diff --git a/README.md b/README.md index 45f01fb..2447c2f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # GPTC + General-purpose text classifier in Python GPTC provides both a CLI tool and a Python library. ## CLI Tool + ### Classifying text python -m gptc @@ -23,20 +25,28 @@ category:probability, ...}` to stdout. python -m gptc -c|--compile ## Library + ### `gptc.Classifier(model)` + Create a `Classifier` object using the given *compiled* model (as a dict, not JSON). + #### `Classifier.confidence(text)` + Classify `text`. Returns a dict of the format `{category: probability, category:probability, ...}` + #### `Classifier.classify(text)` + Classify `text`. Returns the category into which the text is placed (as a string), or `None` when it cannot classify the text. + ## `gptc.compile(raw_model)` Compile a raw model (as a list, not JSON) and return the compiled model (as a dict). ## Model format + This section explains the raw model format, which is how you should create and edit models. @@ -55,6 +65,7 @@ in any way these Python objects can be. However, it is recommended to store them in JSON format for compatibility with the command-line tool. ## Example model + An example model, which is designed to distinguish between texts written by Mark Twain and those written by William Shakespeare, is available in `models`. The raw model is in `models/raw.json`; the compiled model is in