Hierarchy

ocdskit.hierarchy.get_base_class_name(class_names, prefix='')[source]

Derive a base class name from the longest common subsequence of words within class names.

Parameters:
  • class_names (list[str]) – a list of class names

  • prefix (str) – a prefix for the base class name

Returns:

a base class name

Return type:

str or None

ocdskit.hierarchy.get_base_classes_via_fca(classes, min_intent=2, min_extent=2, max_field_prevalence=1.0, base_class_name_prefix='')[source]

Identify base classes using Formal Concept Analysis.

Builds a concept lattice from the property sets of each class. Concepts are filtered to those with at least min_extent member classes and min_intent non-inherited, non-common properties. Properties found in more than max_field_prevalence of classes are considered common and ignored for the min_intent threshold.

Parameters:
  • classes (dict) – mapping of definition names to sets of {prop}:{hash} strings

  • min_intent (int) – minimum number of non-inherited, non-common properties for a base class

  • min_extent (int) – minimum number of member classes for a base class

  • max_field_prevalence (float) – fields found in more than this proportion of classes are considered common

  • base_class_name_prefix (str) – a prefix to disambiguate base class names from existing class names

Returns:

a list of dicts with name, members, and props keys

Return type:

list[dict]