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


Python FeatureExtractor.srl方法代码示例

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


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

示例1: test_single

# 需要导入模块: from feature_extractor import FeatureExtractor [as 别名]
# 或者: from feature_extractor.FeatureExtractor import srl [as 别名]
    def test_single(self):
        for t in self.testdata:
            fe = FeatureExtractor(t, "report")
            fe.ngrams(n=5)
            fe.chunk()
            fe.dependency()
            fe.ne()
            fe.bcv()
            fe.srl()
            logging.debug(pformat(zip(fe.SUF, fe.POS)))
            logging.debug(pformat(fe.features))

            vec = DictVectorizer(sparse=True)
            array_f = vec.fit_transform(fe.features).toarray()
            # logging.debug(pformat(array_f))

        raise Exception
开发者ID:tuxedocat,项目名称:Nyanco,代码行数:19,代码来源:test_feature_extractor.py

示例2: _get_features

# 需要导入模块: from feature_extractor import FeatureExtractor [as 别名]
# 或者: from feature_extractor.FeatureExtractor import srl [as 别名]
 def _get_features(self, v="", v_corpus=None, cls2id=None, domain="src"):
     _flist = []
     _labellist_int = []
     _labellist_str = []
     _labelid = cls2id[v]
     if v_corpus:
         for sid, s in enumerate(v_corpus):
             try:
                 fe = FeatureExtractor(s, verb=v)
                 if "chunk" in self.featuretypes:
                     fe.chunk()
                 if "3gram" in self.featuretypes:
                     fe.ngrams(n=3)
                 if "5gram" in self.featuretypes:
                     fe.ngrams(n=5)
                 if "7gram" in self.featuretypes:
                     fe.ngrams(n=7)
                 if "dep" in self.featuretypes:
                     fe.dependency()
                 if "srl" in self.featuretypes:
                     fe.srl()
                 if "ne" in self.featuretypes:
                     fe.ne()
                 if "errorprob" in self.featuretypes:
                     pass
                 if "topic" in self.featuretypes:
                     pass
                 augf = proc_easyadapt(fe.features, domain=domain)
                 _flist.append(augf)
                 _labellist_int.append(_labelid)
                 _labellist_str.append(v)
             except ValueError:
                 logging.debug(pformat("CaseMaker feature extraction: couldn't find the verb"))
             except:
                 print v
                 raise
     else:
         _flist.append(self.nullfeature)
         _labellist_int.append(_labelid)
         _labellist_str.append(v)
     return _flist, _labellist_str, _labellist_int
开发者ID:tuxedocat,项目名称:Nyanco,代码行数:43,代码来源:classifier.py


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