本文整理汇总了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))