[Python] comparing synonyms NLTK [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 29, 2025.

  1. Stack

    Stack Membro Participativo

    I can't come up with a stranger problem, guess you'll help me.

    for p in wn.synsets('change'):<br>
    print(p)


    Getting:

    Synset('change.n.01')
    Synset('change.n.02')
    Synset('change.n.03')
    Synset('change.n.04')
    Synset('change.n.05')
    Synset('change.n.06')
    Synset('change.n.07')
    Synset('change.n.08')
    Synset('change.n.09')
    Synset('variety.n.06')
    Synset('change.v.01')
    Synset('change.v.02')
    Synset('change.v.03')
    Synset('switch.v.03')
    Synset('change.v.05')
    Synset('change.v.06')
    Synset('exchange.v.01')
    Synset('transfer.v.06')
    Synset('deepen.v.04')
    Synset('change.v.10')


    For example I have an a string:

    a = 'transfer'


    I'd like to be able to identify all kinds of synonyms of word 'change' and know f.e. 'transfer' is the one of them. How can I ask my program: "Is 'transfer' is one of the synonyms of 'change'?"

    Continue reading...

Compartilhe esta Página