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

Connected Papers: Uma abordagem alternativa para revisão da literatura

Durante um projeto de pesquisa podemos encontrar um artigo que nos identificamos em termos de problema de pesquisa e também de solução. Então surge a vontade de saber como essa área de pesquisa se desenvolveu até chegar a esse ponto ou quais desdobramentos ocorreram a partir dessa solução proposta para identificar o estado da arte nesse tema. Podemos seguir duas abordagens:  realizar uma revisão sistemática usando palavras chaves que melhor caracterizam o tema em bibliotecas digitais de referência para encontrar artigos relacionados ou realizar snowballing ancorado nesse artigo que identificamos previamente, explorando os artigos citados (backward) ou os artigos que o citam (forward)  Mas a ferramenta Connected Papers propõe uma abordagem alternativa para essa busca. O problema inicial é dado um artigo de interesse, precisamos encontrar outros artigos relacionados de "certa forma". Find different methods and approaches to the same subject Track down the state of the art rese...

Knowledge Graph Toolkit (KGTK)

https://kgtk.readthedocs.io/en/latest/ KGTK represents KGs using TSV files with 4 columns labeled id, node1, label and node2. The id column is a symbol representing an identifier of an edge, corresponding to the orange circles in the diagram above. node1 represents the source of the edge, node2 represents the destination of the edge, and label represents the relation between node1 and node2. >> Quad do RDF, definir cada tripla como um grafo   KGTK defines knowledge graphs (or more generally any attributed graph or hypergraph ) as a set of nodes and a set of edges between those nodes. KGTK represents everything of meaning via an edge. Edges themselves can be attributed by having edges asserted about them, thus, KGTK can in fact represent arbitrary hypergraphs. KGTK intentionally does not distinguish attributes or qualifiers on nodes and edges from full-fledged edges, tools operating on KGTK graphs can instead interpret edges differently if they so desire. In KGTK, e...

KnOD 2021

Beyond Facts: Online Discourse and Knowledge Graphs A preface to the proceedings of the 1st International Workshop on Knowledge Graphs for Online Discourse Analysis (KnOD 2021, co-located with TheWebConf’21) https://ceur-ws.org/Vol-2877/preface.pdf https://knod2021.wordpress.com/   ABSTRACT Expressing opinions and interacting with others on the Web has led to the production of an abundance of online discourse data, such as claims and viewpoints on controversial topics, their sources and contexts . This data constitutes a valuable source of insights for studies into misinformation spread, bias reinforcement, echo chambers or political agenda setting. While knowledge graphs promise to provide the key to a Web of structured information, they are mainly focused on facts without keeping track of the diversity, connection or temporal evolution of online discourse data. As opposed to facts, claims are inherently more complex. Their interpretation strongly depends on the context and a vari...