decomp.semantics.uds.metadata

Classes for representing UDS annotation metadata.

class decomp.semantics.uds.metadata.UDSAnnotationMetadata(metadata)

The metadata for UDS properties by subspace

Parameters

metadata (Dict[str, Dict[str, UDSPropertyMetadata]]) – A mapping from subspaces to properties to datatypes and possibly annotators

properties(subspace=None)

The properties in a subspace

Parameters

subspace (Optional[str]) – The subspace to get the properties of

Return type

Set[str]

class decomp.semantics.uds.metadata.UDSCorpusMetadata(sentence_metadata=<decomp.semantics.uds.metadata.UDSAnnotationMetadata object>, document_metadata=<decomp.semantics.uds.metadata.UDSAnnotationMetadata object>)

The metadata for UDS properties by subspace

This is a thin wrapper around a pair of UDSAnnotationMetadata objects: one for sentence annotations and one for document annotations.

Parameters
document_annotators(subspace=None, prop=None)

The annotators for a property in a document subspace

Parameters
  • subspace (Optional[str]) – The subspace to get the annotators of

  • prop (Optional[str]) – The property to get the annotators of

Return type

Set[str]

document_properties(subspace=None)

The properties in a document subspace

Parameters

subspace (Optional[str]) – The subspace to get the properties of

Return type

Set[str]

sentence_annotators(subspace=None, prop=None)

The annotators for a property in a sentence subspace

Parameters
  • subspace (Optional[str]) – The subspace to get the annotators of

  • prop (Optional[str]) – The property to get the annotators of

Return type

Set[str]

sentence_properties(subspace=None)

The properties in a sentence subspace

Parameters

subspace (Optional[str]) – The subspace to get the properties of

Return type

Set[str]

class decomp.semantics.uds.metadata.UDSDataType(datatype, categories=None, ordered=None, lower_bound=None, upper_bound=None)

A thin wrapper around builtin datatypes

This class is mainly intended to provide a minimal extension of basic builtin datatypes for representing categorical datatypes. pandas provides a more fully featured version of such a categorical datatype but would add an additional dependency that is heavyweight and otherwise unnecessary.

Parameters
  • datatype (Union[str, int, bool, float]) – A builtin datatype

  • categories (Optional[List[Union[str, int, bool, float]]]) – The values the datatype can take on (if applicable)

  • ordered (Optional[bool]) – If this is a categorical datatype, whether it is ordered

  • lower_bound (Optional[float]) – The lower bound value. Neither categories nor ordered need be specified for this to be specified, though if both categories and this are specified, the datatype must be ordered and the lower bound must match the lower bound of the categories.

  • upper_bound (Optional[float]) – The upper bound value. Neither categories nor ordered need be specified for this to be specified, though if both categories and this are specified, the datatype must be ordered and the upper bound must match the upper bound of the categories.

property categories: Union[Set[Union[str, int, bool, float]], List[Union[str, int, bool, float]]]

The categories

A set of the datatype is unordered and a list if it is ordered

Raises

ValueError – If this is not a categorical datatype, an error is raised

Return type

Union[Set[Union[str, int, bool, float]], List[Union[str, int, bool, float]]]

classmethod from_dict(datatype)

Build a UDSDataType from a dictionary

Parameters

datatype (Dict[str, Union[str, List[Union[str, int, bool, float]], bool]]) – A dictionary representing a datatype. This dictionary must at least have a "datatype" key. It may also have a "categorical" and an "ordered" key, in which case it must have both.

Return type

UDSDataType

class decomp.semantics.uds.metadata.UDSPropertyMetadata(value, confidence, annotators=None)

The metadata for a UDS property

classmethod from_dict(metadata)
Parameters

metadata (Dict[str, Union[Set[str], Dict[str, Dict[str, Union[str, List[Union[str, int, bool, float]], bool]]]]]) – A mapping from "value" and "confidence" to decomp.semantics.uds.metadata.UDSDataType. This mapping may optionally specify a mapping from "annotators" to a set of annotator identifiers.

Return type

UDSPropertyMetadata