mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-22 22:42:53 +02:00
Fixed Sentiment crash (truncation) (#305)
Added truncation attribute.... and it works!
This commit is contained in:
parent
f3f6c40a49
commit
0d1162efbe
@ -19,7 +19,6 @@ class SentimentPipeline:
|
||||
def __init__(self, conn_string: MongoConnection) -> None:
|
||||
"""Method to connect to StagingDB."""
|
||||
self.connect_string = conn_string
|
||||
self.connect_string.database = "transparenzregister_ner"
|
||||
self.connector = conn.MongoConnector(self.connect_string)
|
||||
self.news_obj = news.MongoNewsService(self.connector)
|
||||
|
||||
@ -47,7 +46,6 @@ class SentimentPipeline:
|
||||
)
|
||||
sentiment_service_func = selected_service.sentiment_transformer
|
||||
|
||||
# sents = selected_service.sentiment_spacy(text)
|
||||
sents = sentiment_service_func(text)
|
||||
sentiment = {"label": sents[0], "score": sents[1]}
|
||||
self.news_obj.collection.update_one(
|
||||
|
@ -69,7 +69,9 @@ class SentimentAnalysisService:
|
||||
"""Method to initialize transformer."""
|
||||
# loading the sentiment model(~ 436MB) for transformer
|
||||
self.sentiment_analyzer = pipeline(
|
||||
"sentiment-analysis", model="oliverguhr/german-sentiment-bert"
|
||||
"sentiment-analysis",
|
||||
model="oliverguhr/german-sentiment-bert",
|
||||
truncation=True,
|
||||
)
|
||||
|
||||
def sentiment_spacy(self, doc: str) -> tuple:
|
||||
|
Loading…
x
Reference in New Issue
Block a user