From 68ca30f630e33b5d7a2df3009274a2fda37be74c Mon Sep 17 00:00:00 2001 From: hayashi_mas Date: Thu, 18 Jan 2024 17:09:17 +0900 Subject: [PATCH 1/2] make ubuild subcommand requires system-dict argument (-s) --- python/py_src/sudachipy/command_line.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/py_src/sudachipy/command_line.py b/python/py_src/sudachipy/command_line.py index 99e42564..60efa4bb 100644 --- a/python/py_src/sudachipy/command_line.py +++ b/python/py_src/sudachipy/command_line.py @@ -251,12 +251,14 @@ def main(): # build user-dictionary parser parser_ubd = subparsers.add_parser( 'ubuild', help='see `ubuild -h`', description='Build User Dictionary') - parser_ubd.add_argument('-d', dest='description', default='', metavar='string', required=False, - help='description comment to be embedded on dictionary') parser_ubd.add_argument('-o', dest='out_file', metavar='file', default='user.dic', help='output file (default: user.dic)') - parser_ubd.add_argument('-s', dest='system_dic', metavar='file', required=False, - help='system dictionary path (default: system core dictionary path)') + parser_ubd.add_argument('-d', dest='description', default='', metavar='string', required=False, + help='description comment to be embedded on dictionary') + required_named_ubd = parser_ubd.add_argument_group( + 'required named arguments') + required_named_ubd.add_argument('-s', dest='system_dic', metavar='file', required=True, + help='system dictionary path') parser_ubd.add_argument("in_files", metavar="file", nargs=argparse.ONE_OR_MORE, help='source files with CSV format (one or more)') parser_ubd.set_defaults(handler=_command_user_build, From 3ce1202736b134ee71d426a5fb6890a9f2b60c14 Mon Sep 17 00:00:00 2001 From: hayashi_mas Date: Thu, 18 Jan 2024 17:14:21 +0900 Subject: [PATCH 2/2] update ubuild usage --- python/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/README.md b/python/README.md index 0de7f9ec..f395c233 100644 --- a/python/README.md +++ b/python/README.md @@ -309,18 +309,20 @@ You can build a user dictionary with the subcommand `ubuild`. ```bash $ sudachipy ubuild -h -usage: sudachipy ubuild [-h] [-d string] [-o file] [-s file] file [file ...] +usage: sudachipy ubuild [-h] [-o file] [-d string] -s file file [file ...] Build User Dictionary positional arguments: file source files with CSV format (one or more) -optional arguments: +options: -h, --help show this help message and exit - -d string description comment to be embedded on dictionary -o file output file (default: user.dic) - -s file system dictionary path (default: system core dictionary path) + -d string description comment to be embedded on dictionary + +required named arguments: + -s file system dictionary path ``` About the dictionary file format, please refer to [this document](https://github.com/WorksApplications/Sudachi/blob/develop/docs/user_dict.md) (written in Japanese, English version is not available yet).