ampligraph.datasets.load_from_ntriples(folder_name, file_name, data_home=None, add_reciprocal_rels=False)

Load RDF ntriples

Loads an RDF knowledge graph serialized as ntriples, without building an RDF graph in memory. This function should be preferred over load_from_rdf(), since it does not load the graph into an rdflib model (and it is therefore faster by order of magnitudes). Nevertheless, it requires a ntriples serialization as in the example below:

_:alice <http://xmlns.com/foaf/0.1/knows> _:bob .
_:bob <http://xmlns.com/foaf/0.1/knows> _:alice .


It is recommended to use ampligraph.evaluation.train_test_split_no_unseen() to split custom knowledge graphs into train, validation, and test sets. Using this function will lead to validation, test sets that do not include triples with entities that do not occur in the training set.

  • folder_name (str) – base folder where the file is stored.
  • file_name (str) – file name
  • data_home (str) – The path to the folder that contains the datasets.
  • add_reciprocal_rels (bool) – Flag which specifies whether to add reciprocal relations. For every <s, p, o> in the dataset this creates a corresponding triple with reciprocal relation <o, p_reciprocal, s>. (default: False).

triples – the actual triples of the file.

Return type:

ndarray , shape [n, 3]