Пример #1
0
    def __init__(self, path="SentiWordNet*.txt", language="en"):
        """A sentiment lexicon with scores from SentiWordNet.

        The value for each word is a tuple with values for
        polarity (-1.0-1.0), subjectivity (0.0-1.0) and intensity (0.5-2.0).

        """
        Sentiment.__init__(self, path=path, language=language)
Пример #2
0
 def load(self, path=None):
     _Sentiment.load(self, path)
     # Map "verschrikkelijk" to adverbial "verschrikkelijke" (+1%)
     if not path:
         for w, pos in list(dict.items(self)):
             if "JJ" in pos:
                 p, s, i = pos["JJ"]
                 self.annotate(attributive(w), "JJ", p, s, i)
Пример #3
0
 def load(self, path=None):
     _Sentiment.load(self, path)
     # Map "terrible" to adverb "terribly" (+1% accuracy)
     if not path:
         for w, pos in list(dict.items(self)):
             if "JJ" in pos:
                 if w.endswith("y"):
                     w = w[:-1] + "i"
                 if w.endswith("le"):
                     w = w[:-2]
                 p, s, i = pos["JJ"]
                 self.annotate(w + "ly", "RB", p, s, i)
Пример #4
0
 def load(self, path=None):
     _Sentiment.load(self, path)
     # Map "précaire" to "precaire" (without diacritics, +1% accuracy).
     if not path:
         for w, pos in list(dict.items(self)):
             w0 = w
             if not w.endswith(("à", "è", "é", "ê", "ï")):
                 w = w.replace("à", "a")
                 w = w.replace("é", "e")
                 w = w.replace("è", "e")
                 w = w.replace("ê", "e")
                 w = w.replace("ï", "i")
             if w != w0:
                 for pos, (p, s, i) in list(pos.items()):
                     self.annotate(w, pos, p, s, i)
Пример #5
0
 def get(self, k, *args, **kwargs):
     return Sentiment.get(self, normalize(k), *args, **kwargs)
Пример #6
0
 def __getitem__(self, k):
     return Sentiment.__getitem__(self, normalize(k))