Predicates¶
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 >>> Predicate("$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 >>> Predicate("$relative1 and $relative2 both were members of the same family")
- Parameters
template (
str
) – a clause containing an assertion in English in the past tense, with placeholders showing where references to specificFactor
s from the case can be inserted to make the clause specific. This string must be a valid Pythonstring.Template
.truth (
Optional
[bool
]) – indicates whether the clause incontent
is asserted to be true or false.None
indicates an assertion as to “whether” the clause is true or false, without specifying which.
Clean up and test validity of attributes.
If the
content
sentence is phrased to have a plural context factor, normalizes it by changing “were” to “was”.
Return repr(self).
Make a sentence by filling in placeholders with names of Factors.
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
Test if
content
strings ofself
andother
have same meaning.This once was used to disregard differences between “was” and “were”, but that now happens in
Predicate.__post_init__()
.
Test whether
self
andother
have identical meanings.To return
True
,other
can be neither broader nor narrower.- Return type
Test whether
self
impliesother
.- Return type
- Returns
whether
self
impliesother
, which isTrue
if their statements about quantity imply it.
Test whether
self
impliesother
.- Return type
Return self>=value.
- Return type
Also called the linguistic valency, arity, or adicity.
- Returns
the number of entities that can fit in the pairs of brackets in the predicate.
self.expression
doesn’t count as one of these entities, even though the place whereself.expression
goes in represented by brackets in theself.content
string.
Copy
self
, with the opposite truth value.- Return type
Create list of positions that each term could take without changing Predicate’s meaning.
Assumes that if placeholders are the same except for a final digit, that means they’ve been labeled as interchangeable with one another.
Get the arrangements of all this Predicate’s terms that preserve the same meaning.
Return str(self).
list of weak references to the object (if defined)
A Predicate that compares a described quantity to a constant.
The Comparison class extends the concept of a Predicate. A Comparison still contains a truth value and a template string, but that template should be used to identify a quantity that will be compared to an expression using a sign such as an equal sign or a greater-than sign. This expression must be a constant: either an integer, a floating point number, or a physical quantity expressed in units that can be parsed using the pint library.
To encourage consistent phrasing, the template string in every Comparison object must end with the word “was”.
If you phrase a Comparison with an inequality sign using truth=False, AuthoritySpoke will silently modify your statement so it can have truth=True with a different sign. In this example, the user’s input indicates that it’s false that the weight of marijuana possessed by a defendant was more than 10 grams. AuthoritySpoke interprets this to mean it’s true that the weight was no more than 10 grams.
>>> # example comparing a pint Quantity >>> drug_comparison_with_upper_bound = Comparison( >>> "the weight of marijuana that $defendant possessed was", >>> sign=">", >>> expression="10 grams", >>> truth=False) >>> str(drug_comparison_with_upper_bound) 'that the weight of marijuana that $defendant possessed was no more than 10 gram'
When the number needed for a Comparison isn’t a physical quantity that can be described with the units in the pint library library, you should phrase the text in the template string to explain what the number describes. The template string will still need to end with the word “was”. The value of the expression parameter should be an integer or a floating point number, not a string to be parsed.
>>> # example comparing an integer >>> three_children = Comparison( >>> "the number of children in ${taxpayer}'s household was", >>> sign="=", >>> expression=3) >>> str(three_children) "that the number of children in ${taxpayer}'s household was exactly equal to 3"
- Parameters
sign (
str
) – A string representing an equality or inequality sign like==
,>
, or<=
. Used to indicate that the clause ends with a comparison to some quantity. Should be defined if and only if aquantity
is defined. Even though “=” is the default, it’s the least useful, because courts almost always state rules that are intended to apply to quantities above or below some threshold.quantity – a Python number object or
ureg.Quantity
from the pint library. Comparisons to quantities can be used to determine whetherPredicate
s imply or contradict each other. A singlePredicate
may contain no more than onesign
and onequantity
.
Clean up and test validity of attributes.
If the
content
sentence is phrased to have a plural context factor, normalizes it by changing “were” to “was”.
Return repr(self).
Create numeric expression from text for Comparison class.
This expression can be a datetime.date, an int, a float, or a pint quantity. (See pint tutorial)
- Parameters
quantity – an object to be interpreted as the
expression
field of aComparison
- Return type
- Returns
a Python number object or a
pint.Quantity
object created withpint.UnitRegistry
.
Test if
other
has a quantity parameter consistent withself
.- Return type
Test whether
self
impliesother
.- Return type
Test whether
self
andother
have identical meanings.To return
True
,other
can be neither broader nor narrower.- Return type
Test whether
other
andself
have contradictory meanings.If the checks in the Predicate class find no contradiction, this method looks for a contradiction in the dimensionality detected by the
pint
library, or in the possible ranges for each Comparison’s numericexpression
.- Return type
Copy
self
, with the opposite truth value.- Return type
Convert text to a comparison with a quantity.
Test if quantity ranges in self and other are non-overlapping.
- Return type
Test if the range of quantities mentioned in self is a subset of other’s.
- Return type