spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Additional Language Support

Open aikinci opened this issue 11 years ago • 36 comments

How can I add another language?

aikinci avatar Jan 29 '15 12:01 aikinci

Same question here: where one should begin in order to add support for other languages? Would be glad to lend a hand...

chasseurmic avatar Feb 01 '15 22:02 chasseurmic

+1. I would gladly lend a hand.

scari avatar Feb 14 '15 17:02 scari

Thanks everyone. I'll say a bit more about what's blocking this.

The lexemes.bin data file has been constructed in a way that depends on various intermediate data files --- for instance, I processed an unannotated corpus into a list of word counts, and then smoothed the counts with another script, and then consumed the smoothed probabilities with the current quick-and-dirty make_lexicon.py script, which isn't even in this repository yet. I also need to set up a program to generate Brown clusters, and configure word2vec to generate word vectors.

Finally, I need to document the process, and document the tokenizer file formats, so that I can describe what you'll actually need to do to add new languages.

Instead of doing these things, I've mostly been doing bug-fixes, improving the API docs, and trying to improve my deployment process, which at the moment feels very error-prone.

I'll say a little bit about what will be required to add new languages.

  1. Select an unannotated corpus. This will probably be Wikipedia --- it's a nice way to streamline things across languages. Another nice solution would be to run a language identification program over Common Crawl dumps, so that we can get text from wider genres.
  2. Select an annotated corpus. This will define the tokenization standards that we have to target. I'll be licensing the data, so you probably won't have direct access to it --- I'll have to do the actual training. It will probably be nice to give you a web API, so you can run things. If the API you call is emailing me "hey, train this model", well...That sucks.
  3. Define tokenization rules. This is mostly a list of prefix tokenization, a list of suffix tokenization, and a list of special-cases, which are exact-matched. The "How It Works" page says a little bit more about this, but not enough.
  4. Write a lemmatizer and morphological analyser. If there's a WordNet for the language you're targeting, and it's any good, I would prefer to lemmatize to WordNet sense-keys. The BabelNet project is probably the useful way to go about this.

Having written all this, I'm thinking it might be nice to inter-operate closely with Gensim on this. Gensim will give us the word2vec implementation, and would be a good way to handle the boot-strapping problem: if getting spaCy to work on a new language initially depends on processing a bunch of unannotated data with spaCy, then things are awkward.

I'll think more about this, and probably reach out to Radim about it.

honnibal avatar Feb 14 '15 17:02 honnibal

When I was still using redshift, I used word2vec and gensim to generate word cluster with window_size=2. It was fast, but wasn't quite happy with the result until I found Percy Liang's word clustering tool. Took days to generate since I have large corpus.

geovedi avatar May 07 '15 23:05 geovedi

If you need, I've a lot of resources for Portuguese (word2vec, Stanford NE Extractor, ConLL Floresta Sintática, POS Tagger (trigram, bigram, n-gram)...) that I've trained for my project.

brunoalano avatar Aug 20 '15 14:08 brunoalano

@brunoalano thanks but actually I am interested in Turkish for the beginning.

aikinci avatar Aug 20 '15 15:08 aikinci

Working on docs for this here: http://spacy.io/tutorials/add-a-language/

honnibal avatar Sep 15 '15 06:09 honnibal

+1 Ideally we could develop the concept of explicit partial support of a new language. For example, tokenisation really works already for most languages.

bittlingmayer avatar Sep 19 '15 10:09 bittlingmayer

I would be very interested in spaCy support for German, especially official support. Thanks for the documentation on adding languages!

dpk avatar Sep 20 '15 18:09 dpk

See Issue #124

honnibal avatar Oct 03 '15 03:10 honnibal

Select an unannotated corpus. This will probably be Wikipedia --- it's a nice way to streamline things across languages. Another nice solution would be to run a language identification program over Common Crawl dumps, so that we can get text from wider genres.

Perhaps the corpora from http://corporafromtheweb.org/ are useful here. They're large, come in several different languages (Dutch, English, French, German, Spanish, Swedish), and are tokenized pretty well. They're also POS-tagged and lemmatized, but I don't know whether that's needed here.

evanmiltenburg avatar Jan 11 '16 13:01 evanmiltenburg

I'm pleased to say that there's now excellent support for German, thanks to the great work from our first NLP employee Wolfgang Seeker. We're still finishing up the blog post etc, but the model is uploaded and can be used from spaCy 0.100.7.

import spacy
de_nlp = spacy.load('de')

We're still refactoring and working on better processes for adding more languages. I'm going to close this issue because it's old and most of the information here is now out of date.

Obviously, there's still a lot to do to support more languages. And I think the idea of partial language support is important and overdue. But --- progress :)

honnibal avatar May 05 '16 09:05 honnibal

I'm also glad to help in adding Portuguese tools to spaCy.

By the way, anyone knows if there is corpora to train dependency parsers or just PoS-taggers to Dutch?

davidsbatista avatar May 13 '16 15:05 davidsbatista

Yes there are corpora for that: Lassy-Klein, Lassy-Groot, and SoNaR. Probably the best thing is to contact the TST-centrale. They are undergoing some changes in management, so they might be slow to respond.

For questions about Lassy, you can email Gertjan van Noord.

For questions about SoNaR you can email Nelleke Oostdijk.

I trained a POS-tagger on the NLCOW14 corpus, which was automatically tagged. But if you need something fast, then here is the repository.

If you just need a parser, try Alpino.

evanmiltenburg avatar May 13 '16 15:05 evanmiltenburg

Thanks for your reply! One more questions, does the license associated to those datasets allows to be incorporated into spaCy or use it to process dutch text not within a research context?

davidsbatista avatar May 13 '16 15:05 davidsbatista

I think if you're a researcher yourself, and you don't contribute to SpaCy for money I think it should be OK.

If you're a SpaCy employee it might technically be commercial use and the terms and conditions from the TST-centrale are different: I just checked and the license for Lassy-klein for commercial use costs 2000 euros. Same for SoNar-klein. The larger corpora cost more. Then again, SpaCy is open-source. So you can always try. If it doesn't work, contact Gertjan to see whether he can help you.

Else there's also this free smaller treebank on his website. That should at least get you started. And the people at the university of Groningen would probably be happy to see another parser for Dutch so they can compare Alpino to it :)

Also look around on Maarten van Gompel's GitHub here. He's worked on memory-based POS tagging for Dutch, among other things.

evanmiltenburg avatar May 13 '16 15:05 evanmiltenburg

Dank u wel for all the clarifications!

davidsbatista avatar May 13 '16 16:05 davidsbatista

You're welcome, but I just realized I forgot to mention http://universaldependencies.org/ which also covers Dutch, and seems to overlap with Lassy. Sorry!

evanmiltenburg avatar May 16 '16 14:05 evanmiltenburg

I new here but have been trolling for a while, would be glad to add Bahasa support

kaizenx avatar Jul 18 '16 10:07 kaizenx

@geovedi , were you working on Bahasa?

syllog1sm avatar Jul 18 '16 12:07 syllog1sm