-
Notifications
You must be signed in to change notification settings - Fork 3
/
4-VSpaceTest.metta
executable file
·52 lines (35 loc) · 1.64 KB
/
4-VSpaceTest.metta
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
!(extend-py! metta_learner)
!(let $space (new-gpt-space)
(add-atom &self (= (my-nspace) $space)))
!(add-atom (my-nspace) (The user name is William))
!(add-atom (my-nspace) (William is 26 years old))
!(add-atom (my-nspace) (William has 2 brothers))
!(add-atom (my-nspace) (Brothers names are Mike and Nick))
!(add-atom (my-nspace) (Nick is 3 years older than William))
!(add-atom (my-nspace) (Mike is 5 years younger than Nick))
; !(match (my-nspace) (What is the user name $x) $x)
; !(match (my-nspace) (How old $x is William) $x)
; !(match (my-nspace) (How old ($x) is Mike) $x)
; !(match (my-nspace) (What $x is father name) $x)
; !(match (my-nspace) (What $x is Mike age) $x)
; (match (my-nspace) (What are the names $x of William brothers?) $x)
! (match (my-nspace) (What are the names $x of William brothers?)
(let $query (How old $z is $x ?)
(match (my-nspace) $query ($x is $z years old))))
; It is a sort of negative example: intents would better work as a function,
; because the variable name is not in the pattern
!(let $space (new-gpt-intent-space)
(add-atom &self (= (my-ispace) $space)))
!(add-atom (my-ispace) (lunch-ordering))
!(add-atom (my-ispace) (hobby))
!(add-atom (my-ispace) (user))
; !(match (my-ispace) (I like to play tennis) $topic)
; !(match (my-ispace) (I am a little bit hungry) $topic)
; !(match (my-ispace) (What is my name, $x?) $topic)
(= (space-by-intent user) my-nspace)
(= (dispatch $query $v)
(let $space (space-by-intent (match (my-ispace) $query $topic))
(match ($space) $query $v)))
; A nested matching with choosing a "space" to use
! (dispatch (What is my name, $x ?) $x)
!(metta_learner::vspace-main)