Switch to pyproject.toml
This commit is contained in:
parent
1e04769e9d
commit
80428e1bbf
|
@ -6,48 +6,53 @@ import json
|
|||
import sys
|
||||
import gptc
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="General Purpose Text Classifier", prog="gptc"
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest="subparser_name", required=True)
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="General Purpose Text Classifier", prog="gptc"
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest="subparser_name", required=True)
|
||||
|
||||
compile_parser = subparsers.add_parser("compile", help="compile a raw model")
|
||||
compile_parser.add_argument("model", help="raw model to compile")
|
||||
compile_parser.add_argument("--max-ngram-length", "-n", help="maximum ngram length", type=int, default=1)
|
||||
compile_parser = subparsers.add_parser("compile", help="compile a raw model")
|
||||
compile_parser.add_argument("model", help="raw model to compile")
|
||||
compile_parser.add_argument("--max-ngram-length", "-n", help="maximum ngram length", type=int, default=1)
|
||||
|
||||
classify_parser = subparsers.add_parser("classify", help="classify text")
|
||||
classify_parser.add_argument("model", help="compiled model to use")
|
||||
classify_parser.add_argument("--max-ngram-length", "-n", help="maximum ngram length", type=int, default=1)
|
||||
group = classify_parser.add_mutually_exclusive_group()
|
||||
group.add_argument(
|
||||
"-j",
|
||||
"--json",
|
||||
help="output confidence dict as JSON (default)",
|
||||
action="store_true",
|
||||
)
|
||||
group.add_argument(
|
||||
"-c",
|
||||
"--category",
|
||||
help="output most likely category or `None`",
|
||||
action="store_true",
|
||||
)
|
||||
classify_parser = subparsers.add_parser("classify", help="classify text")
|
||||
classify_parser.add_argument("model", help="compiled model to use")
|
||||
classify_parser.add_argument("--max-ngram-length", "-n", help="maximum ngram length", type=int, default=1)
|
||||
group = classify_parser.add_mutually_exclusive_group()
|
||||
group.add_argument(
|
||||
"-j",
|
||||
"--json",
|
||||
help="output confidence dict as JSON (default)",
|
||||
action="store_true",
|
||||
)
|
||||
group.add_argument(
|
||||
"-c",
|
||||
"--category",
|
||||
help="output most likely category or `None`",
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.model, "r") as f:
|
||||
model = json.load(f)
|
||||
with open(args.model, "r") as f:
|
||||
model = json.load(f)
|
||||
|
||||
if args.subparser_name == "compile":
|
||||
print(json.dumps(gptc.compile(model, args.max_ngram_length)))
|
||||
else:
|
||||
classifier = gptc.Classifier(model, args.max_ngram_length)
|
||||
|
||||
if sys.stdin.isatty():
|
||||
text = input("Text to analyse: ")
|
||||
if args.subparser_name == "compile":
|
||||
print(json.dumps(gptc.compile(model, args.max_ngram_length)))
|
||||
else:
|
||||
text = sys.stdin.read()
|
||||
classifier = gptc.Classifier(model, args.max_ngram_length)
|
||||
|
||||
if args.category:
|
||||
print(classifier.classify(text))
|
||||
else:
|
||||
print(json.dumps(classifier.confidence(text)))
|
||||
if sys.stdin.isatty():
|
||||
text = input("Text to analyse: ")
|
||||
else:
|
||||
text = sys.stdin.read()
|
||||
|
||||
if args.category:
|
||||
print(classifier.classify(text))
|
||||
else:
|
||||
print(json.dumps(classifier.confidence(text)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
29
pyproject.toml
Normal file
29
pyproject.toml
Normal file
|
@ -0,0 +1,29 @@
|
|||
[build-system]
|
||||
requires = ["setuptools>=61.0.0", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "gptc"
|
||||
version = "2.0.0"
|
||||
description = "General-purpose text classifier"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "Samuel Sloniker", email = "sam@kj7rrv.com"}]
|
||||
license = { file = "LICENSE" }
|
||||
classifiers = [
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
dependencies = []
|
||||
requires-python = ">=3.7"
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://git.kj7rrv.com/kj7rrv/gptc"
|
||||
|
||||
[project.scripts]
|
||||
gptc = "gptc.__main__:main"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["gptc"]
|
17
setup.py
17
setup.py
|
@ -1,17 +0,0 @@
|
|||
import setuptools
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
setuptools.setup(
|
||||
name="gptc",
|
||||
version="2.0.0",
|
||||
description="General-purpose text classifier",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
packages=setuptools.find_packages(),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
)
|
Loading…
Reference in New Issue
Block a user