Package miopia :: Package analyzer :: Module SentimentAnalyzer :: Class SentimentAnalyzer
[hide private]
[frames] | no frames]

Class SentimentAnalyzer

source code

       object --+    
                |    
Analyzer.Analyzer --+
                    |
                   SentimentAnalyzer

Instances of SentimentAnalyzer evaluates SentimentDependencyGraph's of a text, returning a summary in a SentimentInfo object

Instance Methods [hide private]
 
__init__(self, parser, dictionaries, conf, preprocessor, lexical_processor)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
add_sentiment_info_to_node(self, node, sentiment_info) source code
 
_analyze_graphs(self, dependency_graphs, lsi)
Returns: A tuple ([SentimentDependencyGraph],SentimentInfo) The first element is a list of the dependency graphs of the texts.
source code
 
analyze_from_conll(self, file_path, **kwargs)
It analyzes a file in ConLL-X format
source code
 
analyze_dir(self, dir_path, input_encoding='utf-8')
It analyzes a directory of plain texts
source code
 
analyze_from_conll_list(self, list_conll_files) source code
 
analyze(self, text) source code
 
analyze_from_plain_file(self, file_path, input_encoding='utf-8', **kwargs)
It analyzes a plain file
source code
 
evaluate(self, graph, node)
This method analyzes recursively an instance of a SentimentDependencyGraph
source code
 
_get_lexical_ponderation(self, list_of_lvs)
Returns: A float with the lexical weighting
source code
 
get_sentiment_info(self, graph, node)
Returns: A instance of the SentimentInfo with the sentiment info of that node, considered in an isolated way.
source code
 
visit_function(self, semantic_category)
Returns: An specific visit function according the semantic category of the word
source code
 
_compute_children(self, graph, children)
It aggregates the SentimentInfo of a list of children nodes.
source code
 
_default_join_semantic_orientation(self, parent, children)
The default function for joining the semantic orientation of two src.miope.analyzer.SentimentInfo objects.
source code
 
_default_join_intensification(self, parent, children)
The default function for joining the semantic orientation of two src.miope.analyzer.SentimentInfo objects.
source code
 
_swap_pos_neg_words(self, sentiment_info)
It swaps the positive and negative words of a SentimentInfo object.
source code
 
_join_sentiment_info(self, parent, children, f_join_semantic_orientation, f_join_intensification=None) source code
 
_visit_noun(self, graph, node)
This function processes a noun node and realizes the recursive calls to their children.
source code
 
_visit_adjective(self, graph, node)
This function processes an adjective node and realizes the recursive calls to their children.
source code
 
_visit_verb(self, graph, node)
This function processes a verb node and realizes the recursive calls to their children.
source code
 
_visit_adverb(self, graph, node)
This function processes an adverb node and realizes the recursive calls to their children.
source code
 
_visit_intensifier(self, graph, node)
This function processes an intensfier node and realizes the recursive calls to their children.
source code
 
_visit_adversative(self, graph, node)
This function processes an artificial adversative node and realizes the recursive calls to their children.
source code
 
_shift_negation_without(self, semantic_orientation)
A function to shift the semantic orientation of a 'without' semantic dependent words
source code
 
_shift_negation(self, semantic_orientation)
A function to shift the semantic orientation of a negation semantic dependent words
source code
 
_is_adjunct_node(self, graph, node)
It determines if the node is an adjunct branch
source code
 
is_subjective_node(self, graph, node)
It determines if a node is subjective
source code
 
_negated_and_other_branches(self, graph, children_nodes, inclusion_function, include_all_branches) source code
 
_visit_without_negation(self, graph, node)
This function processes a 'without' node and realizes the recursive calls to their children.
source code
 
_scope_negation_detection(self, graph, node)
This method analyzes the children of a node and determines which branches must be negated and which not.
source code
 
_negation_sentimental_word_rule(self, graph, node, **kwargs)
This function negates the parent of a negation
source code
 
_negation_default_rule(self, graph, node, **kwargs)
This function negates the sibling branches of a negation
source code
 
_negation_sentimental_branch_rule(self, graph, node, **kwargs)
This function negates the negated branches specified in kwargs['negated_branches'].
source code
 
_negation_function(self, delimiter)
Returns: The negation function to apply given a delimiter
source code
 
_visit_negation(self, graph, node)
This function processes a negation node and realizes the recursive calls to their children.
source code
 
_visit_emoticon(self, graph, node)
This function processes a emoticon node and realizes the recursive calls to their children.
source code
 
_visit_other(self, graph, node)
This function processes an other node and realizes the recursive calls to their children.
source code

Inherited from Analyzer.Analyzer: get_semantic_category, negation_node

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parser, dictionaries, conf, preprocessor, lexical_processor)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
Overrides: object.__init__

add_sentiment_info_to_node(self, node, sentiment_info)

source code 
Parameters:

_analyze_graphs(self, dependency_graphs, lsi)

source code 
Parameters:
Returns:
A tuple ([SentimentDependencyGraph],SentimentInfo) The first element is a list of the dependency graphs of the texts. Each node contains their own src.miope.anayzer.SentimentInfo. The second element is SentimentInfo object containing the general information for the whole text

analyze_from_conll(self, file_path, **kwargs)

source code 

It analyzes a file in ConLL-X format

Parameters:
Overrides: Analyzer.Analyzer.analyze_from_conll

To Do: param lsi not integrated yet.

analyze_dir(self, dir_path, input_encoding='utf-8')

source code 

It analyzes a directory of plain texts

Parameters:
  • dir_path - Path to the directory of plain files to be analysed
  • input_encoding - Encoding of the texts inside the directory @return A list of tuples (text_id,([SentimentDependencyGraph],SentimentInfo))
Overrides: Analyzer.Analyzer.analyze_dir

analyze(self, text)

source code 
Parameters:
Overrides: Analyzer.Analyzer.analyze

analyze_from_plain_file(self, file_path, input_encoding='utf-8', **kwargs)

source code 

It analyzes a plain file

Parameters:
Overrides: Analyzer.Analyzer.analyze_from_plain_file

evaluate(self, graph, node)

source code 

This method analyzes recursively an instance of a SentimentDependencyGraph

Parameters:
Returns:
A SentimentInfo

_get_lexical_ponderation(self, list_of_lvs)

source code 
Parameters:
  • list_of_lvs - A list of LexicalValenceShifters
Returns:
A float with the lexical weighting

get_sentiment_info(self, graph, node)

source code 
Parameters:
Returns:
A instance of the SentimentInfo with the sentiment info of that node, considered in an isolated way.

visit_function(self, semantic_category)

source code 
Parameters:
Returns:
An specific visit function according the semantic category of the word

_compute_children(self, graph, children)

source code 

It aggregates the SentimentInfo of a list of children nodes.

Parameters:
Returns:
A SentimentInfo object with the aggregated sentiment info for the children nodes

_default_join_semantic_orientation(self, parent, children)

source code 

The default function for joining the semantic orientation of two src.miope.analyzer.SentimentInfo objects.

Parameters:
  • parent - The SentimentInfo object which contains the semantic info information of a parent node.
  • children - The SentimentInfo object which contains the semantic info information of their children.

_default_join_intensification(self, parent, children)

source code 

The default function for joining the semantic orientation of two src.miope.analyzer.SentimentInfo objects.

Parameters:
  • parent - The SentimentInfo object which contains the semantic info information of a parent node.
  • children - The SentimentInfo object which contains the semantic info information of their children.

_swap_pos_neg_words(self, sentiment_info)

source code 

It swaps the positive and negative words of a SentimentInfo object.

Parameters:
Returns:
The swapped SentimentInfo object

_join_sentiment_info(self, parent, children, f_join_semantic_orientation, f_join_intensification=None)

source code 
Parameters:
  • parent - The parent SentimentInfo object
  • children - The joined SentimentInfo object of the children
  • f_join_semantic_orientation - A function detailing how to join the semantic orientation of the parent and their children

_visit_noun(self, graph, node)

source code 

This function processes a noun node and realizes the recursive calls to their children.

Parameters:

_visit_adjective(self, graph, node)

source code 

This function processes an adjective node and realizes the recursive calls to their children.

Parameters:

_visit_verb(self, graph, node)

source code 

This function processes a verb node and realizes the recursive calls to their children.

Parameters:

_visit_adverb(self, graph, node)

source code 

This function processes an adverb node and realizes the recursive calls to their children.

Parameters:

_visit_intensifier(self, graph, node)

source code 

This function processes an intensfier node and realizes the recursive calls to their children.

Parameters:

_visit_adversative(self, graph, node)

source code 

This function processes an artificial adversative node and realizes the recursive calls to their children.

Parameters:
  • graph - SentimentDependencyGraph
  • node - An artificial adversative node of the graph @return A SentimentInfo. It contains the joined sentiment info of the adversative node and their children.

_shift_negation_without(self, semantic_orientation)

source code 

A function to shift the semantic orientation of a 'without' semantic dependent words

Parameters:
  • semantic_orientation - An integer @return The shifted semantic orientation

_shift_negation(self, semantic_orientation)

source code 

A function to shift the semantic orientation of a negation semantic dependent words

Parameters:
  • semantic_orientation - An integer @return The shifted semantic orientation

_is_adjunct_node(self, graph, node)

source code 

It determines if the node is an adjunct branch

Parameters:
Returns:
A boolean.

is_subjective_node(self, graph, node)

source code 

It determines if a node is subjective

Parameters:
Returns:
A boolean

_negated_and_other_branches(self, graph, children_nodes, inclusion_function, include_all_branches)

source code 
Parameters:
  • graph - An instance of SentimentDependencyGraph
  • children_nodes - A list of the children_nodes
  • inclusion_function - A function to determine if a node should be negated or not.
  • include_all_branches - A boolean. True: It negates all the nodes that match the inclusion function. False: It only includes the first node that match the inclusion function @return A tuple ([negated_nodes],[non_negated_nodes])

_visit_without_negation(self, graph, node)

source code 

This function processes a 'without' node and realizes the recursive calls to their children.

Parameters:
  • graph - An instance of SentimentDependencyGraph
  • node - An artificial without node of the graph @return A SentimentInfo. It contains the joined sentiment info of the without node and their children.

_scope_negation_detection(self, graph, node)

source code 

This method analyzes the children of a node and determines which branches must be negated and which not.

Parameters:
Returns:
A NegationInfo object

_negation_sentimental_word_rule(self, graph, node, **kwargs)

source code 

This function negates the parent of a negation

Parameters:

_negation_default_rule(self, graph, node, **kwargs)

source code 

This function negates the sibling branches of a negation

Parameters:

_negation_sentimental_branch_rule(self, graph, node, **kwargs)

source code 

This function negates the negated branches specified in kwargs['negated_branches']. The branches inside the parameter kwargs['other_branches'] are not negated

Parameters:
  • graph - An instance of SentimentDependencyGraph
  • node - A node of the graph
  • **kwargs - Keys ={'negated_branches','other_branches'}. The parameter 'negated_branches' represent a list of nodes at the same level are negated. The parameter 'other_branches' represent a list of node at the same level that are not negated.

_negation_function(self, delimiter)

source code 
Parameters:
Returns:
The negation function to apply given a delimiter

_visit_negation(self, graph, node)

source code 

This function processes a negation node and realizes the recursive calls to their children.

Parameters:

_visit_emoticon(self, graph, node)

source code 

This function processes a emoticon node and realizes the recursive calls to their children.

Parameters:

_visit_other(self, graph, node)

source code 

This function processes an other node and realizes the recursive calls to their children.

Parameters: