1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-22 16:04:18 +00:00
bda-6-steffo/unimore_bda_6/analysis/potts.py
Stefano Pigozzi 4344752cf6
Make some more progress for the night
Many things still do not work properly
2023-02-02 05:01:31 +01:00

36 lines
No EOL
818 B
Python

from ..vendor.potts import Tokenizer
from .vanilla import VanillaSA, VanillaReviewSA, VanillaUniformReviewSA
class PottsSA(VanillaSA):
"""
A sentiment analyzer using Potts' tokenizer.
"""
def __init__(self) -> None:
super().__init__()
def _tokenize_text(self, text: str) -> list[str]:
"""
Convert a text string into a list of tokens, using the language of the model.
"""
tokenizer: Tokenizer = Tokenizer(preserve_case=False)
return list(tokenizer.tokenize(text))
class PottsReviewSA(VanillaReviewSA, PottsSA):
"""
A `PottsSA` to be used with `Review`s.
"""
class PottsUniformReviewSA(VanillaUniformReviewSA, PottsSA):
"""
A `PottsSA` with 5 buckets instead of 2.
"""
__all__ = (
"PottsSA",
"PottsReviewSA",
)