本文整理匯總了Python中pattern.text.Sentiment類的典型用法代碼示例。如果您正苦於以下問題:Python Sentiment類的具體用法?Python Sentiment怎麽用?Python Sentiment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Sentiment類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
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: load
def load(self, path=None):
_Sentiment.load(self, path)
# Map "verschrikkelijk" to adverbial "verschrikkelijke" (+1%)
if not path:
for w, pos in dict.items(self):
if "JJ" in pos:
p, s, i = pos["JJ"]
self.annotate(attributive(w), "JJ", p, s, i)
示例3: load
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: load
def load(self):
_Sentiment.load(self)
for w, pos in self.items():
if "JJ" in pos:
# Map "verschrikkelijk" to adverbial "verschrikkelijke" (+1% accuracy)
self.setdefault(attributive(w), {"JJ": pos["JJ"], None: pos["JJ"]})
示例5: load
def load(self, path=None):
_Sentiment.load(self, path)
示例6: get
def get(self, k, *args, **kwargs):
return Sentiment.get(self, normalize(k), *args, **kwargs)
示例7: __getitem__
def __getitem__(self, k):
return Sentiment.__getitem__(self, normalize(k))