Q: How can I grab every term in PROLOG, then write it out?
Q: something like : prolog_term(X,Functor,Arg1,Arg2) and prolog_term(X,Functor,Arg1) (I'm only interested in /1 and /2 arities).
I think that I want to know how to search-for-and-grab PROLOG terms, without having to RTFM everything.
[I have used Lisp and C (and assembler) extensively (+30 years), and am diving into the deep end of PROLOG now].
Example:
(1) Read in a JSON factbase, e.g.
{ fb:
[
{ relation: "line", subject: "line6", object: "don't care" },
{ relation: "x1", subject: "line6", object: "160" },
{ relation: "y1", subject: "line6", object: "240" },
{ relation: "x2", subject: "line6", object: "160" },
{ relation: "y2", subject: "line6", object: "360" }
]
}
(the factbase consists of triples (maybe doubles, when object is "don't care"))
(2) Convert to internal PROLOG format, e.g.
line(line6).
x1(line6,160).
y1(line6,240).
x2(line6,160).
y2(line6,360).
(3) Run some PROLOG rules over the factbase.
(4) Write out all (or some) of the resulting facts in JSON format, e.g. something like:
write_out([line, x1, y1, x2, y2, bounding_box_left, bounding_box_top, bounding_box_right, bounding_box_bottom])
(in this example, line/x1/y1/x2/y2 facts were read in, and bounding_box_* facts were generated in step (3)).
[further details available - I'm trying to keep the question short]