concrete.inspect module¶
Functions used by concrete_inspect.py to print data in a Communication.
The function implementations provide useful examples of how to interact with many different Concrete datastructures.
-
concrete.inspect.penn_treebank_for_parse(parse)¶ Return a Penn-Treebank style representation of a Parse object
Parameters: parse (Parse) – Returns: A string containing a Penn Treebank style parse tree representation Return type: str
-
concrete.inspect.print_communication_taggings_for_communication(comm, tool=None, communication_tagging_filter=None)¶ Print information for
CommunicationTaggingobjectsParameters: - comm (Communication) –
- tool (str) – If not None, only print information for
CommunicationTaggingobjects with a matching metadata.tool field. Mutually exclusive with filter function. - communication_tagging_filter (func) – If not None, print information
for only those
CommunicationTaggingobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
Print ‘CoNLL-style’ tags for the tokens in a Communication. If column is requested (for example, ner is set to True) but there is no such annotation in the communication, that column is not printed (the header is not printed either). If there is more than one such annotation in the communication, one column is printed for each annotation. In the event of differing numbers of annotations per Tokenization, all annotations are printed, but it is not guaranteed that the columns of two different tokenizations correspond to one another.
Parameters: - comm (Communication) –
- char_offsets (bool) – Flag for printing token text specified by
a
Token’s (optional)TextSpan - dependency (bool) – Flag for printing dependency parse HEAD tags
- dependency_tool (str) – If not None, only print information for
DependencyParseobjects if they have a matching metadata.tool field. Mutually exclusive with filter function. - dependency_parse_filter (func) – If not None, print information
for only those
DependencyParseobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered). - lemmas (bool) – Flag for printing lemma tags
(
TokenTaggingobjects of type LEMMA) - lemmas_tool (str) – If not None, only print information for
TokenTaggingobjects of type LEMMA if they have a matching metadata.tool field. Mutually exclusive with filter function. - lemmas_filter (func) – If not None, print information for only those LEMMA taggings that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
- ner (bool) – Flag for printing Named Entity Recognition tags
(
TokenTaggingobjects of type NER) - ner_tool (str) – If not None, only print information for
TokenTaggingobjects of type NER if they have a matching metadata.tool field. Mutually exclusive with filter function. - ner_filter (func) – If not None, print information for only those NER taggings that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
- pos (bool) – Flag for printing Part-of-Speech tags
(
TokenTaggingobjects of type POS) - pos_tool (str) – If not None, only print information for
TokenTaggingobjects of type POS if they have a matching metadata.tool field. Mutually exclusive with filter function. - pos_filter (func) – If not None, print information for only those POS taggings that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
- other_tags (dict) – Map of other tagging types to print (as keys) to annotation filters, or None. If the value (annotation filter) of a given tagging type is not None, print information for only those taggings that pass the filter (should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered)).
-
concrete.inspect.print_entities(comm, tool=None, entity_set_filter=None)¶ Print information for
Entityobjects and their associatedEntityMentionobjectsParameters: - comm (Communication) –
- tool (str) – If not None, only print information for
EntitySetobjects with a matching metadata.tool field. Mutually exclusive with filter function. - entity_set_filter (func) – If not None, print information
for only those
EntitySetobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_id_for_communication(comm, tool=None, communication_filter=None)¶ Print ID field of
CommunicationParameters: - comm (Communication) –
- tool (str) – If not None, only print ID of
Communicationobjects with a matching metadata.tool field. Mutually exclusive with filter function. - communication_filter (func) – If not None, print information
for only those
Communicationobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_metadata(comm, tool=None, annotation_filter=None)¶ Print metadata tools used to annotate Communication
Parameters: - comm (Communication) –
- tool (str) – If not None, only print
AnnotationMetadatainformation for objects with a matching metadata.tool field. Mutually exclusive with filter function. - annotation_filter (func) – If not None, print information for only those objects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_penn_treebank_for_communication(comm, tool=None, parse_filter=None)¶ Print Penn-Treebank parse trees for all
TokenizationobjectsParameters: - comm (Communication) –
- tool (str) – If not None, only print information for
Tokenizationobjects with a matching metadata.tool field. Mutually exclusive with filter function. - parse_filter (func) – If not None, print information
for only those
Parseobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_sections(comm, tool=None, communication_filter=None)¶ Print information for all
Sectionobject, according to their spans.Parameters: - comm (Communication) –
- tool (str) – If not None, only print information for
Sectionobjects with a matching metadata.tool field. Mutually exclusive with filter function. - communication_filter (func) – If not None, print information
for only those
Communicationobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_situation_mentions(comm, tool=None, situation_mention_set_filter=None)¶ Print information for all
SituationMention`s (some of which may not have a :class:.Situation`)Parameters: - comm (Communication) –
- tool (str) – If not None, only print information for
SituationMentionobjects with a matching metadata.tool field. Mutually exclusive with filter function. - situation_mention_set_filter (func) – If not None, print information
for only those
SituationMentionSetobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_situations(comm, tool=None, situation_set_filter=None)¶ Print information for all
Situationobjects and their associatedSituationMentionobjectsParameters: - comm (Communication) –
- tool (str) – If not None, only print information for
Situationobjects with a matching metadata.tool field. Mutually exclusive with filter function. - situation_set_filter (func) – If not None, print information
for only those
SituationSetobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_text_for_communication(comm, tool=None, communication_filter=None)¶ Print text field of :class:.Communication`
Parameters: - comm (Communication) –
- tool (str) – If not None, only print text field of
Communicationobjects with a matching metadata.tool field. Mutually exclusive with filter function. - communication_filter (func) – If not None, print information
for only those
Communicationobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_tokens_for_communication(comm, tool=None, tokenization_filter=None)¶ Print token text for a
CommunicationParameters: - comm (Communication) –
- tool (str) – If not None, only print token text for
Communicationobjects with a matching metadata.tool field. Mutually exclusive with filter function. - tokenization_filter (func) – If not None, print information
for only those
Tokenizationobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).
-
concrete.inspect.print_tokens_with_entityMentions(comm, tool=None, entity_mention_set_filter=None)¶ Print information for
Tokenobjects that are part of anEntityMentionParameters: - comm (Communication) –
- tool (str) – If not None, only print information for tokens
that are associated with an
EntityMentionthat is part of anEntityMentionSetwith a matching metadata.tool field. Mutually exclusive with filter function. - entity_mention_set_filter (func) – If not None, print information
for only those
EntityMentionSetobjects that pass this filter. Should be a function that takes a list of annotations (objects with metadata fields) and returns a list of annotations (possibly filtered and re-ordered).