decomp.semantics.uds.document

Module for representing UDS documents.

class decomp.semantics.uds.document.UDSDocument(sentence_graphs, sentence_ids, name, genre, timestamp=None, doc_graph=None)

A Universal Decompositional Semantics document

Parameters
  • sentence_graphs (Dict[str, UDSSentenceGraph]) – the UDSSentenceGraphs associated with each sentence in the document

  • sentence_ids (Dict[str, str]) – the UD sentence IDs for each graph

  • name (str) – the name of the document (i.e. the UD document ID)

  • genre (str) – the genre of the document (e.g. weblog)

  • timestamp (Optional[str]) – the timestamp of the UD document on which this UDSDocument is based

  • doc_graph (Optional[UDSDocumentGraph]) – the NetworkX DiGraph for the document. If not provided, this will be initialized without edges from sentence_graphs

add_annotation(node_attrs, edge_attrs)

Add node or edge annotations to the document-level graph

Parameters
  • node_attrs (Dict[str, Dict[str, Any]]) – the node annotations to be added

  • edge_attrs (Dict[str, Dict[str, Any]]) – the edge annotations to be added

Return type

None

add_sentence_graphs(sentence_graphs, sentence_ids)

Add additional sentences to a document

Parameters
  • sentence_graphs (Dict[str, UDSSentenceGraph]) – a dictionary containing the sentence-level graphs for the sentences in the document

  • sentence_ids (Dict[str, str]) – a dictionary containing the UD sentence IDs for each graph

  • name – identifier to append to the beginning of node ids

Return type

None

classmethod from_dict(document, sentence_graphs, sentence_ids, name='UDS')

Construct a UDSDocument from a dictionary

Since only the document graphs are serialized, the sentence graphs must also be provided to this method call in order to properly associate them with their documents.

Parameters
  • document (Dict[str, Dict]) – a dictionary constructed by networkx.adjacency_data, containing the graph for the document

  • sentence_graphs (Dict[str, UDSSentenceGraph]) – a dictionary containing (possibly a superset of) the sentence-level graphs for the sentences in the document

  • sentence_ids (Dict[str, str]) – a dictionary containing (possibly a superset of) the UD sentence IDs for each graph

  • name (str) – identifier to append to the beginning of node ids

Return type

UDSDocument

semantics_node(document_node)

The semantics node for a given document node

Parameters

document_node (str) – the document domain node whose semantics node is to be retrieved

Return type

Dict[str, Dict]

property text: str

The document text

Return type

str

to_dict()

Convert the graph to a dictionary

Return type

Dict