Package sentence :: Module parallelsentence :: Class ParallelSentence
[hide private]
[frames] | no frames]

Class ParallelSentence

source code

object --+
         |
        ParallelSentence
Known Subclasses:

A parallel sentence, that contains a source sentence, a number of target sentences, a reference and some attributes

Instance Methods [hide private]
 
__init__(self, source, translations, reference=None, attributes={}, rank_name='rank', **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
 
__str__(self)
str(x)
source code
 
__lt__(self, other) source code
 
__gt__(self, other) source code
 
__eq__(self, other) source code
 
get_rank(self)
provide the rank value of the parallel sentence return: the rank value rtype: string
source code
Ranking
get_ranking(self)
returns a ranking list, containing the ranks of the included target translations
source code
dict([(string,string), ...])
get_attributes(self)
provide all attributes
source code
set([string, ...])
get_attribute_names(self)
provide all attribute names
source code
string
get_attribute(self, name)
provide the value of a particular attribute
source code
 
get_target_attribute_values(self, attribute_name, sub=None) source code
 
get_filtered_target_attribute_values(self, attribute_name, filter_attribute_name, filter_attribute_value) source code
 
add_attributes(self, attributes) source code
 
set_langsrc(self, langsrc) source code
 
set_langtgt(self, langtgt) source code
 
set_id(self, id) source code
 
get_compact_id(self) source code
 
get_tuple_id(self) source code
 
get_compact_judgment_id(self) source code
 
get_judgment_id(self) source code
 
has_judgment_id(self) source code
 
add_judgment_id(self, value) source code
 
get_source(self) source code
 
set_source(self, src) source code
 
get_translations(self) source code
 
set_translations(self, tgt) source code
 
get_reference(self) source code
 
set_reference(self, ref) source code
 
get_nested_attribute_names(self) source code
 
get_nested_attributes(self)
function that gathers all the features of the nested sentences to the parallel sentence object, by prefixing their names accordingly
source code
 
recover_attributes(self)
Moves the attributes back to the nested sentences
source code
 
serialize(self) source code
 
_prefix(self, listitems, prefix) source code
 
merge_parallelsentence(self, ps, attribute_replacements={}, **kwargs)
Augment the parallelsentence with another parallesentence.
source code
 
get_pairwise_parallelsentences(self, replacement=True, **kwargs)
Create a set of all available parallel sentence pairs (in tgt) from one ParallelSentence object.
source code
 
import_indexed_parallelsentence(self, parallelsentence, target_attribute_names, keep_attributes_general=[], keep_attributes_source=[], keep_attributes_target=[]) source code
 
import_missing_parallelsentence(self, target_attribute_names, keep_attributes_general=[], keep_attributes_source=[], keep_attributes_target=[]) source code
 
remove_ties(self)
Function that modifies the current parallel sentence by removing the target translations that create ties.
source code

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

Instance Variables [hide private]
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, source, translations, reference=None, attributes={}, rank_name='rank', **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:
  • sort_translations (boolean) - Whether translations should be sorted based on the system name
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

get_ranking(self)

source code 

returns a ranking list, containing the ranks of the included target translations

Returns: Ranking
the ranking list

get_attributes(self)

source code 

provide all attributes

Returns: dict([(string,string), ...])
the parallel sentence attributes dictionary

get_attribute_names(self)

source code 

provide all attribute names

Returns: set([string, ...])
a set with the names of the attributes

get_attribute(self, name)

source code 

provide the value of a particular attribute

Returns: string
the value of the attribute with the specified name

merge_parallelsentence(self, ps, attribute_replacements={}, **kwargs)

source code 

Augment the parallelsentence with another parallesentence. Merges attributes of source, target and reference sentences and adds target sentences whose system doesn't exist. attributes of target sentences that have a common system.

Parameters:
  • ps (sentence.parallelsentence.ParallelSentence) - Object of ParallelSentence() with one source sentence and more target sentences
  • add_missing (boolean) - If translation outputs are missing from the first file but exist in the second, add them (default: True)

get_pairwise_parallelsentences(self, replacement=True, **kwargs)

source code 

Create a set of all available parallel sentence pairs (in tgt) from one ParallelSentence object.

Parameters:
  • ps (sentence.parallelsentence.ParallelSentence

    kwargs:

    ) - Object of ParallelSetnece() with one source sentence and more target sentences
  • replacement (boolean) - If enabled, creates pairs with all possible combinations with replacement
  • include_references (boolean) - Include references as system translations from system "_ref" and lowest rank
  • filter_unassigned (boolean) - If enabled, it filters out pairs with rank = "-1", which means no value was assigned It should not be turned on for test-sets
  • restrict_ranks ([int, ...]) - Filter pairs to keep only for the ones that include the given ranks. Don't filter if list empty. Before using this, make sure that the ranks are normalized
  • p (a list of PairwiseParallelSentence() objects)

remove_ties(self)

source code 

Function that modifies the current parallel sentence by removing the target translations that create ties. Only first translation for each rank is kept