Multilanguage
Multilingual here refers to the language spoken by the user in the conversation, that is, user language. When starting ChatTree, pass in the "{_user_lang_}" system InfoItem and its value as the infoitem_params parameter content of the "Start Dialogue" interface (see "API") to specify the language spoken by the user in the dialogue (if not passed in, the default is en-US American English). Here the value of the "{_user_lang_}" system InfoItem can be (i.e. user language code):
- "en-US" # American English
- "en-GB" # British English
- "zh-CN" # Mainland Simplified Chinese
- "zh-HK" # Hong Kong Traditional Chinese
- "zh-TW" # Taiwan Traditional Chinese
- "pt-PT" # European Portuguese
- "pt-BR" # Brazilian Portuguese
- "es-ES" # European Spanish
- "es-MX" # Mexican Spanish
- "ja-JP" # Japanese
- "ru-RU" # Russian
- "ru-BY" # Belarusian Russian
- "ru-KZ" # Kazakhstani Russian
- "de-DE" # Germany German
- "de-AT" # Austria German
- "de-CH" # Switzerland German
- "fr-FR" # France French
- "fr-CA" # Canada Quebec French
- "fr-CH" # Switzerland French
- "fr-BE" # Belgium French
- "id-ID" # Indonesian
- "vi-VN" # Vietnamese
- "th-TH" # Thai
- "ar-SA" # Arabic-Saudi
- "ar-AE" # Arabic-UAE
- "it-IT" # Italian
- "nl-NL" # Dutch
- "ko-KR" # Korean
- "hi-IN" # India Hindi
- "bn-BD" # Bangladesh Bengali
- "bn-IN" # India Bengali
- "ur-PK" # Pakistan Urdu
- "tr-TR" # Turkish
- "pl-PL" # Polish
- "ms-MY" # Malay
- "fil-PH" # Filipino
- "uk-UA" # Ukrainian
- "fa-IR" # Persian
- "he-IL" # Hebrew
- "ro-RO" # Romanian
- "cs-CZ" # Czech
- "hu-HU" # Hungarian
- "sv-SE" # Swedish
- "da-DK" # Danish
- "fi-FI" # Finnish
- "nb-NO" # Norwegian written language
In the script or code of the ChatTree, you can use ctx.user_lang() to get the current user language
ChatTree
-
When developing the ChatTree, the development language is American English (en-US) (see "Quick Start"), that is, the system error messages, log informations, node types and attribute names of the ChatTree, the attribute content of the ChatTree (such as InfoItem names, intent descriptions, inform content, system question, background information, InfoItem options, etc.), etc., should all be American English (en-US). That is, the ChatTree defined in en-US American English naturally supports multiple user languages
-
But there are exceptions: five types of content are mentioned in "Text Output", if these contents are expressed in the form of "direct output", the system will automatically translate the content described in American English (en-US) into the user language specified above. However, sometimes the translation effect cannot meet the requirements, in this case, you can use the polling output definition method to provide multiple language versions at the same time, and add the code of the above user language with percent signs before and after each language version.
- For example, in the Python CHatTree, it was originally:
At this time, no matter what the user language is, the system will automatically translate "What help do you need?" into that user language
welcome_node = chattree.create_node( "#single_turn_interact#", {
...
"system_question": "What help do you need?",
...
)} - now changes to:
In this way, the system will select the corresponding language original text for output based on the specific user language, instead of translating it. In this case, if the output content contains the name of the InfoItem (the place where the name of the InfoItem appears in the actual output will be replaced by the value of the InfoItem, see the "Assignment and Use of InfoItems" section of "InfoItem"), then the name of the InfoItem should also be American English (en-US)
welcome_node = chattree.create_node( "#Single interaction#", {
...
"system_question" : ["%en-US%What help do you need?", "%zh-CN%请问您需要什么帮助?", "%ru-RU%Какая помощь вам нужна?", "%es-ES%¿Qué ayuda necesitas?"],
...
)} - If the above five types of content output to the user are expressed in the form of "Prompt Word" (i.e. "<...>"), there will be no relevant problems, and all can still be expressed in American English (en-US).
- For example, in the Python CHatTree, it was originally:
Knowledge Base
- When building the knowledge base, the default is also American English (en-US), such as:
# Terminology Concept
## AI
### Definition
Artificial Intelligence (AI) refers to tasks performed by computer systems that usually require human intelligence. It includes machine learning, natural language processing, computer vision and other fields.
### Synonyms
intelligent computing
### Differences from Related Concepts
Artificial intelligence is different from traditional software programming, which is based on clear rules and logic, while artificial intelligence learns and makes decisions in a data-driven manner.
## Machine Learning
### Definition
Machine Learning is a subfield of artificial intelligence that focuses on developing algorithms that enable computers to learn from data and improve performance without having to be explicitly programmed.
### Synonyms
adaptive systems
### Differences from Related Concepts
Machine learning is a method for achieving artificial intelligence, but not all artificial intelligence systems rely on machine learning. - But to support other user languages, you need to mark each line in the knowledge base with the relevant user language, that is, add the code of the corresponding user language with percent signs before and after the beginning of each line, such as (the knowledge base supports zh-CN Simplified Chinese, en-US American English and ru-RU Russian):
%zh-CN% # 术语概念
%en-US% # Terminology Concept
%ru-RU% # Термины и понятия
%zh-CN% ## 人工智能
%en-US% ## AI
%ru-RU% ## Искусственный интеллект
%zh-CN% ### 定义
%en-US% ### Definition
%ru-RU% ### Определение
%zh-CN% 人工智能(Artificial Intelligence,AI)是指由计算机系统执行的通常需要人类智能的任务。它包括机器学习、自然语言处理、计算机视觉等多个领域。
%en-US% Artificial Intelligence (AI) refers to tasks performed by computer systems that usually require human intelligence. It includes machine learning, natural language processing, computer vision and other fields.
%ru-RU% Искусственный интеллект(Artificial Intelligence,AI)— это задачи, выполняемые компьютерными системами, которые обычно требуют человеческого интеллекта. Он включает такие области, как машинное обучение, обработка естественного языка, компьютерное зрение и другие направления.
%zh-CN% ### 同义词/近义词
%en-US% ### Synonyms
%ru-RU% ### Синонимы / близкие по значению термины
%zh-CN% AI、智能计算
%en-US% intelligent computing
%ru-RU% AI, интеллектуальные вычисления
%zh-CN% ### 与相关概念的区别
%en-US% ### Differences from Related Concepts
%ru-RU% ### Отличия от связанных понятий
%zh-CN% 人工智能不同于传统的软件编程,后者是基于明确的规则和逻辑,而人工智能则通过数据驱动的方式进行学习和决策。
%en-US% Artificial intelligence is different from traditional software programming, which is based on clear rules and logic, while artificial intelligence learns and makes decisions in a data-driven manner.
%ru-RU% Искусственный интеллект отличается от традиционного программирования: традиционное программирование основано на явно заданных правилах и логике, тогда как искусственный интеллект обучается и принимает решения на основе данных.
%zh-CN% ## 机器学习
%en-US% ## Machine Learning
%ru-RU% ## Машинное обучение
%zh-CN% ### 定义
%en-US% ### Definition
%ru-RU% ### Определение
%zh-CN% 机器学习(Machine Learning)是人工智能的一个子领域,专注于开发算法,使计算机能够从数据中学习和改进性能,而无需明确编程。
%en-US% Machine Learning is a subfield of artificial intelligence that focuses on developing algorithms that enable computers to learn from data and improve performance without having to be explicitly programmed.
%ru-RU% Машинное обучение(Machine Learning)— это подраздел искусственного интеллекта, который сосредоточен на разработке алгоритмов, позволяющих компьютерам обучаться на данных и улучшать свою производительность без явного программирования.
%zh-CN% ### 同义词/近义词
%en-US% ### Synonyms
%ru-RU% ### Синонимы / близкие по значению термины
%zh-CN% ML、自适应系统
%en-US% adaptive systems
%ru-RU% ML, адаптивные системы
%zh-CN% ### 与相关概念的区别
%en-US% ### Differences from Related Concepts
%ru-RU% ### Отличия от связанных понятий
%zh-CN% 机器学习是实现人工智能的一种方法,但并非所有的人工智能系统都依赖于机器学习。
%en-US% Machine learning is a method for achieving artificial intelligence, but not all artificial intelligence systems rely on machine learning.
%ru-RU% Машинное обучение является одним из методов реализации искусственного интеллекта, но не все системы искусственного интеллекта зависят от машинного обучения.
The value of Infoitem
- The name of the InfoItem is en-US American English, but the value of the InfoItem will be the corresponding user language in most cases
- But there are exceptions:
- If a node that defines "user input" InfoItem is a "#single_turn_interact#" node, and the node is followed by several "#user_intent#" nodes, then the value of the InfoItem is the value of the "intent" attribute of one of these "#user_intent#" nodes, which is American English (en-US)
- If a "user input" InfoItem (defined by the "#single_turn_interact#" or "#multi_turn_interact#" node) has "infoitem_options", the value of the InfoItem (maybe) is the content of these options, which is American English (en-US)
- If a "user input" InfoItem (defined by the "#single_turn_interact#" or "#multi_turn_interact#" node) has "infoitem_constraint" and the constraint limits the optional value of the InfoItem (which is American English en-US), then the value of InfoItem is also American English (en-US)