How to change NLTK default wordnet language to zsm?
<p>I'm new to NLTK and I'm doing the Python 3 Text Processing with NLTK 3 Cookbook: Chapter 4. I've done "Using WordNet for tagging" and works fine in default language English. I've download Language Bahasa (zsm) to omw and want to try in Bahasa using other datasets. Using the same approach, how can I change the language default from English to zsm now?</p>

<p>Code that I'm using:</p>

<pre><code>class WordNetTagger(SequentialBackoffTagger):

    def __init__(self, *args, **kwargs):
        SequentialBackoffTagger.__init__(self, *args, **kwargs)

        self.wordnet_tag_map = {
            'n': 'NN',
            's': 'JJ',
            'a': 'JJ',
            'r': 'RB',
            'v': 'VB'
        }

    def choose_tag(self, tokens, index, history):
        word = tokens[index]
        fd = FreqDist()

        for synset in wordnet.synsets(word):
            fd[synset.pos()] += 1

        if not fd: return None
        return self.wordnet_tag_map.get(fd.max())
</code></pre>

<p>Thanks in advance.</p>

<p>After some trial I just figured:</p>

<pre><code>def choose_tag(self, tokens, index, history):
    word = tokens[index]
    fd = FreqDist()

    for synset in wordnet.synsets(word, lang='zsm'):
        fd[synset.pos()] += 1

    if not fd: return None
    return self.wordnet_tag_map.get(fd.max())
</code></pre>

<p>Key is wordnet.synsets(word, lang='zsm') works now for me. And I'm still open for any other suggestion or correction. Thanks.</p>

python nltk