import nltk
import re
from tabulate import tabulate
# Install Open Multilingual Wordnet and Wordnet
# if not already installed.
nltkd = nltk.downloader.Downloader()
for corpus in ['wordnet','omw']:
    if not nltkd.is_installed(corpus):
        nltk.download(corpus)

from nltk.corpus import wordnet as wn

capital = re.compile(r'[A-Z]')
table = list()

for lang in sorted(wn.langs()):
    lemma_names_with_capitals_retained = set()
    from nltk.corpus import wordnet as wn
    for aln_term in list(wn.all_lemma_names(lang=lang)):
        for synset in wn.synsets(aln_term):
            for lemma in synset.lemma_names():
                lemma_names_with_capitals_retained.add(lemma)
    table.append([lang,
        len(filter(capital.match, set(wn.all_lemma_names(lang=lang)))),
        len(filter(capital.match, lemma_names_with_capitals_retained))])

print tabulate(table,
    headers=["Language code",
        "all_lemma_names(): # w/capitals",
        "lemma_name.synset.lemma.lemma_names(): # w/capitals"])
