kindred.Sentence

class kindred.Sentence(text, tokens, dependencies, sourceFilename=None)[source]

Set of tokens for a sentence after parsing

Variables:
  • text – Text of the sentence
  • tokens – List of tokens in sentence
  • dependencies – List of dependencies from dependency path. Should be a list of tuples with form (tokenindex1,tokenindex2,dependency_type)
  • sourceFilename – Filename of the source document
  • entityAnnotations – List of entities associated with token indices

Methods

__init__(text, tokens, dependencies, sourceFilename=None)[source]

Constructor for Sentence class

Parameters:
  • text (str) – Text of the sentence
  • tokens (list of kindred.Token) – List of tokens in sentence
  • dependencies (list of tuples) – List of dependencies from dependency path. Should be a list of tuples with form (tokenindex1,tokenindex2,dependency_type)
  • sourceFilename (str) – Filename of the source document
addEntityAnnotation(entity, tokenIndices)[source]

Add an entity annotation to this sentence. Associated a specific entity with the indices of specific tokens

Parameters:
  • entity (kindred.Entity) – Entity to add to sentence
  • tokenIndices (List of ints) – List of token indices
extractMinSubgraphContainingNodes(minSet)[source]

Find the minimum subgraph of the dependency graph that contains the provided set of nodes. Useful for finding dependency-path like structures

Parameters:minSet (List of ints) – List of token indices
Returns:All the nodes and edges in the minimal subgraph
Return type:Tuple of nodes,edges where nodes is a list of token indices, and edges are the associated dependency edges between those tokens