Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. :- dynamic found_data/4.
  2.  
  3. fresh_bnode(Bnode) :-
  4. gensym(bn, Bnode).
  5.  
  6. solve([]).
  7. solve([Goal | Rest]) :-
  8. (
  9. Goal = concept_data(_,_,_,_)
  10. ->
  11. query(Goal)
  12. ;
  13. call(Goal)
  14. ),
  15. solve(Rest).
  16.  
  17. solve2([]).
  18. solve2([Goal | Rest]) :-
  19. (
  20. Goal = concept_data(C,S,P,O)
  21. ->
  22. found_data(C,S,P,O)
  23. ;
  24. call(Goal)
  25. ),
  26. solve2(Rest).
  27.  
  28.  
  29.  
  30. query(concept_data(C, S, P, O)) :-
  31. (
  32. found_data(C, S, P, O)
  33. ->
  34. true
  35. ;
  36. (
  37. query2(concept_data(C, S, P, O), Head),
  38. findall(
  39. _,
  40. (
  41. member(concept_data(C1, S1, P1, O1), Head),
  42. assertz(found_data(C1, S1, P1, O1))
  43. ),
  44. _
  45. )
  46. )
  47. ).
  48.  
  49. query2(concept_data(C, S, P, O), Head) :-
  50. (
  51. (
  52. implication(Head, Body),
  53. member(concept_data(C, S, P, O), Head)
  54. )
  55. ->
  56. solve2(Body)
  57. ).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement