Opinions

class authorityspoke.opinions.Opinion(position=None, author=None, text=None)

A document that resolves legal issues in a case and posits legal holdings.

Usually an opinion must have position="majority" to create holdings binding on any courts.

Parameters
  • position (Optional[str]) – the opinion’s attitude toward the court’s disposition of the case. e.g. majority, dissenting, concurring, concurring in the result

  • author (Optional[str]) – name of the judge who authored the opinion, if identified

  • text (Optional[str]) –

__post_init__()

Add attributes to store Holdings and Factors keyed to their text selectors.

The holding_anchors are text selectors for the whole Holding, not for any individual Factor. Often select text used to indicate whether the Rule is mandatory, universal, valid, or decided, or show the exclusive way to reach the outputs.

clear_holdings()

Remove all Holdings from the opinion.

explanations_contradiction(other)

Yield contexts that would result in a contradiction between self and other.

Return type

Iterator[Explanation]

comparable_with(other)

Check if other can be compared to self for implication or contradiction.

Return type

bool

contradicts(other, context=None)

Test whether self implies the absence of other.

Return type

bool

Returns

True if self and other can’t both be true at the same time. Otherwise returns False.

implies(other, context=None)

Test whether self implies other.

When inherited by FactorGroup, this method will check whether every Statement in other is implied by some Statement in self.

>>> from nettlesome import Entity, Comparison, Statement, FactorGroup
>>> over_100y = Comparison("the distance between $site1 and $site2 was", sign=">", expression="100 yards")
>>> under_1mi = Comparison("the distance between $site1 and $site2 was", sign="<", expression="1 mile")
>>> protest_facts = FactorGroup(
...     [Statement(over_100y, terms=[Entity("the political convention"), Entity("the police cordon")]),
...      Statement(under_1mi, terms=[Entity("the police cordon"), Entity("the political convention")])])
>>> over_50m = Comparison("the distance between $site1 and $site2 was", sign=">", expression="50 meters")
>>> under_2km = Comparison("the distance between $site1 and $site2 was", sign="<=", expression="2 km")
>>> speech_zone_facts = FactorGroup(
...     [Statement(over_50m, terms=[Entity("the free speech zone"), Entity("the courthouse")]),
...      Statement(under_2km, terms=[Entity("the free speech zone"), Entity("the courthouse")])])
>>> protest_facts.implies(speech_zone_facts)
True
Return type

bool

explain_implication(other)

Get one explanation of why self implies other.

Return type

Optional[Explanation]

explain_contradiction(other)

Get one explanation of why self and other contradict.

Using the explanations_contradiction() method, generates one Explanation of how an analogy between the generic terms of the two objects can make them contradictory.

In this example using two FactorGroups, if the three Statements in brexit were asserted about the three Entity terms in nafta, there would be an inconsistency as to whether one pair of Entities signed a treaty with each other.

>>> from nettlesome import Statement, Entity, FactorGroup
>>> nafta = FactorGroup([
...     Statement("$country1 signed a treaty with $country2",
...               terms=[Entity("Mexico"), Entity("USA")]),
...     Statement("$country2 signed a treaty with $country3",
...               terms=[Entity("USA"), Entity("Canada")]),
...     Statement("$country3 signed a treaty with $country1",
...           terms=[Entity("USA"), Entity("Canada")])])
>>> brexit = FactorGroup([
...     Statement("$country1 signed a treaty with $country2",
...               terms=[Entity("UK"), Entity("European Union")]),
...     Statement("$country2 signed a treaty with $country3",
...               terms=[Entity("European Union"), Entity("Germany")]),
...     Statement("$country3 signed a treaty with $country1",
...          terms=[Entity("Germany"), Entity("UK")], truth=False)])
>>> print(nafta.explain_contradiction(brexit))
Because <Mexico> is like <Germany>, and <USA> is like <UK>,
  the statement that <Mexico> signed a treaty with <USA>
CONTRADICTS
  the statement it was false that <Germany> signed a treaty with <UK>
Return type

Optional[Explanation]

explanations_implication(other)

Yield contexts that would result in self implying other.

Return type

Iterator[Union[ContextRegister, Explanation]]

generic_terms_by_str()

Get all generic Factors mentioned in self.

Return type

Dict[str, Comparable]

Returns

a list of generic Factor objects mentioned in any input, output, or despite Factor of self, with guaranteed order, including each generic Factor only once.

get_factor_by_name(name)

Search recursively in holdings of self for Factor with name.

Parameters

name (str) – string to match with the name attribute of the Factor being searched for.

Return type

Optional[Comparable]

Returns

a Factor with the specified name, if one exists in a Rule in self.holdings. Otherwise None.

get_factor_by_str(query)

Search recursively for Factor in holdings of self.

Return type

Optional[Factor]

posit_holding(holding, holding_anchors=None, named_anchors=None, enactment_anchors=None, context=None)

Record that this Opinion endorses specified Holdings.

Return type

None

posit_holdings(holdings, holding_anchors=None, named_anchors=None, enactment_anchors=None, context=None)

Add Holdings to this Opinion from a sequence.

Parameters
  • holdings (Union[AnchoredHoldings, Iterable[Union[Holding, Rule]]]) – a sequence of Holdings that this Opinion posits as valid in its own court or jurisdiction, regardless of whether self accepts that the inputs correspond to the reality of the current case, and regardless of whether the court orders that the outputs be put into effect.

  • text_links – mapping of Factors to the Opinion passages where they can be found. Can be obtained as the mentioned return value of one of the functions in authorityspoke.io.readers.

  • context (Optional[Sequence[Factor]]) – an ordered sequence (probably dict) of generic Factor objects from self which will provide the context for the new holding in the present case.

posit(holdings, holding_anchors=None, named_anchors=None, enactment_anchors=None, context=None)

Add one or more Holdings to this Opinion.

This method passes its values to posit_holding() or posit_holdings() depending on whether the holding parameter is one Holding or a list.

Parameters
  • holdings (Union[AnchoredHoldings, Holding, Iterable[Union[Holding, Rule]]]) – a Holding that the Opinion self posits as valid in its own court or jurisdiction, regardless of whether self accepts that the inputs of the Holding correspond to the reality of the current case, and regardless of whether the court orders that the outputs of the Holding be put into effect.

  • text_links – list of lists of Opinion passages where references to each Holding can be found.

  • context (Optional[Sequence[Factor]]) – an ordered sequence (probably dict) of generic Factor objects from self which will provide the context for the new holding in the present case.

Return type

None

implied_by(other, context=None)

Determine if other implies all the Holdings of self.

Return type

bool

__ge__(other)

Find whether self’s holdings imply all the holdings of other.

Return type

bool

Returns

a bool indicating whether the Rule other (or every holding of other, if other is an Opinion) is implied by some Rule in self.holdings.

__gt__(other)

Find whether self’s holdings imply other’s but self != other.

This actually tests for inequality because Opinion does not have a means method.

Return type

bool

Returns

self >= other and self != other.

select_text(selector)

Get text using a TextQuoteSelector.

Parameters

selector (TextQuoteSelector) – a selector referencing a text passage in this Opinion.

Return type

Optional[str]

Returns

the text referenced by the selector, or None if the text can’t be found.

__str__()

Return str(self).

class authorityspoke.opinions.AnchoredHoldings(holdings: List[Holding], holding_anchors: List[List[TextQuoteSelector]], named_anchors: TextLinkDict, enactment_anchors: TextLinkDict)

Holdings with objects storing the Holdings’ links to Opinion text.

holdings: List[authorityspoke.holdings.Holding]

Alias for field number 0

holding_anchors: List[List[anchorpoint.textselectors.TextQuoteSelector]]

Alias for field number 1

named_anchors: Dict[str, List[anchorpoint.textselectors.TextQuoteSelector]]

Alias for field number 2

enactment_anchors: Dict[str, List[anchorpoint.textselectors.TextQuoteSelector]]

Alias for field number 3

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__repr__()

Return a nicely formatted representation string