当前位置: 首页>>代码示例>>Python>>正文


Python Datum.features方法代码示例

本文整理汇总了Python中Datum.Datum.features方法的典型用法代码示例。如果您正苦于以下问题:Python Datum.features方法的具体用法?Python Datum.features怎么用?Python Datum.features使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Datum.Datum的用法示例。


在下文中一共展示了Datum.features方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setFeaturesTest

# 需要导入模块: from Datum import Datum [as 别名]
# 或者: from Datum.Datum import features [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
开发者ID:CaglarGonul,项目名称:Natural-Language-Processing,代码行数:37,代码来源:FeatureFactory.py

示例2: setFeaturesTrain

# 需要导入模块: from Datum import Datum [as 别名]
# 或者: from Datum.Datum import features [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
开发者ID:CaglarGonul,项目名称:Natural-Language-Processing,代码行数:23,代码来源:FeatureFactory.py


注:本文中的Datum.Datum.features方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。