Skip to content

jvfe/TextProc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextProc

Toy REST API for basic text processing

This was made as a weekend project to learn FastAPI/Flask and basic NLP.

It's a FastAPI API with CRUD capabilities that can also do some basic text processing.

  • Using SQLAlchemy/Pydantic for DB
  • And simple text processing functions that use NLTK/Gensim.

There's also a flask version (flask.py):

  • Using SQLAlchemy and Flask-Marshmallow for DB
  • Flask-RESTful for the actual REST resources
  • And simple text processing functions that use NLTK.

Create env

conda env create -f environment.yml
import nltk

nltk.download('punkt_tab')
nltk.download('stopwords')
nltk.download('wordnet')

Init db and run api:

uvicorn src.app:app --reload

Usage examples (cURL):

  • Create new user:
curl -X POST http://127.0.0.1:8000/users \
     -H "Content-Type: application/json" \
     -d '{"name":"João","content":"I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness."}'
  • Get user 1's bag-of-words:
curl --header "Content-Type: application/json" --request GET  http://localhost:8000/users/1/getbow
  • Get the word most similar to 'pleasure' in user 1's vocabulary:
curl -X POST http://127.0.0.1:8000/users/1/wordvec \
     -H "Content-Type: application/json" \
     -d '{"word": "pleasure"}'

About

Toy REST API for basic text processing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages