from nlp import NLP
from fastapi import FastAPI
from pydantic import BaseModel


class Message(BaseModel):
    text: str


app = FastAPI()
nlp = NLP()


@app.post("/sentiment/")
async def sentiment_analysis(message: Message):
    sentiment = nlp.predict_sentiment(message.text)
    return sentiment


# use uvicorn main:app --reload to run the server
Beispiel #2
0
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 28 02:49:12 2020

@author: erick
"""

from nlp import NLP
import time                

object_nlp = NLP()

begin = time.time()

string = u'Ich bin am 26.12.1993 geboren'
object_nlp.setDoc(string)

object_nlp.docDetails()

#dsobject_nlp.docDetails()

errors = object_nlp.checkSatz(2)

finish = time.time()
#print("%.2fs"% (finish-begin))  


#print(f'Frase: {object_nlp.doc}\n')
for error in errors:
    print(f'Erro: {error["match"]}')
    print(f'Correção: {error["tip"]}\n')
Beispiel #3
0
 def __init__(self, gazetteer, datasetFile, annotatedEntities,
              vocabularyFile):
     self.nlp = NLP()
     self.ner = NER(gazetteer, annotatedEntities)
     self.topicModel = TopicClassification(datasetFile, vocabularyFile)