Pular para o conteúdo principal

Inferência de arestas com KGTK - issue #392

Eu havia solicitado uma nova funcionalidade no KGTK para gerar arestas para os casos de relação inversa e simétrica mas eles me orientaram a usar a funcionalidade de consulta para gerar esse resultado. 

https://github.com/usc-isi-i2/kgtk/issues/392

Eu havia resolvido da seguinte forma para os dados extraídos do Allegro referente as publicações:

kgtk filter -i lattes-prof2.tsv -p " ; dcterms:isReferencedBy ; " -o lattes-prof2-Refs.tsv
** abrir o arquivo e trocar node1 e node2
sed -i 's/dcterms:isReferencedBy/dcterms:references/g' lattes-prof2-Refs.tsv
kgtk cat -i lattes-prof2.tsv lattes-prof2-Refs.tsv / add-id -o lattes-prof3.tsv

E fiz os testes com a forma que eles me indicaram para avaliar se o resultado é o mesmo

It is possible to do the transformations using kgtk query as follows, I will show an example using Wikidata properties. Because dbpedia properties have colon there is a need to quote the values.

kgtk query -i <file> --graph-cache ... \
--match '(n1)-[:P123]->(n2)'  \
--return 'n2 as node1, "P123_inverse" as label, n1 as node2' \
--order-by 'n2, label'

A similar query can be used to do the symmetric properties.

It is possible to complete the graph with all the inverse and symmetric properties in one command. We need to define edges for the properties to record their inverses, and to record whether they are symmetric. Then a single query can do all of them:

kgtk query -i <file> --as input -I <properties-file> --as properties --graph-cache ... \
--match '\
    properties: (prop)-[:inverse]->(prop_inv) \
    input: (n1)-[l {label: prop}]->(n2)'  \
--return 'n2 as node1, prop_inv as label, n1 as node2' \
--order-by 'n2, label, n1'

The above assumes that the has edges of the form <property, inverse, inverse_property>

Nesse primeiro teste inclui somente a relação {dcterms:isReferencedBy -inverse-> dcterms:references}: 

kgtk query -i lattes-prof2.tsv --as input -i lattes-properties.tsv --as properties --graph-cache lattes-cache.tsv --match 'properties: (prop)-[:inverse]->(prop_inv), input: (n1)-[l {label: prop}]->(n2)' --order-by 'n2, label, n1' --return 'n2 as node1, prop_inv as label, n1 as node2' -o lattes-prof3-inverse.tsv

O número e o padrão das arestas geradas foi o mesmo da minha solução "alternativa".

Alterei o arquivo lattes-properties.tsv para incluir outras relações inversas e também relações simétricas e gerei uma nova versão do hipergrafo com essas inferências também

kgtk query -i lattes-prof2.tsv --as input -i lattes-properties.tsv --as properties --graph-cache lattes-cache.tsv --match 'properties: (prop)-[:inverse]->(prop_inv), input: (n1)-[l {label: prop}]->(n2)' --order-by 'n2, label, n1' --return 'n2 as node1, prop_inv as label, n1 as node2' -o lattes-prof2-inference.tsv

kgtk cat -i lattes-prof2.tsv lattes-prof2-inference.tsv / add-id -o lattes-prof3.tsv

E repeti alguns dos testes anteriores

kgtk graph_statistics --log graph_stat_prof3.log --pagerank --statistics-only --degrees --hits -v -i lattes-prof3.tsv -o lattes-prof3-stat.tsv

kgtk reachable-nodes -i lattes-prof3.tsv --root lattes:6075905438020841 -o lattes-prof3-reach-bfs.tsv --show-properties True --breadth-first True
kgtk reachable-nodes -i lattes-prof3.tsv --root lattes:6075905438020841 -o lattes-prof3-reach-nobfs.tsv --show-properties True --breadth-first False

kgtk reachable-nodes -i lattes-prof3.tsv --root lattes:6075905438020841#author-6075905438020841 -o lattes-author-reach-nobfs.tsv --show-properties True --breadth-first False

Comentários sobre o resultado

It has 1990267 nodes and 5948679 edges. ..... aumentou somente no número de arestas como esperado (era 5.649.736 edges)
degree stats: mean=5.977770 ... aumentou (era 5.677365)
Os top 5 no PageRank e no HITS não mudaram

As publicações, conferências, veículos, etc ... são alcançaveis a partir do respectivo lattes. Os arquivos lattes-prof3-reach-bfs.tsv e lattes-prof3-reach-nobfs.tsv contém as mesmas arestas, o que muda é somente a ordem que foram geradas pq o primeiro é por BFS e o segundo por DFS.

As publicações não são alcançaveis a partir de um autor pq o predicado dc:creator não tem simétrico ou inverso no vocabulário Dublin Core. 

OBS. Na modelagem que usamos hj, o lattes é um documento e o pesquisador/professor é o seu criador

lattes:6075905438020841    rdf:type    foaf:Document    E3545564
lattes:6075905438020841    dc:creator    lattes:6075905438020841#author-6075905438020841    E3545560

Comentários

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 Embedding with Triple Context - Leitura de Abstract

  Jun Shi, Huan Gao, Guilin Qi, and Zhangquan Zhou. 2017. Knowledge Graph Embedding with Triple Context. In Proceedings of the 2017 ACM on Conference on Information and Knowledge Management (CIKM '17). Association for Computing Machinery, New York, NY, USA, 2299–2302. https://doi.org/10.1145/3132847.3133119 ABSTRACT Knowledge graph embedding, which aims to represent entities and relations in vector spaces, has shown outstanding performance on a few knowledge graph completion tasks. Most existing methods are based on the assumption that a knowledge graph is a set of separate triples, ignoring rich graph features, i.e., structural information in the graph. In this paper, we take advantages of structures in knowledge graphs, especially local structures around a triple, which we refer to as triple context. We then propose a Triple-Context-based knowledge Embedding model (TCE). For each triple, two kinds of structure information are considered as its context in the graph; one is the out...

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...