[Home: Demos and Tutorials][e2gRuleEngine Mini-Course Index]

Building and Using Expert Systems: a Mini-Course Introducing the e2gRuleEngine Expert System Shell and e2gRuleWriter Decision Table Software

Module 8: Delivering a Knowledge Base in Languages Other Than English

Module 8 Index


Localizing a knowledge base

A typical approach to delivering applications in multiple languages is to first produce a version in a base language, then localize this version of the application for each target language. Once a base language (English is currently the only base language for the e2gRuleEngine) version of a knowledge base has been developed and debugged, the following steps may be used to deliver it in another language:

Here's an example of the auto diagnosis knowledge base translated into French. This is the autofr.kb file referenced in the KBURL applet parameter in the HTML that loads the knowledge base. This is a machine translation and is therefore less polished than would be expected from an expert human translator. The English version of this knowledge base is available as the Example e2gRuleEngine Knowledge Base in the reference documentation.

French Translation of the Auto Diagnosis Knowledge Base
REM Test knowledge base: Must be stored as a Unicode file if applet parameter sets KBENCODING=UTF-16 

RULE [La batterie est-elle morte?]
If [le résultat d'alimenter les phares] = "rien ne se produit" or
[le résultat d'essayer le démarreur] = "rien ne se produit"
Then [recommandée l'action] = "rechargez ou substituez la batterie"

RULE [La voiture est-elle hors d'essence?]
If [le réservoir d'essence] = "vide"
Then [recommandée l'action] = "réapprovisionnez en combustible la voiture"

RULE [La batterie est-elle faible?]
If [le résultat d'essayer le démarreur] : "les manivelles de voiture lentement" "les manivelles de voiture normalement" and
[les phares obscurcissent en essayant le démarreur] = true and
[la quantité vous êtes disposé à dépenser sur des réparations] > 24.99
Then [recommandée l'action] = "rechargez ou substituez la batterie"

RULE [La voiture est-elle inondée?]
If [le résultat d'essayer le démarreur] = "les manivelles de voiture normalement" and
[une odeur d'essence] = "présentez en essayant le démarreur"
Then [recommandée l'action] = "l'attente 10 minutes, relancent alors inondée la voiture"

RULE [Le réservoir d'essence est-il vide?]
If [le résultat d'essayer le démarreur] = "les manivelles de voiture normalement" and
[une odeur d'essence] = "pas présentez en essayant le démarreur"
Then [le réservoir d'essence] = "vide" @ 90

PROMPT [le résultat d'essayer le démarreur] Choice CF
"Que se produit quand vous tournez la clé pour essayer de mettre en marche la voiture?"
"les manivelles de voiture normalement"
"les manivelles de voiture lentement"
"rien ne se produit"

PROMPT [une odeur d'essence] MultChoice CF
"Une odeur d'essence et:"
"présentez en essayant le démarreur"
"pas présentez en essayant le démarreur"

PROMPT [le résultat d'alimenter les phares] MultChoice CF
"Le résultat d'alimenter les phares et:"
"ils s'allument"
"rien ne se produit"

PROMPT [les phares obscurcissent en essayant le démarreur] YesNo CF
"Les phares obscurcissent-ils quand vous essayez le démarreur avec les lumières?"

PROMPT [le réservoir d'essence] MultChoice CF
"Selon la mesure de carburant, le réservoir d'essence est:"
"vide"
"non vide"

PROMPT [la quantité vous êtes disposé à dépenser sur des réparations] Numeric CF
"Combien coûtez-vous disposé à dépenser sur des réparations? (0->500)"
"0"
"500.0"

GOAL [recommandée l'action]

MINCF 80

REM French translation
REM Button text 
TRANSLATE B_SUBMIT = "Soumettez votre réponse" 
TRANSLATE B_EXPLAIN = "Expliquent" 
TRANSLATE B_WHYASK = "Pourquoi demandez?" 
TRANSLATE B_RESTART = "Relancement" 
TRANSLATE B_RETURN = "Retournent" 
REM Message text 
TRANSLATE TR_KB = "Base de connaissance:" 
TRANSLATE TR_NORESP = "Je ne connais pas/ne répondrait plutôt pas" 
TRANSLATE TR_HOWCONF = "Que confiant pensez-vous de votre réponse?" 
TRANSLATE TR_LOWCONF = "Très incertain (50%)" "
TRANSLATE TR_HICONF = "Très certain (100%)" 
TRANSLATE TR_YES = "Oui" 
TRANSLATE TR_NO = "Non"
TRANSLATE TR_FALSE = "faux" 
TRANSLATE TR_RESULTS = "FINALS RÉSULTATS:" 
TRANSLATE TR_MINCF = "Facteur minimum de confiance pour recevoir une valeur comme fait:" 
TRANSLATE TR_NOTDETERMINED = "n'a pas pu être déterminé" 
TRANSLATE TR_ISRESULT = "est:" 
TRANSLATE TR_WITH = "avec" 
TRANSLATE TR_CONF = "% de confiance" 
TRANSLATE TR_ALLGOALS = "toutes les conclusions" 
TRANSLATE TR_VALUE = "Valeur" 
TRANSLATE TR_OF = "de" 
TRANSLATE TR_THISRULE = "Règle au-dessous de réussi à CF=" 
TRANSLATE TR_RULEASGN = "et assigné la valeur" 
TRANSLATE TR_TOFIND = "Pour trouver" 
TRANSLATE TR_AVALUE = "une valeur pour" 
TRANSLATE TR_ISNEEDED = "est nécessaire pour essayer cette règle:" 
TRANSLATE TR_RULE = "RÈGLE:" 
TRANSLATE TR_IF = "SI:" 
TRANSLATE TR_THEN = "ALORS:" 
TRANSLATE TR_AND = "et" 
TRANSLATE TR_OR = "ou" 
TRANSLATE TR_IS = "est" 
TRANSLATE TR_EQUAL = "est" 
TRANSLATE TR_LESSTHAN = "est moins qu'" 						 
TRANSLATE TR_NOTEQUAL = "n'est past" 
TRANSLATE TR_GREATER = "est plus grand qu'" 
TRANSLATE TR_VALUEFOR = "Une valeur pour:" 
TRANSLATE TR_FOUND = "a été déterminé" 
TRANSLATE TR_NOTFOUND = "n'a pas été encore déterminé" 
TRANSLATE TR_WASINPUT = "a été entré avec" 
TRANSLATE TR_DETERMINED = "Déterminé" 
TRANSLATE TR_FROM = "de:" 
TRANSLATE TR_DEFAULTED = "a été placé par défaut avec" 
REM following added in v3.03
TRANSLATE TR_ONE = "une des valeurs du"
TRANSLATE TR_HOWCF1 = "Calcul de confiance de multi-source pour"  

Here's the HTML needed to access the French version (autofr.kb) of the auto diagnosis knowledge base. Note the use of the "KBENCODING" parameter that tells e2gRuleEngine that the knowledge base has been stored as a Unicode file (UTF-16). Although not absolutely required for Roman languages like French, some characters with diacritical marks display more accurately in most fonts when stored in Unicode. If the KBENCODING parameter is set to UTF-16, the knowledge base must be stored in Unicode or an error will be generated when e2gRuleEngine tries to read the file.

The next section discusses one method for storing Unicode files.

HTML for the French Version of the Auto Diagnosis Knowledge Base
<HTML>
<HEAD><TITLE>Système expert De Diagnostic D'Automobile</TITLE></HEAD>
<BODY BGCOLOR="#ffee33">
<APPLET CODE="e2gRuleEngine.class" archive="e2gRuleEngine.jar" width=525 height=300>
<PARAM NAME="KBURL" VALUE="autofr.kb">
<PARAM NAME="APPTITLE" VALUE="Conseiller De Diagnostic D'Automobile">
<PARAM NAME="APPSUBTITLE" VALUE="Une démonstration d'eXpertise2Go">
<PARAM NAME="STARTBUTTON" VALUE="Commencez la consultation">
<PARAM NAME="KBENCODING" VALUE="UTF-16">
<PARAM NAME="DEBUG" VALUE="false">
Java-capable browser required 
</APPLET>
</BODY>


Saving a knowledge base (.kb) or Web page (.htm) file in Unicode

If your application's Web page or e2gRuleEngine knowledge base incorporates non-Roman character sets, you must save the file as a Unicode file. If your application is delivered in a Roman language that employs diacritical marks, saving in Unicode is recommended. Many text editors provide this capability. For example, the Notepad editor included with Microsoft Windows operating systems provides the following Encoding option when Save As is selected from the File menu:


Demonstration and example knowledge base: Weather Wizard (simplified Chinese version)

Click the image below to run the weather example translated (partially) to simplified Chinese:

Example HTML to incorporate the Simplified Chinese language Weather knowledge base in a Web page 
<APPLET CODE="e2gRuleEngine.class" archive="e2gRuleEngine.jar" WIDTH=450 HEIGHT=300> <PARAM NAME="KBURL" VALUE="weatherCh.kb">
<PARAM NAME="APPTITLE" VALUE="天气示范">
<PARAM NAME="APPSUBTITLE" VALUE="由天气巫术师">
<PARAM NAME="PROMPTCOLOR" VALUE="#000000">
<PARAM NAME="BGCOLOR" VALUE="#00ff00">
<PARAM NAME="DEBUG" VALUE="false">
<PARAM NAME="WORDWRAP" VALUE="true">
<PARAM NAME="PROMPTSIZE" VALUE="12">
<PARAM NAME="KBENCODING" VALUE="UTF-16">
<PARAM NAME="STARTBUTTON" VALUE="推荐怎样佩带">
Java is required to view this page!
</APPLET>

Example e2gRuleEngine Knowledge Base: simplified Chinese version of the Weather Demonstration
REM Test Knowledge Base (weatherCh.kb) Chinese-simplified: MUST BE SAVED AS A UNICODE FILE!

RULE [下雨?]
If [降雨雪] = "期望" and
[期望的温度] > 32
Then [推荐] = "穿着雨衣"

RULE [下雪?]
If [降雨雪] = "期望" and
[期望的温度] < 33
Then [推荐] = "穿您的起动" @ 95

PROMPT [降雨雪] MultChoice CF
"根据天气预报,降雨雪是:"
"期望"
"没期望"

PROMPT [期望的温度] Numeric CF
"期望的白天温度(华氏度)是:"
"-30"
"120"

GOAL [推荐]

DEFAULT [推荐] = "佩带什么您想要" @ 90

REM Translation table for e2gRuleEngine output: only partially translated with Babel Fish (babelfish.yahoo.com)
REM Button text 
TRANSLATE B_SUBMIT = "递交您的反应" 
TRANSLATE B_EXPLAIN = "解释" 
TRANSLATE B_WHYASK = "为什么要求?" 
TRANSLATE B_RESTART = "再开始" 
TRANSLATE B_RETURN = "回归" 
REM Message text 
TRANSLATE TR_KB = "知识库:" 
TRANSLATE TR_NORESP = "我不知道也宁可不回答" 
TRANSLATE TR_HOWCONF = "多么确信您感觉关于您的反应?" 
TRANSLATE TR_LOWCONF = "非常不定(50%)" 
TRANSLATE TR_HICONF = "非常确定(100%)" 
TRANSLATE TR_YES = "是" 
TRANSLATE TR_NO = "否" 
TRANSLATE TR_FALSE = "错误"
TRANSLATE TR_RESULTS = "决赛成绩:" 
TRANSLATE TR_MINCF = "接受的价值极小的置信因数作为事实:" 
TRANSLATE TR_NOTDETERMINED = "不能是坚定的" 
TRANSLATE TR_ISRESULT = "is:" 
TRANSLATE TR_WITH = "with" 
TRANSLATE TR_CONF = "% confidence" 
TRANSLATE TR_ALLGOALS = "所有结论" 
TRANSLATE TR_VALUE = "Value" 
TRANSLATE TR_OF = "of" 
TRANSLATE TR_THISRULE = "Rule below fired at CF=" 
TRANSLATE TR_RULEASGN = "and assigned the value" 
TRANSLATE TR_TOFIND = "To find" 
TRANSLATE TR_AVALUE = "a value for" 
TRANSLATE TR_ISNEEDED = "is needed to try this rule:" 
TRANSLATE TR_RULE = "RULE:" 
TRANSLATE TR_IF = "IF:" 
TRANSLATE TR_THEN = "THEN:" 
TRANSLATE TR_AND = "and" 
TRANSLATE TR_OR = "or" 
TRANSLATE TR_EQUAL = "is" 
TRANSLATE TR_LESSTHAN = "is less than" 
TRANSLATE TR_GREATER = "is greater than" 
TRANSLATE TR_NOTEQUAL = "is not" 
TRANSLATE TR_VALUEFOR = "A value for:" 
TRANSLATE TR_FOUND = "has been determined" 
TRANSLATE TR_NOTFOUND = "has not yet been determined" 
TRANSLATE TR_WASINPUT = "was input with " 
TRANSLATE TR_DETERMINED = "Determined" 
TRANSLATE TR_IS = "is" 
TRANSLATE TR_FROM = "from:" 
TRANSLATE TR_DEFAULTED = "was set by default with"
REM following added in v3.03
TRANSLATE TR_ONE = "one of the values of"
TRANSLATE TR_HOWCF1 = "Multi-source confidence calculation for"


Demonstration and example knowledge base: Weather wizard (Cyrillic version)

Click the image below to run the weather example translated (partially) to Cyrillic:

Example HTML to incorporate the Cyrillic Weather knowledge base in a Web page 
<APPLET CODE="e2gRuleEngine.class" archive="e2gRuleEngine.jar" WIDTH=500 HEIGHT=300>
<PARAM NAME="KBURL" VALUE="weatherRu.kb">
<PARAM NAME="APPTITLE" VALUE="Демонстрация погоды">
<PARAM NAME="APPSUBTITLE" VALUE="чудодеем погоды">
<PARAM NAME="PROMPTCOLOR" VALUE="#000000">
<PARAM NAME="BGCOLOR" VALUE="#00ff00">
<PARAM NAME="DEBUG" VALUE="false">
<PARAM NAME="WORDWRAP" VALUE="true">
<PARAM NAME="PROMPTSIZE" VALUE="12">
<PARAM NAME="KBENCODING" VALUE="UTF-16">
<PARAM NAME="STARTBUTTON" VALUE="Порекомендуйте чего нести">
Java is required to view this page!
</APPLET>

Example e2gRuleEngine Knowledge Base: Cyrillic version of the Weather Demonstration
REM Test Knowledge Base (weatherRu.kb) Cyrillic: MUST BE SAVED AS A UNICODE FILE!

RULE [Оно идет идти дождь?]
If [высыпание] = "предположено" and
[предпологаемая температура] > 32
Then [рекомендация] = "несите плащ"

RULE [Оно идет идти снег?]
If [высыпание] = "предположено" and
[предпологаемая температура] < 33
Then [рекомендация] = "несите ваши ботинки" @ 95

PROMPT [высыпание] MultChoice CF
"Согласно прогнозу погоды, высыпание является следующим:"
"предположено"
"не предположено"

PROMPT [предпологаемая температура] Numeric CF
"Предпологаемая температура дневного времени (градусы Fahrenheit) является следующим:"
"-30"
"120"

GOAL [рекомендация]

DEFAULT [рекомендация] = "несите все, что угодно вы хотите к" @ 90

REM Translation table for e2gRuleEngine output: only partially translated with Babel Fish (babelfish.yahoo.com)
REM Button text 
TRANSLATE B_SUBMIT = "Представьте вашу реакцию" 
TRANSLATE B_EXPLAIN = "Объясните" 
TRANSLATE B_WHYASK = "Почему спросите?" 
TRANSLATE B_RESTART = "Рестарт" 
TRANSLATE B_RETURN = "Возвращение" 
REM Message text 
TRANSLATE TR_KB = "Knowledge base:" 
TRANSLATE TR_NORESP = "Я не знаю/довольно не ответил бы" 
TRANSLATE TR_HOWCONF = "Как уверенно вы чувствуете о вашей реакции?" 
TRANSLATE TR_LOWCONF = "Очень неуверено (50%)" 
TRANSLATE TR_HICONF = "Очень уверено (100%)" 
TRANSLATE TR_YES = "yes" 
TRANSLATE TR_NO = "no" 
TRANSLATE TR_FALSE = "false"
TRANSLATE TR_RESULTS = "FINAL RESULTS:" 
TRANSLATE TR_MINCF = "Minimum confidence factor for accepting a value as a fact:" 
TRANSLATE TR_NOTDETERMINED = "could not be determined" 
TRANSLATE TR_ISRESULT = "is:" 
TRANSLATE TR_WITH = "with" 
TRANSLATE TR_CONF = "% confidence" 
TRANSLATE TR_ALLGOALS = "все заключения" 
TRANSLATE TR_VALUE = "Value" 
TRANSLATE TR_OF = "of" 
TRANSLATE TR_THISRULE = "Rule below fired at CF=" 
TRANSLATE TR_RULEASGN = "and assigned the value" 
TRANSLATE TR_TOFIND = "To find" 
TRANSLATE TR_AVALUE = "a value for" 
TRANSLATE TR_ISNEEDED = "is needed to try this rule:" 
TRANSLATE TR_RULE = "RULE:" 
TRANSLATE TR_IF = "IF:" 
TRANSLATE TR_THEN = "THEN:" 
TRANSLATE TR_AND = "and" 
TRANSLATE TR_OR = "or" 
TRANSLATE TR_EQUAL = "is" 
TRANSLATE TR_LESSTHAN = "is less than" 
TRANSLATE TR_GREATER = "is greater than" 
TRANSLATE TR_NOTEQUAL = "is not" 
TRANSLATE TR_VALUEFOR = "A value for:" 
TRANSLATE TR_FOUND = "has been determined" 
TRANSLATE TR_NOTFOUND = "has not yet been determined" 
TRANSLATE TR_WASINPUT = "was input with " 
TRANSLATE TR_DETERMINED = "Determined" 
TRANSLATE TR_IS = "is" 
TRANSLATE TR_FROM = "from:" 
TRANSLATE TR_DEFAULTED = "was set by default with"
REM following added in v3.03
TRANSLATE TR_ONE = "one of the values of"
TRANSLATE TR_HOWCF1 = "Multi-source confidence calculation for"

[Index][Module 1][Module 2][Module 3][Module 4][Module 5][Module 6][Module 7][Module 9][Module 10][Reference]


Copyright © 2001 - 2009 by eXpertise2Go.com. All rights reserved.
webmaster@expertise2go.com