forayer.input_output.from_to_open_ea

IO module for OpenEA data.

Functions

create_kg(path, one_or_two, name[, url])

Create a KG object from open ea files given in path.

from_openea(path[, kg_names, url])

Create ERTask object from open ea-style files.

read_attr_triples(path[, delimiter, url, ...])

Read attribute triples from csv into a dictionary.

read_links(path[, delimiter, url, encoding])

Read entity links.

read_rel_triples(path[, delimiter, url, ...])

Read relation triples.

forayer.input_output.from_to_open_ea.create_kg(path: str, one_or_two: str, name: str, url: Optional[str] = None) forayer.knowledge_graph.kg.KG[source]

Create a KG object from open ea files given in path.

pathstr

path to open ea files of dataset pair

one_or_twostr

which KG to create (either “1” or “2”)

namestr

name of KG

urlstr

url to remote archive if the files are remote

KG

knowledge graph object

forayer.input_output.from_to_open_ea.from_openea(path: str, kg_names: Optional[Tuple[str, str]] = None, url: Optional[str] = None) forayer.knowledge_graph.er_task.ERTask[source]

Create ERTask object from open ea-style files.

pathstr

path to openea files of dataset pair for remote files, the root folder in the zip

kg_names: Optional[Tuple[str,str]]

optionally set knowledge graph names explicitly

url: Optional[str]

url to remote archive if the files are remote

ERTask

er_task object

forayer.input_output.from_to_open_ea.read_attr_triples(path: str, delimiter='\t', url: Optional[str] = None, encoding='utf-8') Dict[str, Dict[str, Any]][source]

Read attribute triples from csv into a dictionary.

This functions returns the triples as dictionary, where entity ids are keys and the values are attribute dictionaries, with the attribute name as key.

path: str

Path to the file If remote: path to the file inside the archive

delimiter: str, default = tab

Delimiter of the csv file

url: Optional[str]

Url to remote zip archive where file is

encoding: str, default utf-8

specific encoding to use

ent_attr_dict: Dict[str, Dict[str, Any]]

Entity and attribute dictionary

Read entity links.

path: str

Path to the file If remote: path to the file inside the archive

delimiter: str, default = tab

Delimiter of the csv file

url: Optional[str]

Url to remote zip archive where file is

encoding: str, default utf-8

specific encoding to use

ClusterHelper

ClusterHelper instance containing all links

forayer.input_output.from_to_open_ea.read_rel_triples(path: str, delimiter='\t', url: Optional[str] = None, encoding='utf-8') Dict[str, Dict[str, Any]][source]

Read relation triples.

This functions returns the triples as dictionary. Containing the relations from left to right,i.e. given a triple (s,p,o) the dictionary would be {s: {o: p}}

path: str

Path to the file If remote: path to the file inside the archive

delimiter: str, default = tab

Delimiter of the csv file

url: Optional[str]

Url to remote zip archive where file is

encoding: str, default utf-8

specific encoding to use

rel_dict: Dict[str, Dict[str, Any]]

Dictionary containing relation triples with subjects as key of outer dict