當前位置: 首頁>>代碼示例>>Python>>正文


Python task_spec_pb2.TaskSpec方法代碼示例

本文整理匯總了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) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:7,代碼來源:lexicon_test.py

示例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 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:11,代碼來源:lexicon.py

示例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)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:16,代碼來源:lexicon_builder_test.py

示例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)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:12,代碼來源:text_formats_test.py

示例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)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:13,代碼來源:parser_trainer.py

示例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 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:12,代碼來源:lexicon.py

示例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)) 
開發者ID:coderSkyChen,項目名稱:Action_Recognition_Zoo,代碼行數:12,代碼來源:lexicon_builder_test.py

示例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)) 
開發者ID:coderSkyChen,項目名稱:Action_Recognition_Zoo,代碼行數:12,代碼來源:text_formats_test.py

示例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)) 
開發者ID:coderSkyChen,項目名稱:Action_Recognition_Zoo,代碼行數:13,代碼來源:parser_trainer.py

示例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 
開發者ID:coderSkyChen,項目名稱:Action_Recognition_Zoo,代碼行數:13,代碼來源:parser_eval.py


注:本文中的syntaxnet.task_spec_pb2.TaskSpec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。