Module KafNafParserMod :: Class KafNafParser
[hide private]
[frames] | no frames]

Class KafNafParser

source code

Instance Methods [hide private]
 
__init__(self, filename=None, type=None)
The constructor for the parser
source code
 
add_clink(self, my_clink)
Adds a clink to the causalRelations layer
source code
 
add_constituency_tree(self, my_tree)
Adds a constituency tree to the constituency layer
source code
 
add_coreference(self, coreference)
Adds an coreference to the coreference layer
source code
 
add_dependency(self, my_dep)
Adds a dependency to the dependency layer
source code
 
add_entity(self, entity)
Adds an entity to the entity layer
source code
 
add_external_reference(self, term_id, external_ref) source code
 
add_external_reference_to_entity(self, entity_id, external_ref)
Adds an external reference to the given entity identifier in the entity layer
source code
 
add_external_reference_to_role(self, role_id, external_ref)
Adds an external reference to the given role identifier in the SRL layer
source code
 
add_external_reference_to_term(self, term_id, external_ref)
Adds an external reference to the given term identifier
source code
 
add_factuality(self, my_fact)
Adds a factvalue to the factuality layer
source code
 
add_linguistic_processor(self, layer, my_lp)
Adds a linguistic processor to the header
source code
 
add_markable(self, markable_obj)
Adds a markable to the markable layer
source code
 
add_opinion(self, opinion_obj)
Adds an opinion to the opinion layer
source code
 
add_predicate(self, predicate_obj)
Adds a predicate to the semantic layer
source code
 
add_predicateAnchor(self, my_predAnch)
Adds a predAnch to the temporalRelations layer
source code
 
add_property(self, label, term_span, pid=None)
Adds a property to the property layer
source code
 
add_term(self, term_obj)
Adds a term to the term layer
source code
 
add_timex(self, time_obj)
Adds a timex entry to the time layer
source code
 
add_tlink(self, my_tlink)
Adds a tlink to the temporalRelations layer
source code
 
add_wf(self, wf_obj)
Adds a token to the text layer
source code
 
convert_factualitylayer_to_factualities(self)
Takes information from factuality layer in old representation Creates new factuality representation and removes the old layer
source code
 
dump(self, filename=<epydoc.docintrospecter._DevNull instance at 0x7fcb5108c7a0>)
Dumps the object to an output filename (or open file descriptor).
source code
Cclink
get_clinks(self)
Iterator that returns the clinks from the causalRelations layer.
source code
Cconstituency_extractor
get_constituency_extractor(self)
Returns a constituency extractor object
source code
Ccoreference
get_corefs(self)
Iterator that returns the corefs from the coreferences layer.
source code
Cdependency
get_dependencies(self)
Iterator that returns the dependencies from the dependency layer.
source code
Cdependency_extractor
get_dependency_extractor(self)
Returns a dependency extractor object
source code
list
get_dict_tokens_for_termid(self, term_id)
Returns the tokens ids that are the span of the term specified
source code
Centity
get_entities(self)
Returns a list of all the entities in the object
source code
Centity
get_entity(self, entity_id)
Returns an entity object for the specified entity_id
source code
Cfactvalue
get_factvalues(self)
Iterator that returns the factvalues from the factuality layer.
source code
string
get_filename(self)
Returns the name of the filename
source code
CHeader
get_header(self)
Returns the header object
source code
string
get_language(self)
Returns the code language of the file
source code
Cmarkable
get_markable(self, markable_id)
Returns a markable object for the specified markable_id
source code
Cmarkable
get_markables(self)
Iterator that returns all the markables from the markable layer
source code
Copinion
get_opinions(self)
Returns a list of all the opinions in the object
source code
Cpredicate
get_predicates(self)
Returns a list of all the predicates in the object
source code
Cproperty
get_properties(self)
Returns all the properties of the features layer (iterator)
source code
string
get_raw(self)
Returns the raw text as a string
source code
Cterm
get_term(self, term_id)
Returns a term object for the specified term_id
source code
Cterm
get_terms(self)
Iterator that returns all the terms from the term layer
source code
Ctime
get_timeExpressions(self)
Returns a list of all the timeexpressions in the text
source code
Ctlink
get_tlinks(self)
Iterator that returns the tlinks from the temporalRelations layer.
source code
Cwf
get_token(self, token_id)
Returns a token object for the specified token_id
source code
Cwf
get_tokens(self)
Iterator that returns all the tokens from the text layer
source code
Ctree
get_trees(self)
Iterator that returns the constituency trees
source code
Ctree
get_trees_as_list(self)
Iterator that returns the constituency trees
source code
string
get_type(self)
Returns the type (NAF/KAF) of the object
source code
list
map_tokens_to_terms(self, list_tokens)
Maps a list of token ids to the corresponding term ids
source code
 
print_constituency(self)
Prints the constituency layer
source code
 
remove_causalRelations_layer(self)
Removes the causalRelations layer (if exists) of the object (in memory)
source code
 
remove_constituency_layer(self)
Removes the constituency layer (if exists) of the object (in memory)
source code
 
remove_coreference_layer(self)
Removes the constituency layer (if exists) of the object (in memory)
source code
 
remove_dependency_layer(self)
Removes the dependency layer (if exists) of the object (in memory)
source code
 
remove_entity_layer(self)
Removes the entity layer (if exists) of the object (in memory)
source code
 
remove_external_references_from_srl_layer(self)
Removes all external references present in the term layer
source code
 
remove_external_references_from_terms(self)
Removes all external references present in the term layer
source code
 
remove_factualitylayer_layer(self)
Removes the factualitylayer layer (the old version) (if exists) of the object (in memory)
source code
 
remove_opinion_layer(self)
Removes the opinion layer (if exists) of the object (in memory)
source code
 
remove_properties(self)
Removes the property layer (if exists) of the object (in memory)
source code
 
remove_temporalRelations_layer(self)
Removes the temporalRelations layer (if exists) of the object (in memory)
source code
 
remove_term_layer(self)
Removes the term layer (if exists) of the object (in memory)
source code
 
remove_terms(self, list_term_ids)
Removes the list of terms specified
source code
 
remove_text_layer(self)
Removes the text layer (if exists) of the object (in memory)
source code
 
remove_this_opinion(self, opinion_id)
Removes the opinion with the provided opinion identifier
source code
 
remove_tokens_of_sentence(self, sentence_id)
Removes the tokens belonging to the supplied sentence
source code
 
set_header(self, header)
Sets the header of the object
source code
 
set_language(self, l)
Sets the language to the KAF root element
source code
 
set_raw(self, text)
Sets the text of the raw element (or creates the layer if does not exist)
source code
 
set_version(self, v)
Sets the language to the KAF root element
source code
 
to_kaf(self)
Converts a NAF object to KAF (in memory).
source code
 
to_naf(self)
Converts a KAF object to NAF (in memory).
source code
Method Details [hide private]

__init__(self, filename=None, type=None)
(Constructor)

source code 

The constructor for the parser

Parameters:
  • filename (string) - KAF/NAF filename. Set it to None to create an empty file
  • type (string) - to indicate if the file will be a NAF or a KAF file, in case of new files.

add_clink(self, my_clink)

source code 

Adds a clink to the causalRelations layer

Parameters:
  • my_clink (Cclink) - clink object

add_constituency_tree(self, my_tree)

source code 

Adds a constituency tree to the constituency layer

Parameters:
  • my_tree (Ctree) - the constituency tree object

add_coreference(self, coreference)

source code 

Adds an coreference to the coreference layer

Parameters:

add_dependency(self, my_dep)

source code 

Adds a dependency to the dependency layer

Parameters:

add_entity(self, entity)

source code 

Adds an entity to the entity layer

Parameters:
  • entity (Centity) - the entity object

add_external_reference_to_entity(self, entity_id, external_ref)

source code 

Adds an external reference to the given entity identifier in the entity layer

Parameters:
  • entity_id (string) - the entity identifier
  • external_ref (CexternalReference) - an external reference object

add_external_reference_to_role(self, role_id, external_ref)

source code 

Adds an external reference to the given role identifier in the SRL layer

Parameters:
  • role_id (string) - the role identifier
  • external_ref (CexternalReference) - an external reference object

add_external_reference_to_term(self, term_id, external_ref)

source code 

Adds an external reference to the given term identifier

Parameters:
  • term_id (string) - the term identifier
  • external_ref (CexternalReference) - an external reference object

add_factuality(self, my_fact)

source code 

Adds a factvalue to the factuality layer

Parameters:

add_linguistic_processor(self, layer, my_lp)

source code 

Adds a linguistic processor to the header

Parameters:
  • my_lp (Clp) - linguistic processor object
  • layer (string) - the layer to which the processor is related to

add_markable(self, markable_obj)

source code 

Adds a markable to the markable layer

Parameters:
  • markable_obj (Cmarkable) - the markable object

add_opinion(self, opinion_obj)

source code 

Adds an opinion to the opinion layer

Parameters:
  • opinion_obj (Copinion) - the opinion object

add_predicate(self, predicate_obj)

source code 

Adds a predicate to the semantic layer

Parameters:
  • predicate_obj (Cpredicate) - the predicate object

add_predicateAnchor(self, my_predAnch)

source code 

Adds a predAnch to the temporalRelations layer

Parameters:

add_property(self, label, term_span, pid=None)

source code 

Adds a property to the property layer

Parameters:
  • label (string) - the type of property
  • term_span (list) - list of term ids
  • pid (string) - the identifier for the property (use None to automatically generate one)

add_term(self, term_obj)

source code 

Adds a term to the term layer

Parameters:
  • term_obj (Cterm) - the term object

add_timex(self, time_obj)

source code 

Adds a timex entry to the time layer

Parameters:
  • time_obj (Ctime) - time time object

add_tlink(self, my_tlink)

source code 

Adds a tlink to the temporalRelations layer

Parameters:
  • my_tlink (Ctlink) - tlink object

add_wf(self, wf_obj)

source code 

Adds a token to the text layer

Parameters:
  • wf_obj (Cwf) - the token object

dump(self, filename=<epydoc.docintrospecter._DevNull instance at 0x7fcb5108c7a0>)

source code 

Dumps the object to an output filename (or open file descriptor). The filename parameter is optional, and if it is not provided, the standard output will be used

Parameters:
  • filename (string or file descriptor) - file where to dump the object (default standard output)

get_clinks(self)

source code 

Iterator that returns the clinks from the causalRelations layer. Use it as: for my_clink in my_obj.get_clinks():

Returns: Cclink
iterator to get all the clinks

get_constituency_extractor(self)

source code 

Returns a constituency extractor object

Returns: Cconstituency_extractor
a constituency extractor object

get_corefs(self)

source code 

Iterator that returns the corefs from the coreferences layer.

Returns: Ccoreference
iterator to get all the coreferences

get_dependencies(self)

source code 

Iterator that returns the dependencies from the dependency layer. Use it as: for my_dep in my_obj.get_dependencies():

Returns: Cdependency
iterator to get all the dependencies

get_dependency_extractor(self)

source code 

Returns a dependency extractor object

Returns: Cdependency_extractor
a dependency extractor object

get_dict_tokens_for_termid(self, term_id)

source code 

Returns the tokens ids that are the span of the term specified

Parameters:
  • term_id (string) - the term idenfier
Returns: list
list of token ids that are the span of the term

get_entities(self)

source code 

Returns a list of all the entities in the object

Returns: Centity
list of entities (iterator)

get_entity(self, entity_id)

source code 

Returns an entity object for the specified entity_id

Parameters:
  • entity_id (string) - entity identifier
Returns: Centity
entity object

get_factvalues(self)

source code 

Iterator that returns the factvalues from the factuality layer. Use it as: for my_fact in my_obj.get_factvalues():

Returns: Cfactvalue
iterator to get all the factvalues

get_filename(self)

source code 

Returns the name of the filename

Returns: string
the filename of the KAF/NAF object

get_header(self)

source code 

Returns the header object

Returns: CHeader
the header object

get_language(self)

source code 

Returns the code language of the file

Returns: string
language code of the file

get_markable(self, markable_id)

source code 

Returns a markable object for the specified markable_id

Parameters:
  • markable_id (string) - entity identifier
Returns: Cmarkable
markable object

get_markables(self)

source code 

Iterator that returns all the markables from the markable layer

Returns: Cmarkable
list of markable objects

get_opinions(self)

source code 

Returns a list of all the opinions in the object

Returns: Copinion
list of opinions (iterator)

get_predicates(self)

source code 

Returns a list of all the predicates in the object

Returns: Cpredicate
list of predicates (iterator)

get_properties(self)

source code 

Returns all the properties of the features layer (iterator)

Returns: Cproperty
list of properties

get_raw(self)

source code 

Returns the raw text as a string

Returns: string
the raw text

get_term(self, term_id)

source code 

Returns a term object for the specified term_id

Parameters:
  • term_id (string) - token identifier
Returns: Cterm
term object

get_terms(self)

source code 

Iterator that returns all the terms from the term layer

Returns: Cterm
list of term objects

get_timeExpressions(self)

source code 

Returns a list of all the timeexpressions in the text

Returns: Ctime
list of time expressions (iterator)

get_tlinks(self)

source code 

Iterator that returns the tlinks from the temporalRelations layer. Use it as: for my_tlink in my_obj.get_tlinks():

Returns: Ctlink
iterator to get all the tlinks

get_token(self, token_id)

source code 

Returns a token object for the specified token_id

Parameters:
  • token_id (string) - token identifier
Returns: Cwf
token object

get_tokens(self)

source code 

Iterator that returns all the tokens from the text layer

Returns: Cwf
list of token objects

get_trees(self)

source code 

Iterator that returns the constituency trees

Returns: Ctree
iterator to all the constituency trees

get_trees_as_list(self)

source code 

Iterator that returns the constituency trees

Returns: Ctree
iterator to all the constituency trees

get_type(self)

source code 

Returns the type (NAF/KAF) of the object

Returns: string
the type of the file

map_tokens_to_terms(self, list_tokens)

source code 

Maps a list of token ids to the corresponding term ids

Parameters:
  • list_tokens (list) - list of token identifiers
Returns: list
list of term idenfitiers

remove_terms(self, list_term_ids)

source code 

Removes the list of terms specified

Parameters:
  • list_term_ids (list) - list of term identifiers

remove_this_opinion(self, opinion_id)

source code 

Removes the opinion with the provided opinion identifier

Parameters:
  • opinion_id (string) - the opinion identifier of the opinion to remove

remove_tokens_of_sentence(self, sentence_id)

source code 

Removes the tokens belonging to the supplied sentence

Parameters:
  • sentence_id (string) - a sentence identifier

set_header(self, header)

source code 

Sets the header of the object

Parameters:
  • header (CHeader) - the header object

set_language(self, l)

source code 

Sets the language to the KAF root element

Parameters:
  • l (string) - the language code

set_raw(self, text)

source code 

Sets the text of the raw element (or creates the layer if does not exist)

Parameters:
  • text (string) - text of the raw layer

set_version(self, v)

source code 

Sets the language to the KAF root element

Parameters:
  • v (string) - the language code

to_kaf(self)

source code 

Converts a NAF object to KAF (in memory). You will have to use the method dump later to save it as a new KAF file

to_naf(self)

source code 

Converts a KAF object to NAF (in memory). You will have to use the method dump later to save it as a new NAF file