Skip to content

antonyms in languages other than German and English #161

Answered by chlor
chlor asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks, it works!
Here is my extension to get antoynms:


import wn
en = wn.Wordnet('omw-en:1.4')
ja = wn.Wordnet('omw-ja:1.4')

### a set of tuples of ili ids of antonyms,
### sorted internally (so we only get one way: id1 < id2)
antonyms = set()
antonyms_txt = set()

### store ilis for antonym pairs
for synset in en.synsets():
    if syn_anto := synset.get_related('antonym'):
        print(synset, syn_anto)
    for sense in synset.senses():
        if sen_anto := sense.get_related('antonym'):
            for anto in sen_anto:
                antonyms.add(tuple(sorted([sense.synset().ili.id, anto.synset().ili.id])))

dict_ant = {}

for (a1, a2) in antonyms:
    s1 = ja.synsets(ili=a1)
   …

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by goodmami
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #160 on March 27, 2022 23:34.