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
CommunicationTagging
objectsParameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print information for
CommunicationTagging
objects with a matching metadata.tool field - communication_tagging_filter (func) – If not None, print information
for only those
CommunicationTagging
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).
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) – Deprecated.
If not None, only print information for
DependencyParse
objects if they have a matching metadata.tool field - dependency_parse_filter (func) – If not None, print information
for only those
DependencyParse
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). - lemmas (bool) – Flag for printing lemma tags
(
TokenTagging
objects of type LEMMA) - lemmas_tool (str) – Deprecated.
If not None, only print information for
TokenTagging
objects of type LEMMA if they have a matching metadata.tool field - 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
(
TokenTagging
objects of type NER) - ner_tool (str) – Deprecated.
If not None, only print information for
TokenTagging
objects of type NER if they have a matching metadata.tool field - 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
(
TokenTagging
objects of type POS) - pos_tool (str) – Deprecated.
If not None, only print information for
TokenTagging
objects of type POS if they have a matching metadata.tool field - 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
Entity
objects and their associatedEntityMention
objectsParameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print information for
EntitySet
objects with a matching metadata.tool field - entity_set_filter (func) – If not None, print information
for only those
EntitySet
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_id_for_communication
(comm, tool=None, communication_filter=None)¶ Print ID field of
Communication
Parameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print ID of
Communication
objects with a matching metadata.tool field - communication_filter (func) – If not None, print information
for only those
Communication
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_metadata
(comm, tool=None, annotation_filter=None)¶ Print metadata tools used to annotate Communication
Parameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print
AnnotationMetadata
information for objects with a matching metadata.tool field - 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
Tokenization
objectsParameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print information for
Tokenization
objects with a matching metadata.tool field - parse_filter (func) – If not None, print information
for only those
Parse
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_sections
(comm, tool=None, communication_filter=None)¶ Print information for all
Section
object, according to their spans.Parameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print information for
Section
objects with a matching metadata.tool field - communication_filter (func) – If not None, print information
for only those
Communication
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_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) – Deprecated.
If not None, only print information for
SituationMention
objects with a matching metadata.tool field - situation_mention_set_filter (func) – If not None, print information
for only those
SituationMentionSet
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_situations
(comm, tool=None, situation_set_filter=None)¶ Print information for all
Situation
objects and their associatedSituationMention
objectsParameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print information for
Situation
objects with a matching metadata.tool field - situation_set_filter (func) – If not None, print information
for only those
SituationSet
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_text_for_communication
(comm, tool=None, communication_filter=None)¶ Print text field of :class:.Communication`
Parameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print text field of
Communication
objects with a matching metadata.tool field - communication_filter (func) – If not None, print information
for only those
Communication
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_tokens_for_communication
(comm, tool=None, tokenization_filter=None)¶ Print token text for a
Communication
Parameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print token text for
Communication
objects with a matching metadata.tool field - tokenization_filter (func) – If not None, print information
for only those
Tokenization
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_tokens_with_entityMentions
(comm, tool=None, entity_mention_set_filter=None)¶ Print information for
Token
objects that are part of anEntityMention
Parameters: - comm (Communication) –
- tool (str) – Deprecated.
If not None, only print information for tokens
that are associated with an
EntityMention
that is part of anEntityMentionSet
with a matching metadata.tool field - entity_mention_set_filter (func) – If not None, print information
for only those
EntityMentionSet
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).