本文整理汇总了Python中loader.Loader.load_wiki方法的典型用法代码示例。如果您正苦于以下问题:Python Loader.load_wiki方法的具体用法?Python Loader.load_wiki怎么用?Python Loader.load_wiki使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loader.Loader
的用法示例。
在下文中一共展示了Loader.load_wiki方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_parameters
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import load_wiki [as 别名]
def read_parameters(self):
parser = argparse.ArgumentParser(description='')
parser.add_argument('--explain', dest='explain', action="store_true", help='More help')
parser.add_argument('--schema', dest='schema', action="store_true", help='Create schema')
parser.add_argument('--parse', dest='parse', action="store_true", help='Parse data')
# (2)
parser.add_argument('--language', action="store", dest="language", help='Language (acronym)')
parser.add_argument('--load', action="store", dest="load", help='Load wikitionary. Argument is file path')
# (4) Popularity values
parser.add_argument('--popularity', action="store", dest="popularity", help='Compute popularity values')
parser.add_argument('--base', action="store", dest="base_lang", help='Base language')
parser.add_argument('--target', action="store", dest="target_lang", help='Target language')
# (5) Get dataset
parser.add_argument('--word_type', action="store", dest="word_type", help='Word type (noun etc.)')
parser.add_argument('--category', action="store", dest="category", help='Category (eg. Animals)')
parser.add_argument('--threshold', action="store", dest="threshold", help='Popularity threshold')
parser.add_argument('--limit', action="store", dest="limit", help='Number of words returned')
parser.add_argument('--out', action="store", dest="out", help='Output filepath')
parser.add_argument('--exported-file', action="store", dest="exported_file", help='Load exported file')
parser.add_argument('--from-file', action="store", dest="from_file", help='Load text file')
parser.add_argument(
'--third-lang',
action="store_true",
dest="third_lang",
help='Whether a set for a third language should be generated',
)
args = parser.parse_args()
# print args
# Check if language is correct
if args.language and args.language not in self.config['available_languages'].split(','):
print '"%s" does not exist. Available languages: %s' % (args.language, self.config['available_languages'])
# (1) Create schema
elif args.schema:
create()
# (2) Load from wiki
elif args.language and args.load:
l = Loader(args.load, args.language)
l.load_wiki()
# (3)
elif args.parse and args.language:
p = self._get_parser(args.language)
p.run()
# (4)
elif args.popularity and args.base_lang:
po = Popularity(args.base_lang, args.popularity)
po.run()
# (5)
elif all((
args.base_lang,
args.target_lang,
args.word_type,
args.category
)) and not args.exported_file:
m = Maker(
args.base_lang,
args.target_lang,
args.word_type,
args.out,
args.category
)
m.translation()
# (8)
# third language
elif args.base_lang and args.target_lang and args.from_file and args.third_lang:
m = Maker(
args.base_lang,
args.target_lang,
args.word_type,
args.out,
None
)
m.translate_to_third_lang(args.from_file)
# (6)
# from exported text file
elif args.base_lang and args.target_lang and args.exported_file:
print 'From exported text file'
# load and translate exported json data
m = Maker(
args.base_lang,
args.target_lang,
args.word_type,
args.out,
#.........这里部分代码省略.........