-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
46 lines (33 loc) · 1.43 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
MISSING_CORPUS_MESSAGE = """
Looks like you are missing some required data for this feature.
To download the necessary data, simply run
python -m textblob.download_corpora
or use the NLTK downloader to download the missing data: http://nltk.org/data.html
If this doesn't fix the problem, file an issue at https://github.com/sloria/TextBlob/issues.
"""
class TextBlobError(Exception):
"""A TextBlob-related error."""
pass
TextBlobException = TextBlobError # Backwards compat
class MissingCorpusError(TextBlobError):
"""Exception thrown when a user tries to use a feature that requires a
dataset or model that the user does not have on their system.
"""
def __init__(self, message=MISSING_CORPUS_MESSAGE, *args, **kwargs):
super(MissingCorpusError, self).__init__(message, *args, **kwargs)
MissingCorpusException = MissingCorpusError # Backwards compat
class DeprecationError(TextBlobError):
"""Raised when user uses a deprecated feature."""
pass
class TranslatorError(TextBlobError):
"""Raised when an error occurs during language translation or detection."""
pass
class NotTranslated(TranslatorError):
"""Raised when text is unchanged after translation. This may be due to the language
being unsupported by the translator.
"""
pass
class FormatError(TextBlobError):
"""Raised if a data file with an unsupported format is passed to a classifier."""
pass