Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
usage=(
'thainlp tag [--sep ""] "
"--keep-whitespace",
dest="keep_whitespace",
action="store_true",
)
parser.add_argument(
"-nw",
"--no-whitespace",
dest="keep_whitespace",
action="store_false",
)
parser.set_defaults(keep_whitespace=True)
args = parser.parse_args(argv)
self.args = args
cli.exit_if_empty(args.text, parser)
result = self.run(
args.text,
engine=args.algorithm,
keep_whitespace=args.keep_whitespace,
)
print(args.separator.join(result) + args.separator)
description=(
"Benchmark for various tasks;\n"
"currently, we have only for word tokenization."
),
usage=(
"thainlp benchmark [task] [task-options]\n\n"
"tasks:\n\n"
"word-tokenization benchmark word tokenization\n\n"
"--"
),
)
parser.add_argument("task", type=str, help="[word-tokenization]")
args = parser.parse_args(argv[2:3])
cli.exit_if_empty(args.task, parser)
task = str.lower(args.task)
task_argv = argv[3:]
if task == "word-tokenization":
WordTokenizationBenchmark(task, task_argv)
"--name",
type=str,
help="corpus's name",
)
parser.add_argument(
"command",
type=str,
default="",
nargs="?",
help="[download|remove]"
)
args = parser.parse_args(argv[2:])
cli.exit_if_empty(args.command, parser)
command = args.command
if hasattr(App, command):
getattr(App, command)(args)
else:
print("No command available: %s" % command)
args = sys.argv[1:]
parser = argparse.ArgumentParser(
"thainlp", usage="thainlp [options]"
)
parser.add_argument(
"command",
type=str,
choices=cli.COMMANDS,
help="text processing action",
)
args = parser.parse_args(sys.argv[1:2])
cli.exit_if_empty(args.command, parser)
if hasattr(cli, args.command):
command = getattr(cli, args.command)
command.App(sys.argv)
else:
print(f"Command not available: {args.command}")
print("Please run with --help for alternatives")
def main(args=None):
"""ThaiNLP command line."""
if args is None:
args = sys.argv[1:]
parser = argparse.ArgumentParser(
"thainlp", usage="thainlp [options]"
)
parser.add_argument(
"command",
type=str,
choices=cli.COMMANDS,
help="text processing action",
)
args = parser.parse_args(sys.argv[1:2])
cli.exit_if_empty(args.command, parser)
if hasattr(cli, args.command):
command = getattr(cli, args.command)
command.App(sys.argv)
else:
print(f"Command not available: {args.command}")
print("Please run with --help for alternatives")