本文整理汇总了Python中Datum.Datum.previousLabel方法的典型用法代码示例。如果您正苦于以下问题:Python Datum.previousLabel方法的具体用法?Python Datum.previousLabel怎么用?Python Datum.previousLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datum.Datum
的用法示例。
在下文中一共展示了Datum.previousLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setFeaturesTest
# 需要导入模块: from Datum import Datum [as 别名]
# 或者: from Datum.Datum import previousLabel [as 别名]
def setFeaturesTest(self, data):
newData = []
words = []
labels = []
labelIndex = {}
for datum in data:
words.append(datum.word)
if not labelIndex.has_key(datum.label):
labelIndex[datum.label] = len(labels)
labels.append(datum.label)
## This is so that the feature factory code doesn't
## accidentally use the true label info
for i in range(0, len(data)):
datum = data[i]
if i == 0:
previousLabel = "O"
datum.features = self.computeFeatures(words, previousLabel, i)
newDatum = Datum(datum.word, datum.label)
newDatum.features = self.computeFeatures(words, previousLabel, i)
newDatum.previousLabel = previousLabel
newData.append(newDatum)
else:
for previousLabel in labels:
datum.features = self.computeFeatures(words, previousLabel, i)
newDatum = Datum(datum.word, datum.label)
newDatum.features = self.computeFeatures(words, previousLabel, i)
newDatum.previousLabel = previousLabel
newData.append(newDatum)
return newData
示例2: setFeaturesTrain
# 需要导入模块: from Datum import Datum [as 别名]
# 或者: from Datum.Datum import previousLabel [as 别名]
def setFeaturesTrain(self, data):
newData = []
words = []
for datum in data:
words.append(datum.word)
## This is so that the feature factory code doesn't
## accidentally use the true label info
previousLabel = "O"
for i in range(0, len(data)):
datum = data[i]
newDatum = Datum(datum.word, datum.label)
newDatum.features = self.computeFeatures(words, previousLabel, i)
newDatum.previousLabel = previousLabel
newData.append(newDatum)
previousLabel = datum.label
return newData