Predicates
Phrases that contain meanings of Statement
s.
Can contain references to other Statement
s,
to numeric values, to dates, or to quantities (with the use of
the pint library).
- class nettlesome.predicates.PhraseABC
Abstract base class for phrases that can be compared like Predicates.
- __ge__(other)
Test whether
self
either implies or has the same meaning asother
.
- __len__()
Get the number of Terms expected.
Also called the linguistic valency, arity, or adicity.
- Returns
the number of
Term
s that can fit in the placeholders in theStatementTemplate
.
- __weakref__
list of weak references to the object (if defined)
- content_without_placeholders()
Get template text with placeholders replaced by identical bracket pairs.
Produces a string that will evaluate equal for two templates with identical non-placedholder text.
- Return type
- contradicts(other)
Test whether
other
andself
have contradictory meanings.This is determined only by the
truth
value, the exact template content, and whether the placeholders indicate interchangeable terms.- Return type
- implies(other)
Test whether
self
impliesother
.A Predicate implies another Predicate only if it
means()
the other Predicate, or if the other Predicate has the same text but a truth value of None.>>> lived_at = Predicate( ... content="$person lived at $place", ... truth=True) >>> whether_lived_at = Predicate( ... content="$person lived at $place", ... truth=None) >>> str(whether_lived_at) 'whether $person lived at $place' >>> lived_at.implies(whether_lived_at) True >>> whether_lived_at.implies(lived_at) False
- means(other)
Test if
self
andother
have identical meanings.The means method will return False based on any difference in the Predicate’s template text, other than the placeholder names.
>>> talked = Predicate(content="$speaker talked to $listener") >>> spoke = Predicate(content="$speaker spoke to $listener") >>> talked.means(spoke) False
The means method will also return False if there are differences in which placeholders are marked as interchangeable.
>>> game_between_others = Predicate( ... content="$organizer1 and $organizer2 planned for $player1 to play $game against $player2.") >>> game_between_each_other = Predicate( ... content="$organizer1 and $organizer2 planned for $organizer1 to play $game against $organizer2.") >>> game_between_others.means(game_between_each_other) False
- same_content_meaning(other)
Test if
content
strings ofself
andother
have same meaning.
- same_term_positions(other)
Test if self and other have same positions for interchangeable Terms.
- Return type
- property template: nettlesome.predicates.StatementTemplate
A text template for the predicate.
- Return type
- Returns
a
StatementTemplate
object
- term_index_permutations()
Get the arrangements of all this Predicate’s terms that preserve the same meaning.
- class nettlesome.predicates.Predicate(**data)
A statement about real events or about a legal conclusion.
Should contain an English-language phrase in the past tense. The past tense is used because legal analysis is usually backward-looking, determining the legal effect of past acts or past conditions.
Don’t use capitalization or end punctuation to signal the beginning or end of the phrase, because the phrase may be used in a context where it’s only part of a longer sentence.
If you need to mention the same term more than once in a Predicate, use the same placeholder for that term each time. If you later create a Fact object using the same Predicate, you will only include each unique term once.
>>> # the template has two placeholders referring to the identical term >>> opened = Predicate(content="$applicant opened a bank account for $applicant and $cosigner")
Sometimes, a Predicate or Comparison needs to mention two terms that are different from each other, but that have interchangeable positions in that particular phrase. To convey interchangeability, the template string should use identical text for the placeholders for the interchangeable terms, except that the different placeholders should each end with a different digit.
>>> # the template has two placeholders referring to different but interchangeable terms >>> members = Predicate(content="$relative1 and $relative2 both were members of the same family")
- Parameters
template – a clause containing an assertion in English in the past tense, with placeholders showing where references to specific terms from the case can be inserted to make the clause specific. This string must be a valid Python
string.Template
.truth – indicates whether the clause in
content
is asserted to be true or false.None
indicates an assertion as to “whether” the clause is true or false, without specifying which.
- __hash__ = None
- __str__()
Return str(self).
- __weakref__
list of weak references to the object (if defined)
- class nettlesome.predicates.StatementTemplate(template, make_singular=True)
A text template for a Predicate.
Should include placeholders for any replaceable
Term
s that can be substituted into thePredicate
.- __init__(template, make_singular=True)
Identify placeholders in template text, and make verbs singular if needed.
>>> school_template = StatementTemplate( ... "$group were at school", make_singular=True) >>> str(school_template) 'StatementTemplate("$group was at school")'
The make_singular flag only affects verbs immediately after
Term
s.>>> text = "$group thought the exams were difficult" >>> exams_template = StatementTemplate(text, make_singular=True) >>> str(exams_template) 'StatementTemplate("$group thought the exams were difficult")'
- Parameters
template (
str
) – text for creating astring.Template
make_singular (
bool
) – whether “were” after a placeholder should be converted to singular “was”
- get_template_with_plurals(context)
Get a version of self with “was” replaced by “were” for any plural terms.
Does not modify this object’s template attribute.
- Return type
- get_term_sequence_from_mapping(term_mapping)
Get an ordered list of terms from a mapping of placeholder names to terms.
- Return type
- mapping_placeholder_to_term(context)
Get a mapping of template placeholders to context terms.
- Parameters
context (
Sequence
[Term
]) – a list of contextfactors.Factor
/s, in the same order they appear in the template string.- Return type
- mapping_placeholder_to_term_name(context)
Get a mapping of template placeholders to the names of their context terms.
- substitute_with_plurals(terms)
Update template text with strings representing Comparable terms.
- Parameters
context – terms with .short_string() methods to substitute into template, and optionally with plural attributes to indicate whether to change the word “was” to “were”
- Return type
- Returns
updated version of template text