-
How to get antonyms from language sources other than German or English language.
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I 've tested it with Italian, French an Spanish and found no examples. |
Beta Was this translation helpful? Give feedback.
-
The wordnets from omw 1.* do not have their own relations but piggyback on
PWN. So lemmas in synsets in any language that have antonyms in PWN should
be antonyms, or at least have opposite meanings. You can get a bigger list
if you also expand through similar-to, ...
…On Tue, 8 Mar 2022, 20:19 Christina Lohr, ***@***.***> wrote:
I 've tested it with Italian, French an Spanish and found no examples.
—
Reply to this email directly, view it on GitHub
<#160 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIPZRRQBMOXXZJO4K54UJTU65AVJANCNFSM5QGFTTSA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply, how can I read antonyms from OWN networks? The code fragments I mentioned are not sufficient. |
Beta Was this translation helpful? Give feedback.
-
Hi, Not optimized at all, but this should work. It gets the antonym relations from English and then looks them up in Japanese. 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()
### store ilis for antonym pairs
for synset in en.synsets():
### check synsets (there aren't any)
if syn_anto := synset.get_related('antonym'):
print(synset, syn_anto)
### check senses
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])))
### print for Japanese
for (a1, a2) in antonyms:
s1 = ja.synsets(ili=a1)
s2 = ja.synsets(ili=a2)
print(s1,s2) |
Beta Was this translation helpful? Give feedback.
-
Thanks, it works!
|
Beta Was this translation helpful? Give feedback.
Thanks, it works!
Here is my extension to get antoynms: