Open MiloudEloumri opened 1 year ago
Thank you for raising the interest on the library. The library only supports formats for knowledge intake:
You need to convert OWL to one of the following formats after that it is readable using
semantic:nt("path_to_knwledge.nt").
Thank you. I tried .nt file and got the following results. It seems semantic:nt() reads or decodes only the first line in the .nt file? How can I decode the whole .nt file? Thanks.
2> A = semantic:nt("C:\Users\milou\match\apps\seresye\examples\relatives.nt"). {stream,{{iri,<<"N58a3244c06634746a227a2193c85ef69">>}, {iri,<<"http://www.w3.org/1999/02/22-rdf-syntax-ns#first">>}, {iri,<<"http://www.semanticweb.org/miloud/ontologies/2023/4/relatives#sara">>}},
3> B = semantic:typed(A). {stream,#{c => 1.0,k => <<"AGlNLL7cwAE">>, o => {iri,<<"http://www.semanticweb.org/miloud/ontologies/2023/4/relatives#sara">>}, p => {iri,<<"rdf">>,<<"first">>}, s => {iri,<<"N58a3244c06634746a227a2193c85ef69">>}, type => {iri,<<"xsd">>,<<"anyURI">>}},
4>
It returns the datum:stream()
type, which is equivalent of "lazy list".
You can learn more about API here: https://github.com/fogfish/datum/blob/master/src/stream/stream.erl
Easies way to cast it into list
stream:list( semantic:nt() )
However, this is not efficient from memory perspective, you need to learn stream:fold
to make efficient application.
{ok, Sock} = ...
%%
%% open a stream to example dataset
Stream = semantic:nt(filename:join(["imdb.nt"])).
%%
%% upload dataset
stream:foreach(
fun(Fact)-> myapp:append(Sock, Fact) end,
semantic:fold(
stream:map(fun semantic:typed/1, Stream)
)
).
BTW, datum:stream() is Erlang implementation derived from Scheme stream interface http://srfi.schemers.org/srfi-41/srfi-41.html
You might use stream w/o datum library
-record(stream, {
head = undefined :: _,
tail = undefined :: datum:option(fun(() -> _))
}).
Stream is pair of Head the value and Tail the function that return new value
%%
%% returns a newly-allocated list containing stream elements
-spec list(datum:stream()) -> list().
list(?None) ->
[];
list(#stream{} = Stream) ->
[stream:head(Stream) | list(stream:tail(Stream))].
Thank you very much. I created a simple example of using Semantic Web ToolKit for Erlang applications with SERESYE and run it as here. If you have time, please check my simple example and see my use of Semantic Web ToolKit for Erlang applications. Do you have any recommendations or improvements? Thank you.
I am using Semantic Web ToolKit as a deps in match rebar3 release to integrate it with SERESYE. I want to create an Erlang module that uses the Semantic Web ToolKit to process facts from the OWL file, and uses SERESYE to apply rules to these facts. How can I load .owl, .rdf or any other supported file format into the Semantic Web ToolKit? Thank you.