python simple nlp library
pip install nlp-tools-py-lib
# main.py
from nlp_tools.preprocessing import Preprocessing
from nlp_tools.loaders import MdLoader
from nlp_tools.representations import MergedMatrixRepresentation
from nlp_tools.classifiers import ClassificationProcessor, NaiveBayseTfIdfClassifier
TRAIN_PATH = 'demo_training.md'
def build_classifier():
loader = MdLoader(TRAIN_PATH)
processor = Preprocessing(loader)
repres = MergedMatrixRepresentation(processor.data)
classifier = ClassificationProcessor(NaiveBayseTfIdfClassifier(), repres.data)
classifier.train()
def predict(text: str):
message = repres.process_new_data(processor.process_sentence(text))
intent, score = classifier.predict(message)
return intent, score
return predict
training.md
example :
# intents
## my_first_intent_name
### responses
- ...
### example
- ...