Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Initial toxic model implementation, related to #53
Browse files Browse the repository at this point in the history
  • Loading branch information
dveselov committed Feb 28, 2020
1 parent 660b8c0 commit f1d97aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dostoevsky/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

AVAILABLE_FILES: typing.Dict[str, typing.Tuple[str, str]] = {
'cnn-social-network-model': ('models/cnn-social-network-model.tar.xz', 'models/cnn-social-network-model.tar.xz'),
'fasttext-social-network-model': ('models/fasttext-social-network-model.tar.xz', 'models/fasttext-social-network-model.tar.xz')
'fasttext-social-network-model': ('models/fasttext-social-network-model.tar.xz', 'models/fasttext-social-network-model.tar.xz'),
'fasttext-toxic-model': ('models/fasttext-toxic-model.tar.xz', 'models/fasttext-toxic-model.tar.xz'),
}


Expand Down
15 changes: 15 additions & 0 deletions dostoevsky/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def predict(self, sentences: List[str]):
def get_raw_model(self):
raise NotImplementedError


class FastTextSocialNetworkModel(BaseModel):
'''
FastText model trained on RuSentiment dataset.
Expand Down Expand Up @@ -90,3 +91,17 @@ def predict(self, sentences: List[str], k: int = -1) -> List[
scores
)) for labels, scores in Y
]


class FastTextToxicModel(FastTextSocialNetworkModel):
'''
FastText model trained on russian toxic comments dataset.
'''

SENTENCE_LENGTH: Optional[int] = None

MODEL_PATH: str = os.path.join(
DATA_BASE_PATH,
'models/fasttext-toxic-model.bin'
)

0 comments on commit f1d97aa

Please sign in to comment.