'Reads a custom tab file containing mappings of lemmas in the given
language to Princeton WordNet 3.0 synset offsets, allowing NLTK\'s
WordNet functions to then be used with that language.
See the "Tab files" section at http://compling.hss.ntu.edu.sg/omw/ for
documentation on the Multilingual WordNet tab file format.
:param tab_file: Tab file as a file or file-like object
:type  lang str
:param lang ISO 639-3 code of the language of the tab file'

def custom_lemmas(self, tab_file, lang):

    if (len(lang) != 3):
        raise ValueError(u'lang    should    be    a    (3    character)    ISO    639-3    code')
    self._lang_data[lang] = [defaultdict(list), defaultdict(list)]
    for l in tab_file.readlines():
        if isinstance(l, bytes):
            l = l.decode(u'utf-8')
        l = l.replace(u'\n', u'')
        l = l.replace(u'    ', u'_')
        if (l[0] != u'#'):
            word = l.split(u' DCTB ')
            self._lang_data[lang][0][word[0]].append(word[2])
            self._lang_data[lang][1][word[2].lower()].append(word[0])
