Package miopia :: Package parser :: Module Parser :: Class Parser
[hide private]
[frames] | no frames]

Class Parser

source code

object --+
         |
        Parser
Known Subclasses:

Instance Methods [hide private]
 
__init__(self, lang='es')
Constructor
source code
 
parse_from_conll(self, file_path)
Returns: A list of SentimentDependencyGraph which represent the parsed file.
source code
 
parse_dir_to_file(self, dir_path, list_of_tagged_sentences, input_path='/tmp/parse_dir_to_file_unparsed.conll', output_path='/tmp/parse_dir_to_file_parsed.conll')
It parses a whole directory of plain texts into a single file
source code
 
parse_to_file(self, output_path, tagged_sentences, aux_path=None) source code
 
parse_tagged_file(self, tagged_file_name, output_file_name) source code
 
parse_dir(self, list_of_tagged_sentences) source code
 
parse(self, tagged_sentences, temp_input=None, temp_output=None)
Returns: A [SentimentDependencyGraph]
source code
 
_simplify(self, parsed_file)
Simplifies a CoNLL 2006 file.
source code
 
_right_brothers(self, sentence, identifier)
Returns: A list of right brothers id's of the adversative clause
source code
 
_reorganize(self, sentences)
Reorganizes the output_parsed CoNLL 2006 file to simplify the subordinating sentences
source code
 
_is_symbolic_url(self, token) source code
 
_reorganize_symbolic_url(self, sentence, key) source code
 
_is_emoticon(self, token)
@param token A TokenDependencyInfo instance
source code
 
_reorganize_emoticon(self, sentence, key) source code
 
_is_reorganizable_adversative(self, token)
Returns: True if token can be reorganized ('pero','sino','mientras','mientras_que','sino_que'), False otherwise
source code
 
_reorganize_adversative(self, sentence, key)
Returns:
source code
 
_type_of_adversative(self, form)
Returns: 'restrict' if the clause is restrictive, 'exclude' otherwise
source code
 
_format(self, sentences)
Prepares a text to get a DependencyGraph instance
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __lang = 'es'
Tools for interacting with MaltParser 1.7* and obtaining SentimentDependencyGraph
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, lang='es')
(Constructor)

source code 

Constructor

Overrides: object.__init__

parse_from_conll(self, file_path)

source code 
Parameters:
  • file_path - A path to a CoNLL 2006 file
Returns:
A list of SentimentDependencyGraph which represent the parsed file.

parse_dir_to_file(self, dir_path, list_of_tagged_sentences, input_path='/tmp/parse_dir_to_file_unparsed.conll', output_path='/tmp/parse_dir_to_file_parsed.conll')

source code 

It parses a whole directory of plain texts into a single file

Parameters:
  • dir_path - The directory where the files and the sentences stored in list_of_tagged_sentences will be written in CoNLL-2006 format.
  • aux_path - The path to the file where all plain sentences will be written in CoNLL 2006 format before parsing them
  • list_of_tagged_sentences - A list of (text_id,[[(token,INfoTag)]].

parse_to_file(self, output_path, tagged_sentences, aux_path=None)

source code 
Parameters:
  • output_path - The destination file.
  • tagged_sentences - [tagged_sentence] where tagged_sentences is a [(token,INfoTag)]. Use LexicalProcessor to obtain them.
  • aux_path - The path to an auxiliary file to parse the sentences.

parse(self, tagged_sentences, temp_input=None, temp_output=None)

source code 
Parameters:
  • tagged_sentences - [tagged_sentence] where tagged_sentences is a [(token,INfoTag)]. Use LexicalProcessor to obtain them.
  • input - Temporal file to save the unparsed text.
  • output - Temporal file to save the parsed text.
Returns:
A [SentimentDependencyGraph]

_simplify(self, parsed_file)

source code 

Simplifies a CoNLL 2006 file. The output is used to build instances of SentimentDependencyGraph

Parameters:
  • parsed_file - A path to a CoNLL 2006 file @return A list of dictionaries. Each dictionary saves a sentence of the file. ID is the key and the string FORM POSTAG HEAD DEPREL is the value

_right_brothers(self, sentence, identifier)

source code 
Parameters:
  • sentence - An adversative sentence
  • identifier - ID of adversative clause
Returns:
A list of right brothers id's of the adversative clause

_reorganize(self, sentences)

source code 

Reorganizes the output_parsed CoNLL 2006 file to simplify the subordinating sentences

Parameters:
  • sentences - A list of dictionaries. Each dictionaries is a sentence in CoNLL 2006 representation. ID is the key and and the string FORM POSTAG HEAD DEPREL is the value.

_is_symbolic_url(self, token)

source code 
Parameters:
  • token - A TokenDependencyInfo instance @return True is token form equals to 'SymbolicURL', False otherwise

_reorganize_symbolic_url(self, sentence, key)

source code 
Parameters:
  • sentence - A dictionary of TokenDependencyInfo. Represents a sentence in CoNLL-2006. ID column is the key.
  • key - ID of the symbolic url token @return A modified dictionary with modified information to the symbolic url token

Precondition: The TokenDependencyInfo sentence[key] must be a symbolic url

_is_emoticon(self, token)

source code 

@param token A TokenDependencyInfo instance

Returns:
True if token form is in set (['Emoticon-Negative','Emoticon-Positive', 'Extremely-Emoticon-Positive', 'Extremely-Emoticon-Negative', 'Neutral']), False otherwise

_reorganize_emoticon(self, sentence, key)

source code 
Parameters:
  • sentence - A dictionary of TokenDependencyInfo. Represents a sentence in CoNLL-2006. ID column is the key.
  • key - ID of the emoticon token @return A modified dictionary with modified information to the symbolic emoticon token

Precondition: The TokenDependencyInfo sentence[key] must be an emoticon

_is_reorganizable_adversative(self, token)

source code 
Parameters:
Returns:
True if token can be reorganized ('pero','sino','mientras','mientras_que','sino_que'), False otherwise

_reorganize_adversative(self, sentence, key)

source code 
Parameters:
  • sentence - A dictionary of a sentence in CoNLL 2006. ID is the key and and the string FORM POSTAG HEAD DEPREL is the value.
  • key - ID of an adversative clause

Precondition: Adversative clause must be reorganizable

_type_of_adversative(self, form)

source code 
Parameters:
  • form - An adversative clause
Returns:
'restrict' if the clause is restrictive, 'exclude' otherwise

Precondition: form must be in {'pero','sino','mientras','mientras_que','sino_que'}