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
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")
'''
'''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)
TokenNodeConstituentNodeNerNodeReferenceNodeDecoratorNode
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
NodeSelection and LinkSelection derive from EntitySelection and have the following attributes:
GroupedEntities
