-
Notifications
You must be signed in to change notification settings - Fork 962
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
attardi
committed
Jan 24, 2023
1 parent
f0ca16c
commit 8f1b434
Showing
2 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
# ============================================================================= | ||
# Version: 3.0 (July 22, 2020) | ||
# Version: 3.0 (January 24, 2023) | ||
# Author: Giuseppe Attardi ([email protected]), University of Pisa | ||
# | ||
# Contributors: | ||
|
@@ -17,7 +17,7 @@ | |
# Nick Ulven (nulven@github) | ||
# | ||
# ============================================================================= | ||
# Copyright (c) 2009-2020. Giuseppe Attardi ([email protected]). | ||
# Copyright (c) 2009-2023. Giuseppe Attardi ([email protected]). | ||
# ============================================================================= | ||
# This file is part of Tanl. | ||
# | ||
|
@@ -68,7 +68,7 @@ | |
# =========================================================================== | ||
|
||
# Program version | ||
__version__ = '3.0.6' | ||
__version__ = '3.0.7' | ||
|
||
## | ||
# Defined in <siteinfo> | ||
|
@@ -194,6 +194,7 @@ def load_templates(file, output_file=None): | |
""" | ||
Load templates from :param file:. | ||
:param output_file: file where to save templates and modules. | ||
:return: number of templates loaded. | ||
""" | ||
global templateNamespace | ||
global moduleNamespace, modulePrefix | ||
|
@@ -335,14 +336,16 @@ def collect_pages(text): | |
|
||
|
||
def process_dump(input_file, template_file, out_file, file_size, file_compress, | ||
process_count, html_safe): | ||
process_count, html_safe, expand_templates=True): | ||
""" | ||
:param input_file: name of the wikipedia dump file; '-' to read from stdin | ||
:param template_file: optional file with template definitions. | ||
:param out_file: directory where to store extracted data, or '-' for stdout | ||
:param file_size: max size of each extracted file, or None for no max (one file) | ||
:param file_compress: whether to compress files with bzip. | ||
:param process_count: number of extraction processes to spawn. | ||
:html_safe: whether to convert entities in text to HTML. | ||
:param expand_templates: whether to expand templates. | ||
""" | ||
global knownNamespaces | ||
global templateNamespace | ||
|
@@ -528,7 +531,7 @@ def reduce_process(output_queue, output): | |
|
||
def main(): | ||
global acceptedNamespaces | ||
global expand_templates, templateCache | ||
global templateCache | ||
|
||
parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]), | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
|
@@ -555,7 +558,7 @@ def main(): | |
help="accepted namespaces") | ||
groupP.add_argument("--templates", | ||
help="use or create file containing templates") | ||
groupP.add_argument("--no-templates", action="store_false", | ||
groupP.add_argument("--no-templates", action="store_true", | ||
help="Do not expand templates") | ||
groupP.add_argument("--html-safe", default=True, | ||
help="use to produce HTML safe output within <doc>...</doc>") | ||
|
@@ -582,8 +585,6 @@ def main(): | |
Extractor.keepLinks = True | ||
Extractor.to_json = args.json | ||
|
||
expand_templates = args.no_templates | ||
|
||
try: | ||
power = 'kmg'.find(args.bytes[-1].lower()) + 1 | ||
# 0 bytes means put a single article per file. | ||
|
@@ -636,8 +637,7 @@ def main(): | |
return | ||
|
||
process_dump(input_file, args.templates, output_path, file_size, | ||
args.compress, args.processes, args.html_safe) | ||
|
||
args.compress, args.processes, args.html_safe, not args.no_templates) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters