Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

translate text using spacy [closed]

Tags:

nltk

spacy

Is it possible to use spacy to translate this sentence into some other language, for e.g. french?

import spacy
nlp = spacy.load('en')
doc = nlp(u'This is a sentence.')

If spacy is not the right tool for this, then which (Free and open source) python library can translate text?

like image 260
shantanuo Avatar asked Jul 12 '18 17:07

shantanuo


People also ask

What does NLP () do in spaCy?

When you call nlp on a text, spaCy first tokenizes the text to produce a Doc object. The Doc is then processed in several different steps – this is also referred to as the processing pipeline. The pipeline used by the trained pipelines typically include a tagger, a lemmatizer, a parser and an entity recognizer.

Which is better NLTK or spaCy?

While NLTK provides access to many algorithms to get something done, spaCy provides the best way to do it. It provides the fastest and most accurate syntactic analysis of any NLP library released to date. It also offers access to larger word vectors that are easier to customize.

Is spaCy open-source?

spaCy is a free, open-source Python library that provides advanced capabilities to conduct natural language processing (NLP) on large volumes of text at high speed.


2 Answers

The comment to your question is correct. You cannot use spaCy to translate text. A good open-source solution could be this library. Sample code:

from translate import Translator
translator = Translator(from_lang='el', to_lang='en')
translation = translator.translate("Ο όμορφος άντρας")
'''

You can the use spacy to perform comon NLP tasks, such as tokenization and
lemmatization in your desired language.

'''
import spacy
nlp = spacy.load('en')
doc = nlp(translation)
for token in doc:
    print(token, token.lemma_)

Output:

The the

handsome handsome

man man

Hope it helps!

like image 129
gdaras Avatar answered Oct 05 '22 04:10

gdaras


Spacy is not for translation. Spacy is for NER(Named Entity Recognition). you can use the python library called translate. You can find a sample project here

like image 33
Darkknight Avatar answered Oct 05 '22 03:10

Darkknight