Package sentence :: Module coupledparallelsentence :: Class CoupledParallelSentence
[hide private]
[frames] | no frames]

Class CoupledParallelSentence

source code

                       object --+    
                                |    
parallelsentence.ParallelSentence --+
                                    |
                                   CoupledParallelSentence

A coupled parallelsentence contains two sources, two respective translations and their corresponding attributes

Instance Methods [hide private]
 
__init__(self, ps1, ps2=None, **kwargs)
Constructor @type source SimpleSentence @param source The source text of the parallel sentence @type translations list ( SimpleSentence ) @param translations A list of given translations @type reference SimpleSentence @param reference The desired translation provided by the system @type attributes dict { String name , String value } @param the attributes that describe the parallel sentence
source code
 
get_couple(self) source code
 
_generate_rank(self)
Generates rank attribute after comparing the scores of the two sentences
source code
{str, str}
_prefix_parallelsentence_attributes(self, attdict1, attdict2)
Merges two dicts of attributes, so that nothing gets lost and overlapping attributes get prefixed with the id of their original parallelsentence
source code
 
_deprefix(self, attname) source code
({str: str}, {str: str})
_reconstruct_parallelsentence_attributes(self)
Reverses the attributes merging that took place in _prefix_parallelsentence_attributes
source code
 
_collapse_simplesentence_attributes(self, ps1, ps2)
Creates a flat dictionary of attributes for the doubled parallel sentence, containing attributes from its ingredients
source code
 
get_nested_attributes(self)
Override method, since nested attributes have been already propagated up the coupled sentence
source code

Inherited from parallelsentence.ParallelSentence: __eq__, __gt__, __lt__, __str__, add_attributes, add_judgment_id, get_attribute, get_attribute_names, get_attributes, get_compact_id, get_compact_judgment_id, get_filtered_target_attribute_values, get_judgment_id, get_nested_attribute_names, get_pairwise_parallelsentences, get_rank, get_ranking, get_reference, get_source, get_target_attribute_values, get_translations, get_tuple_id, has_judgment_id, import_indexed_parallelsentence, import_missing_parallelsentence, merge_parallelsentence, recover_attributes, remove_ties, serialize, set_id, set_langsrc, set_langtgt, set_reference, set_source, set_translations

Inherited from parallelsentence.ParallelSentence (private): _prefix

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

Instance Variables [hide private]
{str, str} attributes
a dict containing the attributes, as a result of merging the two sentences
SimpleSentence ref
a reference translation
SimpleSentence src
the source sentence
[SimpleSentence, ...] tgt
a list of target sentences / translations
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, ps1, ps2=None, **kwargs)
(Constructor)

source code 

Constructor @type source SimpleSentence @param source The source text of the parallel sentence @type translations list ( SimpleSentence ) @param translations A list of given translations @type reference SimpleSentence @param reference The desired translation provided by the system @type attributes dict { String name , String value } @param the attributes that describe the parallel sentence

Parameters:
Overrides: object.__init__

_prefix_parallelsentence_attributes(self, attdict1, attdict2)

source code 

Merges two dicts of attributes, so that nothing gets lost and overlapping attributes get prefixed with the id of their original parallelsentence

Parameters:
  • attdict1 ({str, str}) - dict with the attributes of the first parallelsentence
  • attdict2 ({str, str}) - dict with the attributes of the second parallelsentence
Returns: {str, str}
merged dict of attributes, prefixed if necessary

_reconstruct_parallelsentence_attributes(self)

source code 

Reverses the attributes merging that took place in _prefix_parallelsentence_attributes

Returns: ({str: str}, {str: str})
two dicts containing the attributes of their respective sentences

get_nested_attributes(self)

source code 

Override method, since nested attributes have been already propagated up the coupled sentence

Overrides: parallelsentence.ParallelSentence.get_nested_attributes