Sentiment Analysis

Sentiment Analysis related modeling class

class pororo.tasks.sentiment_analysis.PororoSentimentFactory(task: str, lang: str, model: Optional[str])[source]

Bases: pororo.tasks.utils.base.PororoFactoryBase

Classification based sentiment analysis using Review Corpus

Korean (brainbert.base.ko.shopping)

Korean (brainbert.base.ko.nsmc)

Japanese (jaberta.base.ja.sentiment)

  • data: Internal data

  • metric: Accuracy (96.29)

Examples

>>> sa = Pororo(task="sentiment", model="brainbert.base.ko.nsmc", lang="ko")
>>> sa("배송이 버트 학습시키는 것 만큼 느리네요")
'Negative'
>>> sa("배송이 경량화되었는지 빠르네요")
'Positive'
>>> sa = Pororo(task="sentiment", lang="ja")
>>> sa("日が暑くもイライラか。")  # 날이 더워서 너무 짜증나요.
'Negative'
>>> sa('日が良く散歩に行きたいです。')  # 날이 좋아서 산책을 가고 싶어요.
'Positive'
>>> sa = Pororo(task="sentiment", model="brainbert.base.ko.shopping", lang="ko")
>>> sa("꽤 맘에 들었어요. 겉에서 봤을땐 허름?했는데 맛도 있고, 괜찮아요")
'Positive'
>>> sa("예약하고 가세요 대기줄이 깁니다 훠궈는 하이디라오가 비싼만큼 만족도가 제일 높아요")
'Negative'
>>> sa("이걸 산 내가 레전드", show_probs=True)
{'negative': 0.7525266408920288, 'positive': 0.2474733293056488}
static get_available_langs()[source]
static get_available_models()[source]
load(device: str)[source]

Load user-selected task-specific model

Parameters

device (str) – device information

Returns

User-selected task-specific model

Return type

object

class pororo.tasks.sentiment_analysis.PororoBertSentiment(model, config)[source]

Bases: pororo.tasks.utils.base.PororoSimpleBase

predict(sent: str, **kwargs)str[source]

Conduct sentiment analysis

Parameters
  • sent – (str) sentence to be sentiment analyzed

  • show_probs – (bool) whether to show probability score

Returns

predicted sentence label - negative or positive

Return type

str