Skip to content

thomas-marquis/nlp-tools-py-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nlp-tools-py-lib

python simple nlp library

installation

pip install nlp-tools-py-lib

usage

# 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

- ...