AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

How to implement a Chatscript bot that talk Spanish
 
 
  [ # 61 ]

Normally canonical.txt is meant as an override on standard dictionary data where CS has code to take a conjugation and find the base form in the dictionary.  As we don’t have that code for spanish, you have to enumerate all conjugations explicitly and all base forms.  There is currently no code equivalent for dynamically naming a base form, other than using canon: in a script file.  I could make such a function available. In that context, the cleanest thing to do is define a table in level 0 which lays out all the forms of a verb in one line: eg
envie “te enviare” “ya te envie”  ....

and the code for the table executes setting the canonical of each of the other words to the base form ( here I’m pretending it’s envie) and sets the part of speech and tense bits on a word. So each conjugation set would be a single line and common code sets them all appropriately.  This recreates the DICT (you don’t need to put your spanish in there) as data in the TOPIC folder.

I will proceed with creating the ability to store canonical form relationship from code so that will be available.

 

 
  [ # 62 ]

Thanks for your support Bruce

My spanish bot is quite simple, it only speaks spanish, it only uses only the most common verbs (guess 200), nouns (guess 5000) and persons, eg. it can spare the “Perfect Sujunctive”.

I found this english web that shows spanish conjugations, hope it could be handy.
http://www.spanishdict.com/conjugate/enviar

Sorry I didn’t quite understand all about that “table in level 0” I read the basic manual, the fact manual, and the PosParser manual, currently Im reading the “advanced manual”.

should start creating the DICT with only the nouns? (as explained post before)?

Thanks Advanced Bruce. Thanks for your support.

 

 
  [ # 63 ]

Verbs are easiest to as a script table. And example of such a table (that will work after next release) is this:
table: ^verbs (^canon ^present1s ^present2s ^present3s ^presentp ^past ^pastunusualpartciple)
if (^canon != *) {
^addProperty(^canon VERB VERB_INFINITIVE)
}
if (^present1s != *) {
^canon(^present1s ^canon)
^addProperty(^present1s VERB VERB_PRESENT )
}
if (^pastunusualpartciple != *) {
^canon(^present1s ^canon)
^addProperty(^pastunusualpartciple VERB PHRASAL_VERB )
}
DATA:
fuss fuss1 * * * * fusty

concept: ~unusualtense (~PHRASAL_VERB)

This table declares different forms of a canonical verb (I was lazy and didnt define the * ones).  Note the pastunusualparticiple. This is an example of some verb tense that doesn’t exist in english. The ones in English are defined in the properties of a word, in dictionarysystem.h.  These are accessed by normal names in matching like ~verbpresent.  If you have a spanish tense that is not an english tense, you will need to take over an existing bit for your own use. These will all be from systemflags. I chose PHRASAL_VERB because it will not be useful without using the pos-parser code. But in a pattern you wont want to use ~VERB_CONJUGATE1, so I defined a concept with a tense name that would make sense in patterns. Among the flags you can safely take over are:
INSEPARABLE_PHRASAL_VERB,  MUST_BE_SEPARATE_PHRASAL_VERB,  SEPARABLE_PHRASAL_VERB,  PHRASAL_VERB,  VERB_NOOBJECT, VERB_INDIRECTOBJECT, VERB_DIRECTOBJECT

 

 
  [ # 64 ]

So can we rename the bit flags to the following Spanish Tenses?

Old Bit Flag     New Bit Flag
VERB_INFINITIVE   VERB_INFINITIVE
VERB_PRESENT     VERB_PRESENT
INSEPARABLE_PHRASAL_VERB   VERB_PRETERITE
VERB_PAST     VERB_IMPERFECT
MUST_BE_SEPARATE_PHRASAL_VERB VERB_CONDITIONAL
SEPARABLE_PHRASAL_VERB   VERB_FUTURE
PHRASAL_VERB     VERB_PRESENT_SUBJECTIVE
VERB_NOOBJECT   VERB_IMPERFECT_SUBJECTIVE
VERB_INDIRECTOBJECT   VERB_IMPERFECT2_SUBJECTIVE
VERB_DIRECTOBJECT   VERB_FUTURE_SUBJECTIVE
VERB_TAKES_GERUND   VERB_IMPERATIVE_AFFIRMATIVE
VERB_TAKES_ADJECTIVE   VERB_IMPERATIVE_NEGATIVE
VERB_PRESENT_PARTICIPLE   VERB_PRESENT_PARTICIPLE
VERB_PAST_PARTICIPLE   VERB_PAST_PARTICIPLE

I needed two more flags.  Are VERB_TAKES_GERUND and VERB_TAKES_ADJECTIVE available to reuse?  We can just change the names in the dictionarySystem.h file and restart chatscript?

 

 
  [ # 65 ]

Those bits are also available. But if you merely change names in dictionarySystem.h, the files will not compile because the names are used in the english language parser code (which you are not using). That’s why I recommend merely aliasing things. You COULD add #defines into the file at the end like this:


#define INSEPARABLE_PHRASAL_VERB   VERB_PRETERITE
which will not disturb existing code.  In a topic file you need to do:
concept: ~verb_preterite (VERB_PRETERITE)
which enables you do things analogous to matching: 
u: ( I * ~verb_present * home)
presuming you have coded via a table that your word has the VERB_PRETERITE property, EG
table: ^spanishverbs(^base ^preteriteform ...)
  ^addproperty(^preteriteform VERB_PRETERITE)
DATA
somespanishword somespanishpreteriteformofthatword

 

 
  [ # 66 ]

It looks like there are 66 Spanish verb conjugations to map to each infinitive. Can the rows for the verb table wrap?  Maybe the data table could have the following columns:

^VERB(^canon ^tense ^tense1s ^tense2s ^tense3s ^tense1p ^tense2p ^tense3p)
...
<code>
...

DATA:
hablar VERB_PRESENT hablo hablas habla hablamos habláis hablan
habar VERB_PRETERITE hablé hablaste habló hablamos habláis hablaban
...


66 conjugations of hablar infinitive:

Column   Spanish Word   Bit Flag
1 VERB_INFINITIVE   hablar   VERB_INFINITIVE
2 VERB_PRESENT_1S   hablo   VERB_PRESENT
3 VERB_PRESENT_2S   hablas   VERB_PRESENT
4 VERB_PRESENT_3S   habla   VERB_PRESENT
5 VERB_PRESENT_1P   hablamos   VERB_PRESENT
6 VERB_PRESENT_2P   habláis   VERB_PRESENT
7 VERB_PRESENT_3P   hablan   VERB_PRESENT
8 VERB_PRETERITE_1S   hablé    VERB_PRETERITE
9 VERB_PRETERITE_2S   hablaste   VERB_PRETERITE
10 VERB_PRETERITE_3S   habló    VERB_PRETERITE
11 VERB_PRETERITE_1P   hablamos   VERB_PRETERITE
12 VERB_PRETERITE_2P   hablasteis   VERB_PRETERITE
13 VERB_PRETERITE_3P   hablaron   VERB_PRETERITE
14 VERB_IMPERFECT_1S   hablaba   VERB_IMPERFECT
15 VERB_IMPERFECT_2S   hablabas   VERB_IMPERFECT
16 VERB_IMPERFECT_3S   hablaba   VERB_IMPERFECT
17 VERB_IMPERFECT_1P   hablábamos   VERB_IMPERFECT
18 VERB_IMPERFECT_2P   hablabais   VERB_IMPERFECT
19 VERB_IMPERFECT_3P   hablaban   VERB_IMPERFECT
20 VERB_CONDITIONAL_1S hablaría   VERB_CONDITIONAL
21 VERB_CONDITIONAL_2S hablarías   VERB_CONDITIONAL
22 VERB_CONDITIONAL_3S hablaría   VERB_CONDITIONAL
23 VERB_CONDITIONAL_1P hablaríamos   VERB_CONDITIONAL
24 VERB_CONDITIONAL_2P hablaríais   VERB_CONDITIONAL
25 VERB_CONDITIONAL_3P hablarían   VERB_CONDITIONAL
26 VERB_FUTURE_1S   hablaré  VERB_FUTURE
27 VERB_FUTURE_2S   hablarás   VERB_FUTURE
28 VERB_FUTURE_3S   hablará  VERB_FUTURE
29 VERB_FUTURE_1P   hablaremos   VERB_FUTURE
30 VERB_FUTURE_2P   hablaréis   VERB_FUTURE
31 VERB_FUTURE_3P   hablarán   VERB_FUTURE
32 VERB_PRESENT_SUBJECTIVE_1S hable   VERB_PRESENT_SUBJECTIVE
33 VERB_PRESENT_SUBJECTIVE_2S hables   VERB_PRESENT_SUBJECTIVE
34 VERB_PRESENT_SUBJECTIVE_3S hable   VERB_PRESENT_SUBJECTIVE
35 VERB_PRESENT_SUBJECTIVE_1P hablemos   VERB_PRESENT_SUBJECTIVE
36 VERB_PRESENT_SUBJECTIVE_2P habléis   VERB_PRESENT_SUBJECTIVE
37 VERB_PRESENT_SUBJECTIVE_3P hablen   VERB_PRESENT_SUBJECTIVE
38 VERB_IMPERFECT_SUBJECTIVE_1S hablara   VERB_IMPERFECT_SUBJECTIVE
39 VERB_IMPERFECT_SUBJECTIVE_2S hablaras   VERB_IMPERFECT_SUBJECTIVE
40 VERB_IMPERFECT_SUBJECTIVE_3S hablara   VERB_IMPERFECT_SUBJECTIVE
41 VERB_IMPERFECT_SUBJECTIVE_1P habláramos VERB_IMPERFECT_SUBJECTIVE
42 VERB_IMPERFECT_SUBJECTIVE_2P hablarais   VERB_IMPERFECT_SUBJECTIVE
43 VERB_IMPERFECT_SUBJECTIVE_3P hablaran   VERB_IMPERFECT_SUBJECTIVE
44 VERB_IMPERFECT2_SUBJECTIVE_1S hablase   VERB_IMPERFECT2_SUBJECTIVE
45 VERB_IMPERFECT2_SUBJECTIVE_2S hablases   VERB_IMPERFECT2_SUBJECTIVE
46 VERB_IMPERFECT2_SUBJECTIVE_3S hablase   VERB_IMPERFECT2_SUBJECTIVE
47 VERB_IMPERFECT2_SUBJECTIVE_1P hablásemos VERB_IMPERFECT2_SUBJECTIVE
48 VERB_IMPERFECT2_SUBJECTIVE_2P hablaseis   VERB_IMPERFECT2_SUBJECTIVE
49 VERB_IMPERFECT2_SUBJECTIVE_3P hablasen   VERB_IMPERFECT2_SUBJECTIVE
50 VERB_FUTURE_SUBJECTIVE_1S hablare   VERB_FUTURE_SUBJECTIVE
51 VERB_FUTURE_SUBJECTIVE_2S hablares   VERB_FUTURE_SUBJECTIVE
52 VERB_FUTURE_SUBJECTIVE_3S hablare   VERB_FUTURE_SUBJECTIVE
53 VERB_FUTURE_SUBJECTIVE_1P habláremos VERB_FUTURE_SUBJECTIVE
54 VERB_FUTURE_SUBJECTIVE_2P hablareis   VERB_FUTURE_SUBJECTIVE
55 VERB_FUTURE_SUBJECTIVE_3P hablaren   VERB_FUTURE_SUBJECTIVE
56 IMPERATIVE_AFFIRMATIVE_2S habla   VERB_IMPERATIVE_AFFIRMATIVE
57 IMPERATIVE_AFFIRMATIVE_3S hable   VERB_IMPERATIVE_AFFIRMATIVE
58 IMPERATIVE_AFFIRMATIVE_1P hablemos   VERB_IMPERATIVE_AFFIRMATIVE
59 IMPERATIVE_AFFIRMATIVE_2P hablad   VERB_IMPERATIVE_AFFIRMATIVE
60 IMPERATIVE_AFFIRMATIVE_3P hablen   VERB_IMPERATIVE_AFFIRMATIVE
61 IMPERATIVE_NEGATIVE_2S   no hables   VERB_IMPERATIVE_NEGATIVE
62 IMPERATIVE_NEGATIVE_3S   no hable   VERB_IMPERATIVE_NEGATIVE
63 IMPERATIVE_NEGATIVE_1P   no hablemos VERB_IMPERATIVE_NEGATIVE
64 IMPERATIVE_NEGATIVE_2P   no habléis   VERB_IMPERATIVE_NEGATIVE
65 IMPERATIVE_NEGATIVE_3P   no hablen   VERB_IMPERATIVE_NEGATIVE
66 VERB_PRESENT_PARTICIPLE hablando   VERB_PRESENT_PARTICIPLE
67 VERB_PAST_PARTICIPLE   hablado   VERB_PAST_PARTICIPLE

 

 
  [ # 67 ]

You certainly cant put them on the same line because of a macro argument limit of 15 arguments. Your column, word, bitflag approach works fine if the table is:
table: ~verbdata( ^word ^property)
^addproperty( ^word ^property)
DATA:
hablemos   VERB_IMPERATIVE_AFFIRMATIVE
hablad   VERB_IMPERATIVE_AFFIRMATIVE
hablen   VERB_IMPERATIVE_AFFIRMATIVE
no hables   VERB_IMPERATIVE_NEGATIVE   # IMPERATIVE_NEGATIVE_2S
It didn’t look like you were using IMPERATIVE_NEGATIVE_2S (ie not as a bit) so if its merely a comment then you can use that after, as a comment
Note you cannot put no hables as a verb. You can put “no hables” or no_hables.

 

 
  [ # 68 ]

And then once ^canon is available can I do something like the following to add the previous canonical form to following lines? Or is it best to just repeat the canonical form as a 3rd column on every row of the data table?

table: ~verbdata( ^word ^property)
^addproperty( ^word ^property)
if (^property = VERB_INFINITIVE) { $canonical = ^word } ELSE { ^canon(^word $canonical) }

DATA:
hablar     VERB_INFINITIVE
hablemos   VERB_IMPERATIVE_AFFIRMATIVE
hablad     VERB_IMPERATIVE_AFFIRMATIVE

 

 
  [ # 69 ]

As I released a new version yesterday, ^canon is already available. Actually in your case I would use a tablemacro:. This allows you to designate the first n arguments (in your case the canonical form) and means you can invoke your actual table with that supplemental argument. Go read up on it.

 

 
  [ # 70 ]

Hi, Bruce, thanks for your support

All these seems pretty advanced to me, I’m currently reading the Fact Manual, before reading the Advanced Manual. The “table:” info is in the fact manual, am I right? where can I find info about the ^canon stuff?

Thanks Advanced.

 

 
  [ # 71 ]

Well, yes, it is “advanced”. You are taking on an extremely advanced project. The ^canon documentation is with the rest of the functions documentation, in System Functions manual. Here is an illustration of tablemacros.
tablemacro: ^favetable(^topic ^modifier ^main ^message )
...code for building facts based on these 4 parameters

table: ^favetable(~games )
board game “My favorite board game is Monopoly because I like the idea of owning everything.”
strategy game “My favorite strategy game is Go because the Japanese know a good game when they play one.”

The table sets ~games as the universal first argument to the tablemacro and then is a local table of 3 values which become the remaining 3 arguments to the tablemacro. You can set any of the initial arguments and then your table consists of the remaining ones.

 

 
  [ # 72 ]

Thanks Bruce.  I downloaded the latest version 5.8 and created the following table macro.  I tried hardcoding ^canon(hablo hablar) into the code and it still did not work for me.  Do I need a createfact(^word member ~verbs) in addition to the ^addProperty command?  I deleted the dictionary files so how do verb forms become added as words in the dictionary if the words need to exist before an ^addproperty can be used?


outputmacro: ^addverb(^canonicalform ^verbtense ^word)
if (^word != *) {
^addProperty(^word VERB ^verbtense)
^canon(^word ^canonicalform)
}

tablemacro: ^addverbs(^canonicalform ^verbtense ^person1_singular ^person2_singular ^person3_singular ^person1_plural ^person2_plural ^person3_plural)

^addProperty(^canonicalform VERB VERB_INFINITIVE)
^addverb(^canonicalform ^verbtense ^person1_singular )
^addverb(^canonicalform ^verbtense ^person2_singular )
^addverb(^canonicalform ^verbtense ^person3_singular )
^addverb(^canonicalform ^verbtense ^person1_plural )
^addverb(^canonicalform ^verbtense ^person2_plural )
^addverb(^canonicalform ^verbtense ^person3_plural )

table: ^addverbs(hablar)
VERB_PRESENT hablo hablas habla hablamos habláis hablan
VERB_PAST hablaba hablabas hablaba hablábamos hablabais hablaban


I defined the following concepts and they appear when executing :conceptlist
concept: ~myverbs (~myverb_present ~myverb_past)
concept: ~myverb_present (VERB_PRESENT)
concept: ~myverb_past (VERB_PAST)

:concepts hablo returns nothing.  Only when I add ^createfact(^word member ~verbs) then the ~verb concept appears but no concepts that should be linked via bit flags are showing.  I modified files0.txt to point to a “/rawdata/Spanish/” folder with verbs.tbl as the fiel containing the code.  I believe it is processing the file because i made several syntax errors and these were reported during building.  I restarted chatscript and performed :build 0 and :build Harry after each change.  I saved the file as UTF-8.  I did not modify the dictionarySystem.h file or any other files in this latest 5.8 install.

 

 
  [ # 73 ]

Hi Alaric Schenck,
I guess you have experience building a chatscript chatbot in english, right? How long have you been working with Chatscript?
Thanks Advanced.

 

 
  [ # 74 ]

Re ^canon—yes my bug in code. Fixed, pending new CS release.

“Do I need a createfact(^word member ~verbs) in addition to the ^addProperty”
The bit involved for a verb is VERB so the set is called ~verb. You should see that on a :prepare. There is a different set, ~verbs, constructed by ONTOLOGY/verbhierarchy.txt which is only english verbs. I don’t know that you actually need to refer to that concept set at all.

“I deleted the dictionary files so how do verb forms become added as words in the dictionary if the words need to exist before an ^addproperty can be used? “

Words do not need to exist before addproperty, it will create a word. After a compile, the TOPIC/dict1.txt file (or if done at level 0 the dict0.txt file) will list all the words that should be added to the dictionary and with what bits.

 

 
  [ # 75 ]

You can actually write script to work around the canon bug. The goal is a file in TOPIC called canon1.txt (or 0 if that’s your level). It contains 1 entry per line, 1st word is the raw form, 2nd word is the canonical. You can put in your table script to use ^log to directly write append that file yourself (after initially somewhere else forcing it to create afresh).

 

‹ First  < 3 4 5 6 7 >  Last ›
5 of 17
 
  login or register to react
‹‹ Web interaction      Why no direct_so query? ››