本文整理汇总了Python中syntaxnet.task_spec_pb2.TaskSpec方法的典型用法代码示例。如果您正苦于以下问题:Python task_spec_pb2.TaskSpec方法的具体用法?Python task_spec_pb2.TaskSpec怎么用?Python task_spec_pb2.TaskSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类syntaxnet.task_spec_pb2
的用法示例。
在下文中一共展示了task_spec_pb2.TaskSpec方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCreateLexiconContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def testCreateLexiconContext(self):
expected_context = task_spec_pb2.TaskSpec()
text_format.Parse(_EXPECTED_CONTEXT, expected_context)
self.assertProtoEquals(
lexicon.create_lexicon_context('/tmp'), expected_context)
示例2: create_lexicon_context
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def create_lexicon_context(path):
"""Construct a SyntaxNet TaskContext file for standard lexical resources."""
context = task_spec_pb2.TaskSpec()
for name in [
'word-map', 'tag-map', 'tag-to-category', 'lcword-map', 'category-map',
'char-map', 'char-ngram-map', 'label-map', 'prefix-table', 'suffix-table'
]:
context.input.add(name=name).part.add(file_pattern=os.path.join(path, name))
return context
示例3: WriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def WriteContext(self, corpus_format):
context = task_spec_pb2.TaskSpec()
self.AddParameter('brain_parser_embedding_names', 'words;tags', context)
self.AddParameter('brain_parser_features', 'input.token.word;input.tag',
context)
self.AddInput('documents', self.corpus_file, corpus_format, context)
for name in ('word-map', 'lcword-map', 'tag-map',
'category-map', 'label-map', 'prefix-table',
'suffix-table', 'tag-to-category', 'char-map',
'char-ngram-map'):
self.AddInput(name, os.path.join(FLAGS.test_tmpdir, name), '', context)
logging.info('Writing context to: %s', self.context_file)
with open(self.context_file, 'w') as f:
f.write(str(context))
示例4: WriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def WriteContext(self, corpus_format):
context = task_spec_pb2.TaskSpec()
self.AddInput('documents', self.corpus_file, corpus_format, context)
for name in ('word-map', 'lcword-map', 'tag-map', 'category-map',
'label-map', 'prefix-table', 'suffix-table',
'tag-to-category'):
self.AddInput(name, os.path.join(FLAGS.test_tmpdir, name), '', context)
logging.info('Writing context to: %s', self.context_file)
with open(self.context_file, 'w') as f:
f.write(str(context))
示例5: RewriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def RewriteContext():
context = task_spec_pb2.TaskSpec()
with gfile.FastGFile(FLAGS.task_context, 'rb') as fin:
text_format.Merge(fin.read(), context)
for resource in context.input:
if resource.creator == StageName():
del resource.part[:]
part = resource.part.add()
part.file_pattern = os.path.join(OutputPath(resource.name))
with gfile.FastGFile(OutputPath('context'), 'w') as fout:
fout.write(str(context))
示例6: create_lexicon_context
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def create_lexicon_context(path):
"""Construct a SyntaxNet TaskContext file for standard lexical resources."""
context = task_spec_pb2.TaskSpec()
for name in [
'word-map', 'tag-map', 'tag-to-category', 'lcword-map', 'category-map',
'char-map', 'char-ngram-map', 'label-map', 'prefix-table', 'suffix-table',
'known-word-map'
]:
context.input.add(name=name).part.add(file_pattern=os.path.join(path, name))
return context
示例7: WriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def WriteContext(self, corpus_format):
context = task_spec_pb2.TaskSpec()
self.AddInput('documents', self.corpus_file, corpus_format, context)
for name in ('word-map', 'lcword-map', 'tag-map',
'category-map', 'label-map', 'prefix-table',
'suffix-table', 'tag-to-category', 'char-map'):
self.AddInput(name, os.path.join(FLAGS.test_tmpdir, name), '', context)
logging.info('Writing context to: %s', self.context_file)
with open(self.context_file, 'w') as f:
f.write(str(context))
示例8: WriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def WriteContext(self, corpus_format):
context = task_spec_pb2.TaskSpec()
self.AddInput('documents', self.corpus_file, corpus_format, context)
for name in ('word-map', 'lcword-map', 'tag-map',
'category-map', 'label-map', 'prefix-table',
'suffix-table', 'tag-to-category'):
self.AddInput(name, os.path.join(FLAGS.test_tmpdir, name), '', context)
logging.info('Writing context to: %s', self.context_file)
with open(self.context_file, 'w') as f:
f.write(str(context))
示例9: RewriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def RewriteContext():
context = task_spec_pb2.TaskSpec()
with gfile.FastGFile(FLAGS.task_context) as fin:
text_format.Merge(fin.read(), context)
for resource in context.input:
if resource.creator == StageName():
del resource.part[:]
part = resource.part.add()
part.file_pattern = os.path.join(OutputPath(resource.name))
with gfile.FastGFile(OutputPath('context'), 'w') as fout:
fout.write(str(context))
示例10: RewriteContext
# 需要导入模块: from syntaxnet import task_spec_pb2 [as 别名]
# 或者: from syntaxnet.task_spec_pb2 import TaskSpec [as 别名]
def RewriteContext(task_context):
context = task_spec_pb2.TaskSpec()
with gfile.FastGFile(task_context) as fin:
text_format.Merge(fin.read(), context)
for resource in context.input:
for part in resource.part:
if part.file_pattern != '-':
part.file_pattern = os.path.join(FLAGS.resource_dir, part.file_pattern)
with tempfile.NamedTemporaryFile(delete=False) as fout:
fout.write(str(context))
return fout.name