Skip to content

Commit 4f25f4e

Browse files
committed
quant_foreach -> do; quant_check -> check
1 parent 37214f4 commit 4f25f4e

File tree

18 files changed

+120
-111
lines changed

18 files changed

+120
-111
lines changed

doc/manual/knowledge-engineer/creating-a-grammar.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ I don't think I found the ultimate way to represent questions, but what I'd like
4242

4343
and then refine the changing part in a separate rule:
4444

45-
{ rule: do_clause(P1) -> np(E1) tv(P1, E1, E2) np(E2), sense: quant_check($np1, quant_check( $np2, $tv)) }
45+
{ rule: do_clause(P1) -> np(E1) tv(P1, E1, E2) np(E2), sense: check($np1, check( $np2, $tv)) }
4646

4747
The first rule states that these type of questions start with "do" and that they are yes/no questions, which means that their answer is a simple yes or no. The `intent(yes_no)` in the sense of the rule is a kind of tag that is used by the solution to recognize the type of sentence.
4848

@@ -62,7 +62,7 @@ A declarative sentence states something to be the case. The aim of the sentence
6262

6363
Let's start with simple declarative sentences. This one handles sentences like: "all red blocks are mine"
6464

65-
{ rule: declarative(P1) -> np(E1) copula(_) np(E2), sense: assert( own(A, B) :- quant_check($np1, quant_check($np2, equals(A, E2) equals(B, E1)))) }
65+
{ rule: declarative(P1) -> np(E1) copula(_) np(E2), sense: assert( own(A, B) :- check($np1, check($np2, equals(A, E2) equals(B, E1)))) }
6666

6767
A `copula` is a verb like "is" and "are" when it has no meaning of its own in the sentence. In the sense you can see the `assert` relation whose single argument is a rule. When this declarative is executed, the `assert` adds a rule to a rule base (the first rule base known to the system).
6868

@@ -83,11 +83,11 @@ This is how to implement "all red blocks are mine, but the blocks in the box are
8383

8484
{ rule: default_rule(P1) -> np(E1) tv(P1, A, B) np(E2), sense: assert(
8585
$tv :-
86-
quant_check($np, quant_check($np2, equals(A, E1) equals(B, E2) not( -$tv )))) }
86+
check($np, check($np2, equals(A, E1) equals(B, E2) not( -$tv )))) }
8787

8888
{ rule: assertion(P1) -> np(E1) dont(_) tv(P1, A, B) np(E2), sense: assert(
8989
-$tv :-
90-
quant_check($np1, quant_check($np2, equals(A, E1) equals(B, E2))) }
90+
check($np1, check($np2, equals(A, E1) equals(B, E2))) }
9191

9292
These last rules form the default rule and the exception. They are posed in a general way that allows for multiple application. The first says "NP verb NP", which handles clauses like "I like ice" and "you own the table". Note the sense: the head is `$tv`, which is the meaning of the second child in the rule (`tv(P1, A, B)`), and this head reoccurs later on in rule, in the form of `not( -$tv )`. The meaning here is "I own all red blocks except for the ones that I don't own".
9393

@@ -156,7 +156,7 @@ At the moment the `proper_noun_group` is processed, the parser has received top-
156156

157157
Let's have an example:
158158

159-
{ rule: nbar(E1) -> 'daughter' 'of' np(E2), sense: quant_check($np, has_daughter(E2, E1)) }
159+
{ rule: nbar(E1) -> 'daughter' 'of' np(E2), sense: check($np, has_daughter(E2, E1)) }
160160

161161
Here `np(E2)` will be rewritten to the name "Charles Babbage". The parser also sees that E2 is the first argument of the relation `has_daughter(E2, E1)`. And you can tell the system that the first argument of this relation is a person, by adding this line to the file "argument-sort.relation":
162162

@@ -183,7 +183,7 @@ There are transitive verbs (`tv`) and intransitive verbs (`iv`). Transitive verb
183183

184184
Here's a simple rewrite for a transitive verb phrase:
185185

186-
{ rule: vp(P1, E1) -> marry(P1) np(E2), sense: quant_check($np, marry(P1, E1, E2)) }
186+
{ rule: vp(P1, E1) -> marry(P1) np(E2), sense: check($np, marry(P1, E1, E2)) }
187187

188188
The `find` combines the `quant` or `quant`s with the sense of the verb. `find` iterates over all combinations of values for the quants.
189189

@@ -221,13 +221,13 @@ An attributive adjective preceeds a noun phrase. There can be multiple adjective
221221
Phrases like "is taller than" are also adjective, but in a predicative way.
222222

223223
{ rule: relative_clause(E1) -> 'which' copula(C1) adjp(E1) }
224-
{ rule: adjp(E1) -> 'taller' 'than' np(E2), sense: quant_check($np, taller(E1, E2)) }
224+
{ rule: adjp(E1) -> 'taller' 'than' np(E2), sense: check($np, taller(E1, E2)) }
225225

226226
## Prepositional phrases
227227

228228
These phrases denote a relation between two noun phrases. Here's the rule for the preposition "in".
229229

230-
{ rule: pp(E1) -> 'in' np(E2), sense: quant_check($np, contain(_, E2, E1)) }
230+
{ rule: pp(E1) -> 'in' np(E2), sense: check($np, contain(_, E2, E1)) }
231231

232232
## Numbers
233233

doc/manual/knowledge-engineer/function-reference/grammar.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,29 @@ This relation is used by solutions to recognize types of problems.
1313

1414
An intent function has no effect; it always succeeds.
1515

16-
## Quant foreach
16+
## Do
1717

18-
Find all entities specified by a `quant` (minimally), assign each of them in turn to a variable and execute `Scope`.
18+
Finds the entities specified by a `quant`, assign each of them in turn to a variable and execute `Scope`.
1919

20-
Fails as soon as a scope returns no results.
20+
Does not continue to find entities after the quantifier has succeeded.
21+
Fails if the number of entities that pass `Scope` is **less than** the same as specified by the quantifier of `Quant`.
2122

22-
go:quant_foreach(Quant ..., Scope)
23+
go:do(Quant ..., Scope)
2324

2425
* `Quant`: a quant
2526
* `Scope`: a relation set
2627

2728
Check [quantification](quantification.md) for more information.
2829

29-
## Quant check
30+
## Check
3031

31-
Find all entities specified by `Quants`, check if the number of entities that pass `Scope` is the same as specified by the quantifier of `Quant`.
32+
Find all entities specified by `Quant`.
3233

33-
go:quant_check(Quants, Scope)
34+
Fails if the number of entities that pass `Scope` is not the same as specified by the quantifier of `Quant`.
35+
36+
go:check(Quant, Scope)
3437

35-
* `Quants`: one or more quants
38+
* `Quant`: a quant
3639
* `Scope`: a relation set
3740

3841
Check [quantification](quantification.md) for more information.

doc/manual/knowledge-engineer/modules-namespaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ These aliases are called `module aliases`. They are used by NLI-GO to locate rel
5656

5757
Built-in predicates are always prefixed by the system-alias `go`. For example:
5858

59-
go:quant_check($np, dom:has_father(E2, E1))
59+
go:check($np, dom:has_father(E2, E1))
6060

6161

doc/manual/knowledge-engineer/quantification.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ Here is the typical case for the `qp`. Note that the `quantifier` relation is fo
6262

6363
The quant is only useful when combined with a parent relation (typically a verb). You need to specify explicity that the quant is used. If there is more than one quant, the order of the quants can be given. An example:
6464

65-
{ rule: np_comp4(P1) -> np(E1) marry(P1) 'to' np(E2), sense: quant_check($np1, quant_check($np2, marry(P1, E1, E2))) }
65+
{ rule: np_comp4(P1) -> np(E1) marry(P1) 'to' np(E2), sense: check($np1, check($np2, marry(P1, E1, E2))) }
6666

6767
Imagine the sentence: "Did all these men marry two women?". Resolving this question means going through all the men, one-by-one, and for each of them counting the women that were married to them. If one of them married only one woman, the answer is no.
6868

69-
`quant_check` says: apply the quants from the right-hand positions 1 (`$np1`), which is the sense of the `np(E1)` and 4 (`$np2`) and use them in that order. When the sense is built, the result looks like this:
69+
`check` says: apply the quants from the right-hand positions 1 (`$np1`), which is the sense of the `np(E1)` and 4 (`$np2`) and use them in that order. When the sense is built, the result looks like this:
7070

71-
quant_check(
71+
check(
7272
quant(Q1, E1, ...),
7373
marry(P1, E1, E2)
7474
)
7575

76-
`quant_check` has a set of quantifiers, and a _scope_ that consists of zero or more relations (`marry(P1, E1, E2)`).
76+
`check` has a set of quantifiers, and a _scope_ that consists of zero or more relations (`marry(P1, E1, E2)`).
7777

7878
In this example the quant for E1 precedes that of E2, but the order does not need to match the order of the variables in the scope.
7979

80-
It is important to understand the way `quant_check` is evaluated. I will sketch the process here briefly. Note that the quants are nested, and that the inner loop uses a single value from the range of the outer quant, and goes through all range values of the inner loop.
80+
It is important to understand the way `check` is evaluated. I will sketch the process here briefly. Note that the quants are nested, and that the inner loop uses a single value from the range of the outer quant, and goes through all range values of the inner loop.
8181

8282
b1 = []binding
8383
foreach E1-range-set as E1 in outer range {
@@ -95,7 +95,7 @@ This is the process for 2 quants. The number of quants is often 1, and possibly
9595

9696
## Quant foreach
9797

98-
The function `quant_foreach` is exactly like find, with one important distinction: `do` checks the quantifier _during_ the loop as well.
98+
The function `do` is exactly like find, with one important distinction: `do` checks the quantifier _during_ the loop as well.
9999

100100
foreach E2-range-set as E2 in inner range {
101101
execute scope, bound with single E1 and E2, and add binding to b2
@@ -106,9 +106,9 @@ This relation is needed for different kinds of relations: imperative ones, like
106106

107107
Imagine now this sentence: "pick up two blocks".
108108

109-
Handling this question with `quant_check` amounts to picking up all blocks and then checking if there were two that were picked up. This is clearly nonsense. `quant_foreach` goes through all blocks, and attempts to pick them up. As soon as the quantifier `2` matches, it stops.
109+
Handling this question with `check` amounts to picking up all blocks and then checking if there were two that were picked up. This is clearly nonsense. `do` goes through all blocks, and attempts to pick them up. As soon as the quantifier `2` matches, it stops.
110110

111-
The difference between `quant_check` and `quant_foreach` is that `quant_foreach` stops when it has enough, while `quant_check` continues. Use `quant_check` with interrogative relations and `quant_foreach` with imperative relations.
111+
The difference between `check` and `do` is that `do` stops when it has enough, while `check` continues. Use `check` with interrogative relations and `do` with imperative relations.
112112

113113
## Unquantified nouns
114114

doc/manual/system-developer/processing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ To use the parser, you need to define a grammar.
6868

6969
Each grammar entry contains a rule and, optionally, a sense. The rule is the syntactic part, but extended with entity variables. The sense consists of the relations that are created when parsing the sentence. The entity variables of the syntax reappear in the relations. Let me give you an example of how this works. When the following rewrite rule has been completed (example clause: John could marry Elsa)
7070

71-
{ rule: np_comp2(E1) -> child(E1) have(_) np(E2), sense: go:quant_check($np, dom:have_child(E2, E1)) }
71+
{ rule: np_comp2(E1) -> child(E1) have(_) np(E2), sense: go:check($np, dom:have_child(E2, E1)) }
7272

7373
{ rule: interrogative(P1) -> 'how' 'many' np_comp2(E1), sense: go:intent(how_many, E1) }
7474

@@ -97,7 +97,7 @@ The example sentence (from Tokenizer paragraph) yields the following parse tree:
9797
When the whole tree is parsed all relations will be connected in a relational model. I just call this a relation set.
9898
Here's the relation set for our sample sentence:
9999

100-
go_quant_check(go_quant(go_quantifier(R9, R10, go_equals(R9, R10)), E8, none), dom_have_child(E8, E7)) go_intent(how_many, E7) go_intent(question)
100+
go_check(go_quant(go_quantifier(R9, R10, go_equals(R9, R10)), E8, none), dom_have_child(E8, E7)) go_intent(how_many, E7) go_intent(question)
101101

102102
### Answerer
103103

doc/remarks.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2022-10-31
2+
3+
Replaced `go:quant_foreach()` by `go:do()`.
4+
Replaced `go:quant_check()` by `go:check()`.
5+
6+
These are high frequent constructs and should have short and clear names.
7+
18
## 2022-10-30
29

310
Currently deactivating the `go:has_sort()` built-in predicate, because it just complicated things.

doc/todo.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ If the next sentence is "The waiter showed us our seat.", "the waiter" refers to
3838

3939
Make it consistent, complete, robust, etc. Have it conform existing paradigms.
4040

41-
- turn the "JSON" datatype into a "binary" datatype
4241
- maybe remove `result` from `responses` in the intent; it is not used now
4342
- I must implement all entities with atoms. Currently they are variables, but it means that variables are used as values, and this is clumsy. Then there must be a mapping from these atoms to database ids.
4443
- typed arguments

lib/knowledge/function/SystemSolverFunctionBase.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func (base *SystemSolverFunctionBase) GetFunctions() map[string]api.SolverFuncti
3232
mentalese.PredicateEventReference: base.eventReference,
3333

3434
// quant
35-
mentalese.PredicateQuantCheck: base.quantCheck,
36-
mentalese.PredicateQuantForeach: base.quantForeach,
35+
mentalese.PredicateCheck: base.quantCheck,
36+
mentalese.PredicateDo: base.quantForeach,
3737
mentalese.PredicateQuantOrderedList: base.quantOrderedList,
3838

3939
// control

lib/mentalese/Relation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const SortEntity = "entity"
2626
const SortEvent = "event"
2727

2828
const PredicateCanned = "go_canned"
29-
const PredicateQuantCheck = "go_quant_check"
30-
const PredicateQuantForeach = "go_quant_foreach"
29+
const PredicateCheck = "go_check"
30+
const PredicateDo = "go_do"
3131
const PredicateQuantOrderedList = "go_quant_ordered_list"
3232
const PredicateQuant = "go_quant"
3333
const PredicateQuantifier = "go_quantifier"

0 commit comments

Comments
 (0)