Cortecx is a Python NLP library facilitating the implementation of common NLP tasks.
Use the package manager pip to install Cortecx.
pip install cortecx
- Numpy
- Psutil
- Python 3.6 +
For Models:
- Keras
- Tensorflow
import cortecx.construction.cxsession as cxsession
from cortecx.construction.materials import Parser
cxsession.Session().start()
parser = Parser()
parser.include('YOUR PARAMS') # See Parser.possible_params
answer = parser('YOUR TEXT')
Cortecx returns the processed text according to your params in easy to read and key JSON format:
Example:
import cortecx.construction.cxsession as cxsession
from cortecx.construction.materials import Parser
cxsession.Session().start()
parser = Parser()
parser.include('chunks') # 'chunks' parameter will extract noun chunks
parser.include('pos') # 'pos' parameter will extract pos tags
answer = parser('Jimmy went to the mall.')
Response:
>>> answer
{'analysis': [{'jimmy': {'chunk': 'B-NP', 'pos': 'NNP'}},
{'went': {'chunk': 'B-VP', 'pos': 'VBD'}},
{'to': {'chunk': 'B-PP', 'pos': 'TO'}},
{'the': {'chunk': 'B-NP', 'pos': 'DT'}},
{'mall': {'chunk': 'I-NP', 'pos': 'NN'}},
{'.': {'chunk': 'O', 'pos': '.'}}]}
Use the HELP class found in
import cortecx.construction.tools as t
print(t.HELP().pos_codes) # codes for the part of speech tags
print(t.HELP().chunk_codes) # codes for the chunk tags
If there are any issues feel free to email me at lleyton.ariton@gmail.com
- Parser raises an error if input text does not end in a period
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Work in Progress
Lleyton Ariton