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


Python Helper.num_sentences方法代码示例

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


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

示例1: results

# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import num_sentences [as 别名]
####
# The main experiments
#
# Here we do monotone and lattice translation of the first 100 sentences
# in ../data/dev.en. The results (all FSTs created in the process and the 
# BLEU scores) are stored the folders `results-monotone` and `results-lattice`.
# 
# All further experiments can be found in `experiments-auxiliary.py`. It is also
# recommended to run `experiments_dummies.py`.

from Helper import *
from all_tasks import *

if __name__ == "__main__":

	# Monotone translation on 100 sentences
	root = "../results-monotone/"
	print "\n" + "-"*80 + "\nMONOTONE TRANSLATION"
	print "This can take a while. All files will be written to"\
		+ " the folder "+root+"\nThere you can also find the BLEU scores."

	H = Helper("all-monotone", root=root)
	H.num_sentences = 100
	H.blue_scores_fn = root+"monotone-bleu-scores.txt"
	do_tasks(H, tasks=[0,1,2,3,4], exp_type="monotone", bleu=True, draw=False)

开发者ID:maartjeth,项目名称:NLP2,代码行数:27,代码来源:test.py

示例2: FST

# 需要导入模块: import Helper [as 别名]
# 或者: from Helper import num_sentences [as 别名]
		phrase_table_fst = FST("%s-%s" % (self.phrase_table_fst_base, i))

		# Updating osymbols and recompiling is pretty essential: all isymbols
		# of the phrase-table FST should be osymbols of the input FST. This is 
		# easily fixed by  updating the input_fst.osymbols accordingly
		# More info in the Notes section of the README
		input_fst = FST("%s-%s" % (self.input_fst_base, i))
		input_fst.osymbols_fn = phrase_table_fst.isymbols_fn
		input_fst.compile()

		# Generate translation SFT and copy in- and out-symbol files
		phrase_table_fst.sort(how="ilabel").decompile()
		translation = input_fst.compose(phrase_table_fst, "%s-%s" % (translation_fst_base, i))
		translation.copy_symbols()

		if draw: translation.draw()

# Add Helper methods
Helper.generate_translation_fsts = generate_translation_fsts
Helper.generate_best_derivations_fsts = generate_best_derivations_fsts

if __name__ == '__main__':
	root = "../results-monotone/"
	H = Helper(type="all-monotone", root=root)
	H.num_sentences = 2
	H.generate_translation_fsts()
	H.generate_best_derivations_fsts()

	# H = Helper(type="blackdog-monotone")
	# H.generate_translation_fsts(draw=True)
	# H.generate_best_derivations_fsts(draw=True)
开发者ID:maartjeth,项目名称:NLP2,代码行数:33,代码来源:task3.py


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