Pular para o conteúdo principal

Aula 12: WordNet | Introdução à Linguagem de Programação Python *** com NLTK

 Fonte -> https://youtu.be/0OCq31jQ9E4

A WordNet do Brasil -> http://www.nilc.icmc.usp.br/wordnetbr/

NLTK 


synsets = dada uma palavra acha todos os significados, pode informar a língua e a classe gramatical da palavra (substantivo, verbo, advérbio)

from nltk.corpus import wordnet as wn

wordnet.synset(xxxxxx).definition() = descrição do significado

É possível extrair hipernimia, hiponimia, antonimos e os lemas (diferentes palavras/expressões com o mesmo significado) formando uma REDE LEXICAL. Com isso é possível calcular a distância entre 2 synset dentro do grafo. 

Veja trecho de código abaixo:

texto = 'útil'
print('NOUN:', wordnet.synsets(texto, lang='por', pos=wordnet.NOUN))

texto = 'útil'
print('ADJ:', wordnet.synsets(texto, lang='por', pos=wordnet.ADJ))
print(wordnet.synset('handy.s.01').definition())


texto = 'computador'
for synset in wn.synsets(texto, lang='por', pos=wn.NOUN):
    print('DEF:',synset.name(), synset.definition())
    print('EXA:',synset.name(), synset.examples())    
    print('HYPER:', wn.synset(synset.name()).hypernyms())
    print('HYPON:', wn.synset(synset.name()).hyponyms())
    for lemma in synset.lemmas('por'):
        print('LEMMA:', lemma.name())
    print('\n')
origem = wordnet.synsets(texto, lang='por', pos=wordnet.NOUN)[0]

texto = 'programa'
for synset in wordnet.synsets(texto, lang='por', pos=wordnet.NOUN):
    print('DEF:',synset.name(), synset.definition())
destino = wordnet.synsets(texto, lang='por', pos=wordnet.NOUN)[0]
print('Distância entre computador e programa: ', origem.path_similarity(destino))
pt_br_stemmer(texto)

texto = 'bom'
for synset in wordnet.synsets(texto, lang='por', pos=wordnet.ADJ):
    print('DEF:', synset.name(), synset.definition())
print('ANTO:', wordnet.lemma('good.a.01.good').antonyms())
pt_br_stemmer(texto)

Estudando um pouco mais achei esse outro link com mais recursos e vídeos sobre o NLTK e WordNet

https://pythonprogramming.net/wordnet-nltk-tutorial/


Comentários

  1. Explorei esse recurso em alguns exemplos com Jupyter notebook

    ResponderExcluir
  2. Estava pesquisando o quanto o pacote python NLTK estaria atualizado com a wordnet em Português (openWordnet-PT) e o descobri que a versão atualizada estaria sendo distribuída em breve através de outro pacote python: wn

    https://wn.readthedocs.io/en/latest/
    https://github.com/goodmami/wn

    O pacote dá suporte a outros idiomas além do Português e Inglês.

    ResponderExcluir

Postar um comentário

Sinta-se a vontade para comentar. Críticas construtivas são sempre bem vindas.

Postagens mais visitadas deste blog

truth makers AND truth bearers - Palestra Giancarlo no SBBD

Dando uma googada https://iep.utm.edu/truth/ There are two commonly accepted constraints on truth and falsehood:     Every proposition is true or false.         [Law of the Excluded Middle.]     No proposition is both true and false.         [Law of Non-contradiction.] What is the difference between a truth-maker and a truth bearer? Truth-bearers are either true or false; truth-makers are not since, not being representations, they cannot be said to be true, nor can they be said to be false . That's a second difference. Truth-bearers are 'bipolar,' either true or false; truth-makers are 'unipolar': all of them obtain. What are considered truth bearers?   A variety of truth bearers are considered – statements, beliefs, claims, assumptions, hypotheses, propositions, sentences, and utterances . When I speak of a fact . . . I mean the kind of thing that makes a proposition true or false. (Russell, 1972, p. 36.) “Truthmaker theories” hold that in order for any truthbe

DGL-KE : Deep Graph Library (DGL)

Fonte: https://towardsdatascience.com/introduction-to-knowledge-graph-embedding-with-dgl-ke-77ace6fb60ef Amazon recently launched DGL-KE, a software package that simplifies this process with simple command-line scripts. With DGL-KE , users can generate embeddings for very large graphs 2–5x faster than competing techniques. DGL-KE provides users the flexibility to select models used to generate embeddings and optimize performance by configuring hardware, data sampling parameters, and the loss function. To use this package effectively, however, it is important to understand how embeddings work and the optimizations available to compute them. This two-part blog series is designed to provide this information and get you ready to start taking advantage of DGL-KE . Finally, another class of graphs that is especially important for knowledge graphs are multigraphs . These are graphs that can have multiple (directed) edges between the same pair of nodes and can also contain loops. The