-
Notifications
You must be signed in to change notification settings - Fork 0
/
17 3 24.pl
130 lines (96 loc) · 4 KB
/
17 3 24.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
% 17 3 24
% 16 so far
% "Time Travel","People 1.txt",0,algorithms,"2. The aliens have different animals they have evolved from"
% The following are theories.
ancestor(different).
medicine(different).
culture(different).
pedagogy(same).
meditation(same).
computers(same).
simulation(same).
immortality(same).
% ["Short Arguments","Gridline 2.txt",0,algorithms,"3. I noted the height of the meniscus. I measured the meniscuses. I read the value for the bottom of the meniscus. I read the value for the top of the meniscus. I used the correct value."]
concave(bottom). % u
convex(top). % ^
% ["Creating and Helping Pedagogues","CREATE AND HELP PEDAGOGUES by Lucian Green Pedagogy Helper - Write on Breasoning - Computer Science 3 of 4.txt",0,algorithms," 45. I plugged Simulated Intelligence (SI) into people."]
% br with pos
% ?- new_t2b("Mara wrote the pear.",B,XYZ),length(B,L),numbers(L,1,[],N),findall([B1,XYZ1],(member(N1,N),get_item_n(B,N1,B1),get_item_n(XYZ,N1,XYZ1)),List),writeln(List).
% [[person,[50,30,180]],[square,[1,1,0]],[pen,[15,0.5,0.5]],[square,[1,1,0]],[down,[1,1,0]],[square,[1,1,0]],[pear,[5,5,10]],[block,[1,1,1]]]
:-include('../listprologinterpreter/listprolog.pl').
new_t2b(S,B,XYZ) :- downcase_atom(S,S1),string_codes(S1,C),phrase(s(B),C),maplist(br,B,XYZ),!.
s(B) --> noun1(B1), space(B2), verb(B3), space(B4), noun1(B5), full_stop(B6), {foldr(append,[B1,[B2],[B3],[B4],B5,[B6]],B)}.
noun1(B) --> determiner(B1), space(B2), noun(B3), {foldr(append,[[B1],[B2],[B3]],B)}.
noun1(B) --> noun(B1), {foldr(append,[[B1]],B)}.
determiner("down") --> "the".
determiner("down") --> "an".
determiner("down") --> "a".
space("square") --> " ".
full_stop("block") --> ".".
noun("pear") --> "pear".
noun("person") --> "mara".
verb("pen") --> "wrote".
verb("mouth") --> "addressed".
br("down", [1,1,0]).
br("square",[1,1,0]).
br("block", [1,1,1]).
br("pear", [5,5,10]).
br("person",[50,30,180]).
br("pen", [15,0.5,0.5]).
br("mouth", [4,0,1]).
% br with sent and alg
% types
% eg type_checker([c1(a,b),c2(a),c3(b,c)],Types).
% Types = [c1(atom, number), c2(atom), c3(number, string)].
type_checker([],[]).
type_checker([C1|C],[T1|T]) :-
functor(C1,C2,Ar),
(Ar=1->
(arg(1,C1,A1),
type(A1,T2),
type(C2,T2),
functor(T1,C2,Ar),arg(1,T1,T2));
(Ar=2,
arg(1,C1,A1),arg(2,C1,A2),
type(A1,T2),type(A2,T3),
type(C2,T2,T3),
functor(T1,C2,Ar),arg(1,T1,T2),arg(2,T1,T3))),
type_checker(C,T).
type(a,atom).
type(b,number).
type(c,string).
type(c1,atom,number).
type(c2,atom).
type(c3,number,string).
% types with a sentence
% eg types_to_sentence([c1(atom, number), c2(atom), c3(number, string), c4(string, atom)],S).
% S = "I converted the value from an atom to a number, checked it was an atom, then converted it to a string, then back to an atom."
types_to_sentence([],[]).
types_to_sentence(T,S) :-
findall(T1b,(member(T1,T),
((functor(T1,C2,2),arg(1,T1,A1),arg(2,T1,A2))->T1b=[C2,A1,A2];
(functor(T1,C2,1),arg(1,T1,A1),T1b=[C2,A1]))),T2b),
t2s(T2b,[],S1,T2b),foldr(string_concat,S1,S),!.
t2s([],S,S,_).
t2s([T1|T2b],S1,S2,SS) :-
S1=[],
(T1=[_,A1,A2]->(det(A1,DA1),det(A2,DA2),foldr(string_concat,["I converted the value from ",DA1," ",A1," to ",DA2," ",A2,""],S3));
(T1=[_,A1]->(det(A1,DA1),foldr(string_concat,["I checked the value was ",DA1," ",A1,""],S3)))),
append(S1,[S3],S4),
t2s(T2b,S4,S2,SS).
t2s([T1],S1,S2,SS) :-
not(S1=[]),
(T1=[_,_A1,A2]->(det(A2,DA2),findall(X,member([_,X,_],SS),X1),(member(A2,X1)->W="back";W=""),foldr(string_concat,[", then ",W," to ",DA2," ",A2,"."],S3));
(T1=[_,A1]->(det(A1,DA1),findall(X,member([_,X],SS),X1),(member(A1,X1)->W=" again";W=""),foldr(string_concat,[", then checked it was ",DA1," ",A1,W,"."],S3)))),
append(S1,[S3],S4),
t2s([],S4,S2,SS).
t2s([T1|T2b],S1,S2,SS) :-
not(S1=[]),
(T1=[_,_A1,A2]->(det(A2,DA2),foldr(string_concat,[", then converted it to ",DA2," ",A2,""],S3));
(T1=[_,A1]->(det(A1,DA1),foldr(string_concat,[", checked it was ",DA1," ",A1,""],S3)))),
append(S1,[S3],S4),
t2s(T2b,S4,S2,SS).
det(atom,an).
det(number,a).
det(string,a).
% 68 in total