| |
- exceptions.Exception
-
- LRAInputError
- Task
- WordPair
class Task |
|
A Task-object represents one analogy-question that is to solve by LRA.
There are the following attributes:
- stem: A WordPair whoms relation is too be found in the choices.
- choices: A list of WordPairs, from which to choose the corresponding
relation to the stem.
- rightChoice: A WordPair that is equal to one of the choices, and whoms
relation is similar to that of the stem. |
|
Methods defined here:
- __init__(self, stem, choices, rightChoice)
- __str__(self)
- compareAllChoicesWithStem(self, aMatrix)
- Compares all choices with the stem by cosinus similarity, and
sets the similarity list to every choices WordPair, so that the
average similarity can be computed later.
- deleteFutureZeroVectors(self)
- Deletes all word pairs that have no phrases in the corpus. If the
stem pair has no phrases in the corpus, an LRAInputError is raised.
- getAllCachedPhrases(self)
- Returns all found phrases of all word pairs, that were found when
calling setPhraseCache.
- getAllPairTuples(self)
- Returns a list of all word pairs that are involved in the task
as tuples.
- getLRAResult(self)
- Returns True if the selection that LRA made matches the actual
right choice, and False othdeerwise.
- setAllAlternates(self, numSim, numFilter, minInter, maxInter)
- Sets all alternates of the task.
- setChoices(self, newChoices)
- setLRAResult(self)
- Calculates the relational similarity of every choice to the stem
pair, and sets the lraChoice attribute to the one choice WordPair
with the highest score.
- setPhraseCache(self, minInter, maxInter)
- Searches for all word pairs involved in the task, and saves all
intervening phrases in the cache of the search engine, if they have
not been stored there. Phrases must have a length of at least
<minInter> and <maxInter> the most.
- setRightChoice(self, newRightChoice)
- setStem(self, newStem)
|
class WordPair |
|
A WordPair contains the original and alternate word pairs. It is
possible to iterate over all of them. The alternates can be set by calling
setAlternates.
The <relationalSimDict> dictionary contains tuples of words as keys and
relational similarities of the WordPair to those words in tuple as values. |
|
Methods defined here:
- __cmp__(self, other)
- __init__(self, pair)
- __str__(self)
- deletePair(self, pairTuple)
- Erases <pairTuple> out of the allPairs list, if <pairTuple> is
not the original. An original can not be deleted, because it is
essential when calculating the relational similarity.
- getAllPairs(self)
- Returns a list of tuples: The original and the alternate word
pairs, if they have been set before.
- getSimilarity(self, stemTuple)
- Returns the relational similarity of the WordPair instance to the
<stemTuple> WordPair.
- printAll(self)
- Prints the original and all alternates.
- setAlternates(self, nrToPull, nrToKeep, minInter, maxInter)
- Sets the alternates to the original word pair. All accepted
alternates are appended to the allPairs list. <nrToPull>
synonyms are fetched from the thesaurus, the top frequent <nrToKeep>
pairs in the corpus remain. Between the two words there may only occur
phrases of length minimum <minInter> and maximum <maxInter>.
- setSimilarity(self, stemTuple, relationalSimilarity)
- Sets the relational similarity of the WordPair instance to the
<stemTuple> WordPair to <relationalSimilarity>.
| |