Skip to content

Commit

Permalink
Finished polyglot support
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisMayo committed Dec 30, 2023
1 parent 4165eff commit e0dff6c
Show file tree
Hide file tree
Showing 3 changed files with 723 additions and 1,210 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ docker run --rm \
#### Settings
The following environment variables are honored by objection_engine:
- oe_bypass_sentiment: If on any value other than the empty string, the sentiment analysis is bypassed
- oe_sentiment_model: If "polyglot", polyglot will be used for sentiment analisis, if empty or "hf" it would be a huggingface model
- oe_sentiment_model: If "polyglot", polyglot will be used for sentiment analisis, if empty or "hf" it would be a huggingface model. When using polyglot models remember to do python -m polyglot download TASK:sentiment2
- ~~oe_stats_server~~ (not longer supported as of Objection engine 3.3.0): If present, it will be used as the URL to post statistics to. The server responsible should be similar to https://github.com/LuisMayo/simple-server-counter
- oe_polyglot_models: (docker only) If on polyglot model(s), the data for the model will be downloaded when starting the container.
- OE_DIRECT_H264_ENCODING: If "true" then it will directly encode the videos in H264 with OpenCV, instead of encoding in mp4v and re-encoding later. This is faster than the default, but it requires running on windows or having a self-compiled OpenCV build in your system. If you don't know what any of this means, don't enable it.
Expand Down
4 changes: 1 addition & 3 deletions objection_engine/ace_attorney_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,11 @@ def hf_sentiment(self, text: str):
return self._sentiment_analyzer(text)[0]

def poly_sentiment(self, text: str):
print(text)
poly_text = Text(text)
try:
polarity = poly_text.polarity
except:
except Exception as e:
polarity = 0
print(polarity)
if polarity > 0.35:
return {'label': 'positive', 'score': 1.0}
# If polarity is -1 there isn't enough information to determine if it's negative therefore we introduce randomness
Expand Down
Loading

0 comments on commit e0dff6c

Please sign in to comment.