本文整理匯總了Python中dragnn.python.sentence_io.FormatSentenceReader方法的典型用法代碼示例。如果您正苦於以下問題:Python sentence_io.FormatSentenceReader方法的具體用法?Python sentence_io.FormatSentenceReader怎麽用?Python sentence_io.FormatSentenceReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dragnn.python.sentence_io
的用法示例。
在下文中一共展示了sentence_io.FormatSentenceReader方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_segmenter_corpus
# 需要導入模塊: from dragnn.python import sentence_io [as 別名]
# 或者: from dragnn.python.sentence_io import FormatSentenceReader [as 別名]
def get_segmenter_corpus(input_data_path, use_text_format):
"""Reads in a character corpus for segmenting."""
# Read in the documents.
tf.logging.info('Reading documents...')
if use_text_format:
char_corpus = sentence_io.FormatSentenceReader(input_data_path,
'untokenized-text').corpus()
else:
input_corpus = sentence_io.ConllSentenceReader(input_data_path).corpus()
with tf.Session(graph=tf.Graph()) as tmp_session:
char_input = gen_parser_ops.char_token_generator(input_corpus)
char_corpus = tmp_session.run(char_input)
check.Eq(len(input_corpus), len(char_corpus))
return char_corpus