Package translate :: Package search :: Module match :: Class matcher |
[hide private]
[frames] | no frames]

# Class matcher

source code

A class that will do matching and store configuration for the matching process

Instance Methods | [hide private]
__init__(self, store, max_candidates=10, min_similarity=75, max_length=70, comparer=None, usefuzzy=False) max_candidates is the maximum number of candidates that should be assembled, min_similarity is the minimum similarity that must be attained to be included in the result, comparer is an optional Comparer with similarity() function | source code
usable(self, unit) Returns whether this translation unit is usable for TM | source code
inittm(self, stores, reverse=False) Initialises the memory for later use. | source code
extendtm(self, units, store=None, sort=True) Extends the memory with extra unit(s). | source code
setparameters(self, max_candidates=10, min_similarity=75, max_length=70) Sets the parameters without reinitialising the tm. | source code
getstoplength(self, min_similarity, text) Calculates a length beyond which we are not interested. | source code
getstartlength(self, min_similarity, text) Calculates the minimum length we are interested in. | source code
list |
matches(self, text) Returns a list of possible matches for given source text. | source code
buildunits(self, candidates) Builds a list of units conforming to base API, with the score in the comment | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables | [hide private]
| sort_reverse = `False` Parse an instance of this class from the start of the given string.

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, store, max_candidates=10, min_similarity=75, max_length=70, comparer=None, usefuzzy=False) (Constructor) | source code
max_candidates is the maximum number of candidates that should be assembled, min_similarity is the minimum similarity that must be attained to be included in the result, comparer is an optional Comparer with similarity() function Overrides: object.__init__

### inittm(self, stores, reverse=False) | source code
Initialises the memory for later use. We use simple base units for speedup.

### extendtm(self, units, store=None, sort=True) | source code
Extends the memory with extra unit(s). Parameters: `units` - The units to add to the TM. `store` - Optional store from where some metadata can be retrieved and associated with each unit. `sort` - Optional parameter that can be set to False to supress sorting of the candidates list. This should probably only be used in inittm().

### setparameters(self, max_candidates=10, min_similarity=75, max_length=70) | source code
Sets the parameters without reinitialising the tm. If a parameter is not specified, it is set to the default, not ignored

### getstoplength(self, min_similarity, text) | source code
Calculates a length beyond which we are not interested. The extra fat is because we don't use plain character distance only.

### getstartlength(self, min_similarity, text) | source code
Calculates the minimum length we are interested in. The extra fat is because we don't use plain character distance only.

### matches(self, text) | source code
Returns a list of possible matches for given source text. Parameters: `text` (String) - The text that will be search for in the translation memory Returns: list a list of units with the source and target strings from the translation memory. If self.addpercentage is true (default) the match quality is given as a percentage in the notes.