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


Python Configuration.is_terminal_state方法代码示例

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


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

示例1: test_features

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import is_terminal_state [as 别名]
 def test_features(self):
     sen = [DependencyToken(i, '-', '-', '-', '-') for i in range(11)]
     sen[1].head = 5
     sen[2].head = 3
     sen[3].head = 5
     sen[4].head = 5
     sen[5].head = 0
     sen[6].head = 5
     sen[7].head = 8
     sen[8].head = 5
     sen[9].head = 8
     sen[10].head = 5
     conf = Configuration(sen)
     i = 0
     while not conf.is_terminal_state():
         act, l = conf.next_gold_action()
         label = (act + ':' + l) if l else act
         feats = conf.feature_ids()
         if i==8:
             assert feats[-2] == 2
             assert feats[8] == 3
         if i==11:
             assert feats[10] == 6
         conf.do(act, l)
         i+=1
     assert conf.lm[5] == 1
     assert conf.lm2[5] == 3
     assert conf.rm[5] == 10
     assert conf.rm2[5] == 8
开发者ID:frank4120,项目名称:nlp_nn,代码行数:31,代码来源:unit_tests.py

示例2: enumerate

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import is_terminal_state [as 别名]
import os, sys
from utils import *
from configuration import Configuration

writer = codecs.open(os.path.abspath(sys.argv[2]), 'w', encoding='utf-8')
for i, sen in enumerate(read_conll(os.path.abspath(sys.argv[1]))):
    if is_projective([e.head for e in sen[1:]]):
        conf = Configuration(sen)
        while not conf.is_terminal_state():
            act, l = conf.next_gold_action()
            label = (act + ':' + l) if l else act
            wf, pf,lf = conf.features()
            writer.write(' '.join(wf) + ' ' + ' '.join(pf)  + ' ' + ' '.join(lf)+ ' ' + label + '\n')
            conf.do(act, l)
    if (i+1) % 100 == 0: sys.stdout.write(str(i+1) + '...')
writer.close()
print('Done!')
开发者ID:frank4120,项目名称:nlp_nn,代码行数:19,代码来源:gen.py


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