Analogies

class authorityspoke.factors.Analogy(need_matches, available, comparison)

Two groups of Factors and a function that must hold between them.

Can be used to find ways to assign the Factors’ context assignments consistently with the Analogy.

Parameters
  • need_matches (Sequence[Optional[Factor]]) – Factors that all need to satisfy the comparison with some Factor of available for the relation to hold.

  • available (Sequence[Optional[Factor]]) – Factors available for matching with the need_matches Factors, but that don’t all need to be matched themselves for the relation to hold.

  • comparison (Callable) – a function defining the comparison that must be True between each need_matches and some available for the relation to hold. Could be Factor.means() or Factor.__ge__().

ordered_comparison(context=None)

Find ways for a series of pairs of Factors to satisfy a comparison.

Parameters

context (Optional[ContextRegister]) – keys representing Factors in self and values representing Factors in other. The keys and values have been found in corresponding positions in self and other.

Yields

every way that matches can be updated to be consistent with each element of self.need_matches having the relationship self.comparison with the item at the corresponding index of self.available.

Return type

Iterator[ContextRegister]

unordered_comparison(matches, still_need_matches=None)

Find ways for two unordered sets of Factors to satisfy a comparison.

Parameters
  • matches (ContextRegister) – a mapping of Factors that have already been matched to each other in the recursive search for a complete group of matches. Starts empty when the method is first called.

  • still_need_matches (Optional[List[Factor]]) – Factors that need to satisfy the comparison comparison with some Factor of available for the relation to hold, and have not yet been matched.

Yields

context registers showing how each Factor in need_matches can have the relation comparison with some Factor in available_for_matching, with matching context.

Return type

Iterator[ContextRegister]

update_matchlist(matchlist, inverse=False)

Filter context assignments with unordered_comparison().

Parameters

matchlist (List[ContextRegister]) – possible ways to match generic Factors of need_matches with available.

Return type

List[ContextRegister]

Returns

a new version of matchlist filtered to be consistent with self’s unordered_comparison().

authorityspoke.factors.all_analogy_matches(relations, inverse=False, context=None)

Find all context registers consistent with multiple Analogy comparisons.

Parameters

relations (Tuple[Analogy, …]) – a series of Analogy comparisons in which the need_matches Factors all refer to one context (for instance, the same Opinion), and the available Factors all refer to another context.

Return type

List[ContextRegister]

Returns

a list of all context registers consistent with all of the Analogys.