Skip to content

Commit

Permalink
fixing string: built-ins and adding graph:is built-in
Browse files Browse the repository at this point in the history
  • Loading branch information
josd committed Sep 5, 2024
1 parent cfc290b commit 759f7d9
Show file tree
Hide file tree
Showing 42 changed files with 47 additions and 140 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.4
1.4.5
3 changes: 0 additions & 3 deletions cases/ackermann.trig
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# assuming lingua explanations
[] log:explanation [].

# ackermann(x, y)
_:bng_1 log:isImpliedBy _:bng_2.

Expand Down
6 changes: 2 additions & 4 deletions cases/age.trig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ GRAPH _:bng_1 {

GRAPH _:bng_2 {
var:S :birthDay var:B.
[] rdf:value ""; time:localTime var:D.
#[] rdf:value ""; time:localTime var:D.
var:D log:equalTo "2024-08-21T00:00:00.0Z"^^xsd:dateTime.
(var:D var:B) math:difference var:F.
var:F math:greaterThan var:A.
}
Expand All @@ -35,6 +36,3 @@ _:bng_3 log:query _:bng_3.
GRAPH _:bng_3 {
var:S :ageAbove "P80Y"^^xsd:duration.
}

# assuming lingua explanations
[] log:explanation [].
3 changes: 0 additions & 3 deletions cases/edt.trig
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX edt: <http://eulersharp.sourceforge.net/2009/12dtb/test#>

# assuming lingua explanations
[] log:explanation [].

# importing
_:bng_1 log:implies true.

Expand Down
3 changes: 0 additions & 3 deletions cases/fibonacci.trig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# assuming lingua explanations
[] log:explanation [].

# backward rules
_:bng_1 log:isImpliedBy _:bng_2.

Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions cases/owe/age.trig → cases/output-with-explanation/age.trig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PREFIX : <https://eyereasoner.github.io/lingua/cases/age.trig#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX time: <http://www.w3.org/2000/10/swap/time#>
PREFIX math: <http://www.w3.org/2000/10/swap/math#>

:patH :ageAbove "P80Y"^^xsd:duration.
Expand All @@ -15,9 +14,9 @@ _:bng_1 log:explains _:bng_2.

GRAPH _:bng_1 {
:patH :birthDay "1944-08-21"^^xsd:date.
[] rdf:value ""; time:localTime "2024-09-02T15:04:02.842Z"^^xsd:dateTime.
("2024-09-02T15:04:02.842Z"^^xsd:dateTime "1944-08-21"^^xsd:date) math:difference 2525699042.842 .
[] rdf:value 2525699042.842; math:greaterThan "P80Y"^^xsd:duration.
[] rdf:value "2024-08-21T00:00:00.0Z"^^xsd:dateTime; log:equalTo "2024-08-21T00:00:00.0Z"^^xsd:dateTime.
("2024-08-21T00:00:00.0Z"^^xsd:dateTime "1944-08-21"^^xsd:date) math:difference 2524608000.0 .
[] rdf:value 2524608000.0; math:greaterThan "P80Y"^^xsd:duration.
}

GRAPH _:bng_2 {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions cases/owe/edt.trig → cases/output-with-explanation/edt.trig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edt:i100000 a edt:N5000.
# lingua explanation
#

_:node_3_1 log:explains true.
_:node_1_1 log:explains true.
_:bng_1 log:explains _:bng_2.
_:bng_3 log:explains _:bng_4.
_:bng_5 log:explains _:bng_6.
Expand Down Expand Up @@ -5008,9 +5008,9 @@ _:bng_9991 log:explains _:bng_9992.
_:bng_9993 log:explains _:bng_9994.
_:bng_9995 log:explains _:bng_9996.
_:bng_9997 log:explains _:bng_9998.
_:bng_9999 log:explains _:node_6_1.
_:bng_9999 log:explains _:node_4_1.

GRAPH _:node_3_1 {
GRAPH _:node_1_1 {
<https://eyereasoner.github.io/lingua/cases/edt.trig> log:imports <https://eyereasoner.github.io/eye/reasoning/edt/test-facts.ttl>.
<https://eyereasoner.github.io/lingua/cases/edt.trig> log:imports <https://eyereasoner.github.io/eye/reasoning/edt/test-dl.ttl>.
}
Expand Down Expand Up @@ -50011,6 +50011,6 @@ GRAPH _:bng_9999 {
edt:i100000 a edt:N4999.
}

GRAPH _:node_6_1 {
GRAPH _:node_4_1 {
edt:i100000 a edt:N5000.
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions cases/output/term.trig

This file was deleted.

38 changes: 0 additions & 38 deletions cases/owe/term.trig

This file was deleted.

3 changes: 0 additions & 3 deletions cases/peano.trig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# assuming lingua explanations
[] log:explanation [].

# add
_:bng_1 log:isImpliedBy true.

Expand Down
3 changes: 0 additions & 3 deletions cases/pi.trig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX var: <http://www.w3.org/2000/10/swap/var#>
PREFIX : <#>

# assuming lingua explanations
[] log:explanation [].

_:bng_1 log:isImpliedBy _:bng_2.

GRAPH _:bng_1 {
Expand Down
39 changes: 0 additions & 39 deletions cases/term.trig

This file was deleted.

2 changes: 1 addition & 1 deletion cases/test
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ do
echo -en "$(pad "${file}" -24)"
start=$(($(date +%s%N)/1000000))
lingua --genid 8b98b360-9a70-4845-b52c-c675af60ad01 --wcache https://eyereasoner.github.io ../.. https://eyereasoner.github.io/lingua/cases/$file --output output/$file
lingua --genid 8b98b360-9a70-4845-b52c-c675af60ad01 --wcache https://eyereasoner.github.io ../.. --explain https://eyereasoner.github.io/lingua/cases/$file --output owe/$file
lingua --genid 8b98b360-9a70-4845-b52c-c675af60ad01 --wcache https://eyereasoner.github.io ../.. --explain https://eyereasoner.github.io/lingua/cases/$file --output output-with-explanation/$file
end=$(($(date +%s%N)/1000000))
echo -en "${YELLOW}$(pad "`expr $end - $start` msec" 12)${NORMAL} "
if [[ $(git diff **/$file | wc -l) -eq 0 ]]; then
Expand Down
49 changes: 36 additions & 13 deletions lingua.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
:- use_module(library(semweb/turtle)).
:- catch(use_module(library(http/http_open)), _, true).

version_info('lingua v1.4.4').
version_info('lingua v1.4.5').

help_info('Usage: lingua <options>* <data>*

Expand All @@ -45,6 +45,7 @@
:- dynamic(flag/2).
:- dynamic(fpred/1).
:- dynamic(graph/2).
:- dynamic(graphid/1).
:- dynamic(hash_value/2).
:- dynamic(implies/2). % implies(Premise, Conclusion)
:- dynamic(keep_ng/1).
Expand Down Expand Up @@ -75,6 +76,7 @@
:- dynamic('<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>'/2).
:- dynamic('<http://www.w3.org/1999/02/22-rdf-syntax-ns#value>'/2).
:- dynamic('<http://www.w3.org/2000/01/rdf-schema#subClassOf>'/2).
:- dynamic('<http://www.w3.org/2000/10/swap/graph#is>'/2).
:- dynamic('<http://www.w3.org/2000/10/swap/log#callWithCleanup>'/2).
:- dynamic('<http://www.w3.org/2000/10/swap/log#collectAllIn>'/2).
:- dynamic('<http://www.w3.org/2000/10/swap/log#explains>'/2).
Expand Down Expand Up @@ -190,8 +192,8 @@
% process command line arguments
args(Args),

% create named graphs
( quad(_, _, _, G),
% create trig graphs
( graphid(G),
findall(C,
( retract(quad(S, P, O, G)),
C =.. [P, S, O]
Expand Down Expand Up @@ -475,6 +477,10 @@
( current_predicate(Predicate/2)
-> true
; dynamic(Predicate/2)
),
( \+graphid(Graph)
-> assertz(graphid(Graph))
; true
)
)
),
Expand Down Expand Up @@ -727,6 +733,18 @@
djiti_fact(':-'(A, B), ':-'(C, D)) :-
!,
makevars((A, B), (C, D), eta).
djiti_fact('<http://www.w3.org/2000/10/swap/graph#is>'(G, T), graph(G, T)) :-
!,
( \+graphid(G)
-> assertz(graphid(G))
; true
).
djiti_fact('<http://www.w3.org/2000/10/swap/graph#is>'(G, T), graph(G, T)) :-
!,
( \+graphid(G)
-> assertz(graphid(G))
; true
).
djiti_fact('<http://www.w3.org/2000/10/swap/log#dcg>'(_, literal(A, type('<http://www.w3.org/2001/XMLSchema#string>'))), B) :-
!,
read_term_from_atom(A, C, []),
Expand Down Expand Up @@ -771,7 +789,7 @@
),
nb_setval(fdepth, 0),
nb_setval(pdepth, 0),
nb_setval(cdepth, 0), mf(answer(_)),
nb_setval(cdepth, 0),
( answer(B1, B2, B3),
B1 \= '<http://www.w3.org/2000/10/swap/log#explains>',
relabel([B1, B2, B3], [C1, C2, C3]),
Expand Down Expand Up @@ -1367,6 +1385,9 @@
)
).

'<http://www.w3.org/2000/10/swap/graph#is>'(A, B) :-
graph(A, B).

'<http://www.w3.org/2000/10/swap/graph#length>'(A, B) :-
when(
( nonvar(A)
Expand Down Expand Up @@ -1414,9 +1435,6 @@
)
).

'<http://www.w3.org/2000/10/swap/graph#term>'(A, B) :-
graph(A, B).

'<http://www.w3.org/2000/10/swap/graph#union>'(A, B) :-
when(
( nonvar(A)
Expand Down Expand Up @@ -2809,7 +2827,9 @@
),
( preformat(SearchList, SearchList2),
preformat(ReplaceList, ReplaceList2),
replace(SearchList2, ReplaceList2, X, Z),
escape_atom(X, Xe),
replace(SearchList2, ReplaceList2, Xe, Ze),
escape_atom(Z, Ze),
atom_string(Y, Z)
)
).
Expand Down Expand Up @@ -2881,7 +2901,8 @@
( ground([A, B])
),
( getint(B, I),
sub_atom(A, 0, E, 0, _),
escape_atom(A, Ae),
sub_atom(Ae, 0, E, 0, _),
J is E-I+1,
( I < 1
-> G is 0,
Expand All @@ -2890,9 +2911,8 @@
H is J
),
( H < 0
-> D = []
; escape_atom(A, Ae),
escape_atom(D, De),
-> D = ''
; escape_atom(D, De),
sub_atom(Ae, G, H, _, De)
)
)
Expand Down Expand Up @@ -3292,7 +3312,8 @@
!.
replace([Search|SearchRest], [Replace|ReplaceRest], X, Y) :-
atomic_list_concat(['(', Search, ')'], Scap),
scrape(X, Scap, Scrape),
escape_atom(Scape, Scap),
scrape(X, Scape, Scrape),
atom_codes(Replace, RC),
srlist(Scrape, RC, Subst),
atom_codes(X, XC),
Expand Down Expand Up @@ -3513,6 +3534,8 @@
conjify(B, D).
conjify('<http://www.w3.org/2000/10/swap/log#callWithCut>'(true, true), !) :-
!.
conjify('<http://www.w3.org/2000/10/swap/log#callWithCut>'(A, true), (A, !)) :-
!.
conjify(A, A).

contains(X, X) :-
Expand Down

0 comments on commit 759f7d9

Please sign in to comment.