Skip to content

Commit 5c2ccde

Browse files
committed
NLP-2043 fixes to engine for foreign, fixes to livedata direct_ queries
1 parent 1504dea commit 5c2ccde

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

BINARIES/chatscript.exe

512 Bytes
Binary file not shown.

LIVEDATA/ENGLISH/numbers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ couple 2 WORD_NUMBER
1515
deuce 2 WORD_NUMBER
1616
pair 2 WORD_NUMBER
1717
half 2 FRACTION_NUMBER
18+
halves 2 FRACTION_NUMBER
1819
three 3 REAL_NUMBER
1920
third 3 WORD_NUMBER
2021
triple 3 WORD_NUMBER

LIVEDATA/SYSTEM/queries.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ QUERY: directflag_v "1vq: queue v : f" # (? love ?)
155155
# 2. walk thru q, looking at facts were q item is verb
156156
# 3. fact must have flag on it from match argument
157157

158-
159158
# find facts given an object
160159
QUERY: direct_o "1oq: queue o" # (? ? cat)
161160
# 1. tag object with 1 and queue it
@@ -169,35 +168,35 @@ QUERY: directflag_o "1oq: queue o : f" # (? ? cat)
169168
# 3. there are no constraints to match, so all facts are accepted that have factflag on
170169

171170
# find facts given subject and verb
172-
QUERY: direct_sv "1sq 2vt: queue s: match v2" # (dog love ?)
171+
QUERY: direct_sv "1sq 2vT: queue s: match v2" # (dog love ?)
173172
# 1. tag subject with 1 and queue it
174173
# 2. mark verb with 2 (no queuing)
175174
# 3. walk thru q, looking at facts where q item is subject
176175
# 4. accept facts where verb is marked with 2
177176

178177
# find facts given subject and verb
179-
QUERY: directflag_sv "1sq 2vt: queue s: match v2 f" # (dog love ?)
178+
QUERY: directflag_sv "1sq 2vT: queue s: match v2 f" # (dog love ?)
180179
# 1. tag subject with 1 and queue it
181180
# 2. mark verb with 2 (no queuing)
182181
# 3. walk thru q, looking at facts where q item is subject
183182
# 4. accept facts where verb is marked with 2 and fact flag is on
184183

185184
# find facts given fact subject and verb
186-
QUERY: direct_Sv "1Sq 2vt: queue s: match v2" # (dog love ?)
185+
QUERY: direct_Sv "1Sq 2vT: queue s: match v2" # (dog love ?)
187186
# 1. tag subject with 1 and queue it
188187
# 2. mark verb with 2 (no queuing)
189188
# 3. walk thru q, looking at facts where q item is subject
190189
# 4. accept facts where verb is marked with 2
191190

192191
# find facts given verb and object
193-
QUERY: direct_vo "1oq 2vt: queue o: match v2" # (? love cat)
192+
QUERY: direct_vo "1oq 2vT: queue o: match v2" # (? love cat)
194193
# 1. tag object with 1 and queue it
195194
# 2. mark verb with 2 (no queuing)
196195
# 3. walk thru q, looking at facts where q item is object
197196
# 4. accept facts where verb is marked with 2
198197

199198
# find facts given verb and object and flag
200-
QUERY: directflag_vo "1oq 2vt: queue o: match v2 f" # (? love cat)
199+
QUERY: directflag_vo "1oq 2vT: queue o: match v2 f" # (? love cat)
201200
# 1. tag object with 1 and queue it
202201
# 2. mark verb with 2 (no queuing)
203202
# 3. walk thru q, looking at facts where q item is object
@@ -211,22 +210,22 @@ QUERY: direct_vO "1Oq 2vt: queue o: match v2" # (? love cat)
211210
# 4. accept facts where verb is marked with 2
212211

213212
# find facts given subject and object
214-
QUERY: direct_so "1sq 2ot: queue s: match o2" # (dog ? cat)
213+
QUERY: direct_so "1sq 2oT: queue s: match o2" # (dog ? cat)
215214
# 1. tag subject with 1 and queue it
216215
# 2. mark object with 2 (no queuing)
217216
# 3. walk thru q, looking at facts where q item is subject
218217
# 4. accept facts where object is marked with 2
219218

220219
# find facts given subject verb and object
221-
QUERY: direct_svo "1oq 2vt 3st: queue o: match v2 s3" # (dog love cat)
220+
QUERY: direct_svo "1oq 2vT 3sT: queue o: match v2 s3" # (dog love cat)
222221
# 1. tag object with 1 and queue it
223222
# 2. mark verb with 2 (no queuing)
224223
# 3. mark subject with 3 (no queuing)
225224
# 4. walk thru q, looking at facts where q item is object
226225
# 5. accept facts where verb is marked with 2 and subject is marked with 3
227226

228227
# find facts given subject verb and object and flag
229-
QUERY: directflag_svo "1oq 2vt 3st: queue o: match v2 s3 f" # (dog love cat)
228+
QUERY: directflag_svo "1oq 2vT 3sT: queue o: match v2 s3 f" # (dog love cat)
230229
# 1. tag object with 1 and queue it
231230
# 2. mark verb with 2 (no queuing)
232231
# 3. mark subject with 3 (no queuing)

SRC/dictionarySystem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ char* GetCanonical(WORDP D)
306306
{
307307
std::map<WORDP,WORDP>::iterator it;
308308
it = canonicalWords.find(D);
309-
return (it != canonicalWords.end()) ? it->second->word : NULL;
309+
if (it == canonicalWords.end()) return NULL;
310+
return it->second->word;
310311
}
311312

312313
WORDP GetTense(WORDP D)
@@ -1853,6 +1854,7 @@ void WriteDictionary(WORDP D,uint64 data)
18531854
WriteDictionaryReference((char*)"conjugate",GetTense(D),out);
18541855
WriteDictionaryReference((char*)"plural",GetPlural(D),out);
18551856
WriteDictionaryReference((char*)"comparative",GetComparison(D),out);
1857+
if (GetCanonical(D)) WriteDictionaryReference((char*)"lemma", FindWord(GetCanonical(D)), out);
18561858

18571859
// show the meanings, with illustrative gloss
18581860

SRC/english.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ uint64 GetPosData( int at, char* original,WORDP& revise, WORDP &entry,WORDP &can
608608

609609
if (externalTagger || stricmp(language, "english"))
610610
{
611-
entry = canonical = StoreWord(original);
611+
entry = StoreWord(original);
612+
canonical = FindWord(GetCanonical(entry));
613+
if (!canonical) canonical = entry;
612614
return 0; // remote pos tagging or none
613615
}
614616

SRC/testing.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9317,6 +9317,13 @@ static void BuildForeign(char* input)
93179317
printf("file not found");
93189318
return;
93199319
}
9320+
9321+
UseDictionaryFile(NULL);
9322+
InitFacts();
9323+
InitDictionary();
9324+
InitStackHeap();
9325+
InitCache();
9326+
93209327
sprintf(name,"DICT/%s",language);
93219328
MakeDirectory(name);
93229329
ClearDictionaryFiles();
@@ -9339,6 +9346,7 @@ static void BuildForeign(char* input)
93399346
*close = 0;
93409347
strcpy(lemma, ptr + 1);
93419348
*close = ')';
9349+
if (!strcmp(lemma, word)) *lemma = 0; // cancel same lemma
93429350

93439351
char pos[MAX_WORD_SIZE];
93449352
unsigned int flags = 0;
@@ -9351,10 +9359,12 @@ static void BuildForeign(char* input)
93519359
WORDP D = FindWord(pos);
93529360
if (D) flags |= D->properties;
93539361
}
9354-
StoreWord(word, flags);
9362+
WORDP D = StoreWord(word, flags);
9363+
if (*lemma) SetCanonical(D, MakeMeaning(StoreWord(lemma)));
93559364
}
93569365
fclose(in);
93579366
WalkDictionary(WriteDictionary);
9367+
myexit("end foreign build");
93589368
}
93599369

93609370
static void TrimIt(char* name,uint64 flag)

0 commit comments

Comments
 (0)