Skip to content

egerber/OpenKnowledgeGraph

Repository files navigation

Open-Knowledge-Graph

Introduction

OpenKnowledgeGraph is a allows to represent texts as a graphs and allows to work with entities in a structured manner. Among other it has the following features

  • Split up Conjugational Sentences into simple parts
  • Sentence Canonicalization ("Thomas likes to play piano and go skiing" => ["Thomas likes to play piano", "Thomas likes to go skiing"])
  • extract entities from the text and link coreferences (using neuralcoref package)
  • constituency graph (generated from the spacy dependency parse tree)
  • find statistical frequent expressions in the text (e.g. "[NP] shows that [VP])
  • extract knowledge triplets from text
  • save graph to disk and reload
  • search for entities across multiple documents
  • creating new nodes, adding custom properties, and connecting nodes
  • creating pipeline for processing texts

Examples

from openKnowledgeGraph import OpenKnowledgeGryph

sample_text="Thomas likes to go skiing and play the guitar"
g=OpenKnowledgeGraph.from_text(sample_text)

g.find_nodes(Q(type="np"))
'''

'''

g.find_nodes(Q(type="token",pos="noun")
'''

'''

Nodes and Links

The Graph contains two types of entities: Nodes and Links. Nodes allow to store properties about an entity, as well as define custom computed properties. Links connect two Nodes. Both nodes and links have the following attributes:

  • type (e.g. token, dependency, np, vp, ...or anything custom)
  • attributes (key-value dictionary)

Nodes

  • TokenNode
  • ConstituentNode
  • NerNode
  • ReferenceNode
  • DecoratorNode

Links

Query

Queries allow to search for nodes and links using:

  • graph.find_nodes(Q(...)) (short: graph.fn(Q(...))))

  • graph.find_links(Q(...)) (short: graph.fl(Q(...))))

  • filter

  • group_by

  • order_by(sort_func,order='asc')

  • order_by_desc(sort_func)

  • order_by_asc(sort_func)

  • merge(other_selection: EntitySelection)

  • append(element)

  • show_preview()

Q

Q

EntitySelection

NodeSelection and LinkSelection derive from EntitySelection and have the following attributes:

GroupedEntities

GroupedEntities

Operations

ConstituentTransformer

CanonicalizationTransformer

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors