Skip to content

Commit ed66f5e

Browse files
authored
Remove dependency on textblob.translate
TextBlob.translate() and TextBlob.detect_language, and textblob.translate are removed in TextBlob 0.18.0 (see https://textblob.readthedocs.io/en/dev/changelog.html)
1 parent 07b0651 commit ed66f5e

File tree

1 file changed

+1
-33
lines changed

1 file changed

+1
-33
lines changed

textblob_de/blob.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
from textblob.blob import _initialize_models
4343
from textblob.decorators import cached_property, requires_nltk_corpus
44-
from textblob.translate import Translator
4544
from textblob.utils import lowerstrip
4645

4746
from textblob_de.base import BaseBlob as _BaseBlob
@@ -63,13 +62,11 @@ class Word(unicode):
6362

6463
"""A simple word representation.
6564
66-
Includes methods for inflection, translation, and WordNet
65+
Includes methods for inflection and WordNet
6766
integration.
6867
6968
"""
7069

71-
translator = Translator()
72-
7370
def __new__(cls, string, pos_tag=None):
7471
"""Return a new instance of the class.
7572
@@ -97,25 +94,6 @@ def pluralize(self):
9794
"""Return the plural version of the word as a string."""
9895
return Word(_pluralize(self.string))
9996

100-
def translate(self, from_lang=None, to="de"):
101-
"""Translate the word to another language using Google's Translate API.
102-
103-
.. versionadded:: 0.5.0 (``textblob``)
104-
105-
"""
106-
if from_lang is None:
107-
from_lang = self.translator.detect(self.string)
108-
return self.translator.translate(self.string,
109-
from_lang=from_lang, to_lang=to)
110-
111-
def detect_language(self):
112-
"""Detect the word's language using Google's Translate API.
113-
114-
.. versionadded:: 0.5.0 (``textblob``)
115-
116-
"""
117-
return self.translator.detect(self.string)
118-
11997
def spellcheck(self):
12098
"""Return a list of (word, confidence) tuples of spelling corrections.
12199
@@ -497,16 +475,6 @@ def np_counts(self):
497475
counts[phrase] += 1
498476
return counts
499477

500-
def translate(self, from_lang=None, to="de"):
501-
"""Translate the blob to another language."""
502-
if from_lang is None:
503-
from_lang = self.translator.detect(self.string)
504-
return self.__class__(
505-
self.translator.translate(
506-
self.raw,
507-
from_lang=from_lang,
508-
to_lang=to))
509-
510478
def correct(self):
511479
"""Attempt to correct the spelling of a blob.
512480

0 commit comments

Comments
 (0)