本文整理汇总了Python中dictionary.Dictionary.read_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.read_from_file方法的具体用法?Python Dictionary.read_from_file怎么用?Python Dictionary.read_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.read_from_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_options
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import read_from_file [as 别名]
def parse_options(parser):
(options, args) = parser.parse_args()
input_file = args[0]
bound = float(args[1])
scorer = args[2]
iters = int(options.iters)
# stopwords
punct = set([".", "!", "?", ",", "-", ":", "'", "...", "--", ";", "(", ")", "\""])
src_stopwords = set(punct)
if options.src_stop:
src_stopwords |= set(file(options.src_stop).read().rstrip("\n").split("\n"))
tgt_stopwords = set(punct)
if options.tgt_stop:
tgt_stopwords |= set(file(options.tgt_stop).read().rstrip("\n").split("\n"))
# gold dict
gold = Dictionary()
if options.dict:
gold = Dictionary.read_from_file(file(options.dict))
rem = None
if options.remaining:
rem = options.remaining
try:
logging.basicConfig(level=logging.__dict__[options.loglevel], format="%(asctime)s : %(module)s - %(levelname)s - %(message)s")
except KeyError:
print "Not a logging level."
sys.exit(-1)
bound_multiplier=int(options.bound_multiplier)
strdiff = options.strdiff
ngrams = options.ngrams
sets = options.sets
sparse_bound = int(options.sparse_bound)
uniset_min = int(options.uniset_min)
uniset_max = int(options.uniset_max)
return (input_file, bound, scorer, iters, src_stopwords, tgt_stopwords,
gold, rem, bound_multiplier, strdiff, ngrams, sets, sparse_bound,
uniset_min, uniset_max)