from nltk.tree import Tree
from nltk.stemmer.porter import PorterStemmer
from nltk.featurestructure import FeatureStructure
from nltk_contrib import pywordnet

import enchant

from Senses import Senses, Senses2, Senses3
from DirectionCorpus import printDirs,constructItemRegexp,DirectionCorpusReader,saveParse
from Options import Options
from Utility import logger, lstail

pywordnet.setCacheCapacity(100)
Lexicon = 'Directions/Lexicon2.lex'
Corpus2 = True
if Corpus2: Senses.update(Senses2)
Corpus3 = True
if Corpus3: Senses.update(Senses3)

class ProximateSensesRule(ProximateTokensRule):
    PROPERTY_NAME = 'sense' # for printing.
    TAG='SENSE'
    def extract_property(token): # [staticmethod]
        """@return: The given token's C{SENSE} property."""
        return token['SENSE']
    extract_property = staticmethod(extract_property)

class ProximateStemsRule(ProximateTokensRule):
    PROPERTY_NAME = 'stem' # for printing.
    TAG='STEM'
    def extract_property(token): # [staticmethod]
Example #2
0
from nltk.stemmer.porter import PorterStemmer
from nltk.featurestructure import FeatureStructure
from nltk_contrib import pywordnet

import enchant

from Senses import Senses, Senses2, Senses3
from DirectionCorpus import printDirs, constructItemRegexp, DirectionCorpusReader, saveParse
from Options import Options
from Utility import logger, lstail

pywordnet.setCacheCapacity(100)
Lexicon = "Directions/Lexicon2.lex"
Corpus2 = True
if Corpus2:
    Senses.update(Senses2)
Corpus3 = True
if Corpus3:
    Senses.update(Senses3)


class ProximateSensesRule(ProximateTokensRule):
    PROPERTY_NAME = "sense"  # for printing.
    TAG = "SENSE"

    def extract_property(token):  # [staticmethod]
        """@return: The given token's C{SENSE} property."""
        return token["SENSE"]

    extract_property = staticmethod(extract_property)