Rule-based symbolic English parsing and reasoning engine
Project description
EnglishAI
EnglishAI is a symbolic English parser and reasoning engine written in Python.
Instead of using statistical prediction, EnglishAI tries to represent language using explicit symbolic structures and grammar rules.
The project is experimental and under active development.
Code Example for Demonstration
from englishai import code, decode, answer
s = "my mother's mother's daughter was mary"
eq = code(s)
print(f"EQUATION: {eq}\nSENTENCE: {s}\nSENTENCE AFTER DECODING EQUATION IN PRESENT TENSE: {decode(eq)}")
print()
# basic question answerer based on context
question_context = [
("who are you", "i am your father. you are a boy."),
("is mary alive", "your father is my father. your mother is my mother. you are mary. i killed my sister"),
("am i alive", "am alive i"), # invalid sentence
("am i alive", "i killed john"),
("who is my mother", "my mother's mother's daughter is mary"),
("is bob alive", "i am your father. my son is bob. i killed my son."),
("who is john", "john is my mother."), # john is a boy name and boys can't be mother
("is john alive", "i kills john's father"), # wrong grammar
("is john alive", "she kills john's father"), # corrected grammar
]
for question, context in question_context:
try:
out = answer(question, context)
except:
out = None
print(f"CONTEXT: {context}")
print(f"QUESTION: {question} ?")
if out is not None:
print(f"ANSWER: {'{'+', '.join(out)+'}' if isinstance(out, list) else out}")
else:
print("ANSWER: the reasoning proves that the context is contradictory / grammar error / incorrect format or spelling error / unsupported sentence or out of vocabulary")
print()
Output of the Code
EQUATION: equal(daughter(mother(mother(i))),mary)
SENTENCE: my mother's mother's daughter was mary
SENTENCE AFTER DECODING EQUATION IN PRESENT TENSE: my mother's mother's daughter is mary
CONTEXT: i am your father. you are a boy.
QUESTION: who are you ?
ANSWER: {i, your son}
CONTEXT: your father is my father. your mother is my mother. you are mary. i killed my sister
QUESTION: is mary alive ?
ANSWER: no
CONTEXT: am alive i
QUESTION: am i alive ?
ANSWER: the reasoning proves that the context is contradictory / grammar error / incorrect format or spelling error / unsupported sentence or out of vocabulary
CONTEXT: i killed john
QUESTION: am i alive ?
ANSWER: yes
CONTEXT: my mother's mother's daughter is mary
QUESTION: who is my mother ?
ANSWER: {your mother, mary, mary's mother's daughter}
CONTEXT: i am your father. my son is bob. i killed my son.
QUESTION: is bob alive ?
ANSWER: no
CONTEXT: john is my mother.
QUESTION: who is john ?
ANSWER: the reasoning proves that the context is contradictory / grammar error / incorrect format or spelling error / unsupported sentence or out of vocabulary
CONTEXT: i kills john's father
QUESTION: is john alive ?
ANSWER: the reasoning proves that the context is contradictory / grammar error / incorrect format or spelling error / unsupported sentence or out of vocabulary
CONTEXT: she kills john's father
QUESTION: is john alive ?
ANSWER: yes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file englishai-0.3.5.tar.gz.
File metadata
- Download URL: englishai-0.3.5.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
086848179f7c2019b77d3fda9819eb06e2cbd87dd1880db65609ffdbef81f4ce
|
|
| MD5 |
94e508bf54e09b175932b1c0d13ecd8f
|
|
| BLAKE2b-256 |
7840c8868d9acfbb0bf750ad74b2df5982f61006463dc2f2d615e3aebbeb5ea1
|
File details
Details for the file englishai-0.3.5-py3-none-any.whl.
File metadata
- Download URL: englishai-0.3.5-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dea2cc398f4e8c8b14e178031ac540a1b87032beb660e71c9cb867006eeb94eb
|
|
| MD5 |
c7b1875cbbb4110ef1767a9305d4ff6b
|
|
| BLAKE2b-256 |
c0757c4c386387355c57363cfa9670792d4fa428c6d85e534a8885f7a566061e
|