/Janex-Python

A free open-source framework which can be used to build interactive AIs.

Primary LanguagePythonOtherNOASSERTION

Janex

Janex-Python is a library which can be used to create Natural Language Processing-based programs and other forms of Artificial Intelligence.

It is part of the Janex eco-system which is designed for developers to use in their own projects for free, licensed under the Free Lily License.

As of update 0.0.80, the entire infrastructure of how this code works has been modified intensely.

How to use

First, install Janex using pip.

python3 -m pip install Janex

Next, import it into your code

from Janex import *

Intent classifier

To use the pre-built intent classifier included with the package, you need to create an instance of it and then set the intents, vectors and dimensions.

from janex.intentclassifier import *

Classifier = IntentClassifier()

Classifier.set_intentsfp("intents.json")
Classifier.set_vectorsfp("vectors.json")
Classifier.set_dimensions(300)

Classifier.train_vectors()

You can then determine the class of which a certain variable belongs in using the Classifier.claffy() function.

Input = input("You: ")

classification = Classifier.classify(Input)

response = random.choice(classification["responses"])

print(response)

Data experimentation with vectors

If you would like to tokenize, stem or otherwise preprocess data, the Janex library comes with some pre-made tools.

To tokenize:

from Janex.word_manipulation import *

string = "Hello. My name is Brendon."

tokens = tokenize(string)

print(tokens)

To vectorize:

from Janex.vectortoolkit import *

input_string = "Hello, my name is Sheila."

vectors = string_vectorize(input_string)

vectors = reshape_array_dimensions(vectors, 300) # To reshape the vector array

secondstring = "Hello, my name is Robert."

second_vectors = string_vectorize(secondstring)

second_vectors = reshape_array_dimensions(second_vectors, 300)

similarity = calculate_cosine_similarity(vectors, second_vectors)

print(similarity)