本文整理匯總了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