diff --git a/AI/AIFunctionSet/README_en.md b/AI/AIFunctionSet/README_en.md
new file mode 100644
index 0000000000000000000000000000000000000000..092cb8289504127b1e596eb131d90d4f15182f58
--- /dev/null
+++ b/AI/AIFunctionSet/README_en.md
@@ -0,0 +1,32 @@
+# AI
+
+- HarmonyOSOpenHarmony provides abundant Artificial Intelligence \(AI\) capabilities that can be used out of the box. You can easily integrate these AI capabilities on demand to make your applications smarter. The AI capabilities are as follows:
+
+ \* QR code generation: Generates a quick response \(QR\) code image based on a given string and QR code image size and returns it through byte streams. The caller can then restore the QR code image from the QR code byte streams.
+
+ \* General text recognition: Converts scanned text on bills, cards, forms, newspapers, books, and other printed materials into image information, and then uses text recognition technologies to convert the image information into computable input.
+
+ \* Single image super-resolution \(SISR\): Provides 1x and 3x super-resolution capabilities for mobile devices. 1x SR processing removes the image compression noise, and 3x SR processing enlarges the side edge by three times while suppressing the compression noise.
+
+ \* Document skew detection and correction: Provides document skew detection and correction as an assisting enhancement in document duplicating.
+
+ \* Text-image super-resolution \(TISR\): Enlarges an image containing text by nine times \(three times the height and three times the width\) and enhances the definition of text in the image.
+
+ \* Word segmentation: Automatically segments input text into words at the specified granularity. You can change the granularity as required.
+
+ \* POS tagging: Automatically segments input text into words and attaches a correct part of speech \(POS\) tag to each word. You can define your own POS tagging granularity as required.
+
+ \* Assistant-specific intention recognition: Performs semantic analysis and intention recognition on text messages users send to devices, making devices smarter in various application scenarios.
+
+ \* IM-specific intention recognition: Uses the machine learning technology to analyze and recognize intentions of text messages, such as short messages or messages from IM applications.
+
+ \* Keyword extraction: Extracts the most relevant keywords from text. A keyword may be an entity with a specific meaning, such as a person name, a place, and a movie. It can also be a basic but critical word in the text.
+
+ \* Entity recognition: Extracts entities with specific meanings from natural languages and performs related operations \(such as searching\) based on the extracted entities.
+
+ \* Automatic speech recognition \(ASR\): Converts audio files and real-time audio data streams into Chinese character sequences at a recognition accuracy of over 90% \(95% for local recognition\).
+
+- Licensing
+
+For details, see the LICENSE.
+
diff --git a/AI/AIFunctionSet/README_zh.md b/AI/AIFunctionSet/README_zh.md
new file mode 100644
index 0000000000000000000000000000000000000000..131ca79eb869f5154974e93dd51f2efe66c3501e
--- /dev/null
+++ b/AI/AIFunctionSet/README_zh.md
@@ -0,0 +1,18 @@
+AI
+============
+为应用提供丰富的AI(Artificial Intelligence)能力,支持开箱即用。开发者可以灵活、便捷地选择AI能力,让应用变得更加智能。
+
+* 二维码生成: 根据开发者给定的字符串信息和二维码图片尺寸,返回相应的二维码图片字节流。调用方可以通过二维码字节流生成二维码图片。
+* 通用文字识别: 通过拍照、扫描等光学输入方式,把各种票据、卡证、表格、报刊、书籍等印刷品文字转化为图像信息,再利用文字识别技术将图像信息转化为计算机等设备可以使用的字符信息的技术。
+* 图像超分辨率: 提供适用于移动终端的1x和3x超分能力;1x超分可以去除图片的压缩噪声,3x超分在有效抑制压缩噪声的同时,提供3倍的边长放大能力。
+* 文档检测校正: 提供了文档翻拍过程的辅助增强功能,包含两个子功能:文档检测和文档校正。
+* 文字图像超分: 文字图像超分辨率可以对包含文字内容的图像进行9倍放大(高宽各放大3倍),同时增强图像内文字的清晰度,称为“文字图像超分辨率”,简称“文字图像超分”。
+* 分词: 对于一段输入文本,可以自动进行分词,同时提供不同的分词粒度。开发者可以根据需要自定义分词粒度。
+* 词性标注: 对于输入的一段文本,自动通过词性标注接口对其进行分词,并为分词结果中的每个单词标注一个正确的词性。词性标注提供不同的分词粒度,开发者可以根据需要自定义分词粒度。
+* 助手类意图识别: 对用户发送给设备的文本消息进行语义分析和意图识别,进而衍生出各种智能的应用场景,使设备更智慧、更智能。
+* IM类意图识别: 利用机器学习技术,针对用户短信或聊天类APP等IM应用的文本消息进行内容分析,并识别出消息内容代表的用户意图。
+* 关键字提取: 可以在大量信息中提取出文本想要表达的核心内容,可以是具有特定意义的实体,如:人名,地点,电影等。也可以是一些基础但是在文本中很关键的词汇。
+* 实体识别: 从自然语言中提取出具有特定意义的实体,并在此基础上完成搜索等一系列相关操作及功能。
+* 语音识别: 将语音文件、实时语音数据流转换为汉字序列,准确率达到90%以上(本地识别95%)。
+
+## Licensing
diff --git a/AI/AIFunctionSet/build.gradle b/AI/AIFunctionSet/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..dede97233a0367a47b29085b9cf491932a1674e0
--- /dev/null
+++ b/AI/AIFunctionSet/build.gradle
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
+buildscript {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.huawei.ohos:hap:2.4.4.2'
+ }
+}
+allprojects {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+}
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/build.gradle b/AI/AIFunctionSet/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..656369fc78e70ed49e04ddc78669669135d51545
--- /dev/null
+++ b/AI/AIFunctionSet/entry/build.gradle
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+apply plugin: 'com.huawei.ohos.hap'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+}
diff --git a/AI/AIFunctionSet/entry/src/main/config.json b/AI/AIFunctionSet/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..a8f0fd3fe5ece38be835218f7ae2b50111175b59
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/config.json
@@ -0,0 +1,71 @@
+{
+ "app": {
+ "bundleName": "ohos.samples.aifunctionset",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.samples.aifunctionset",
+ "name": ".MainAbility",
+ "reqCapabilities": [
+ "video_support"
+ ],
+ "deviceType": [
+ "default"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree":false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "portrait",
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.MICROPHONE"
+ },
+ {
+ "name": "ohos.permission.READ_CALENDAR"
+ },
+ {
+ "name": "ohos.permission.INTERNET"
+ },
+ {
+ "name": "ohos.permission.ACCESS_NETWORK_STATE"
+ },
+ {
+ "name": "ohos.permission.READ_USER_STORAGE"
+ },
+ {
+ "name": "ohos.permission.WRITE_USER_STORAGE"
+ },
+ {
+ "name": "ohos.permission.MANAGE_USER_STORAGE"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/MainAbility.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..fa9764176be4473ee90abc09eff8dbbfa2fdeca2
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/MainAbility.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset;
+
+import ohos.samples.aifunctionset.slice.AiMainSlice;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * MainAbility
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(AiMainSlice.class.getName());
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/bean/AsrBean.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/bean/AsrBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4a53aeee816fa9554f44b876f4667a3e7264d46
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/bean/AsrBean.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.bean;
+
+import java.util.List;
+
+/**
+ * AsrBean
+ */
+
+public class AsrBean {
+ private List result;
+
+ private String resultType;
+
+ public void setResult(List result) {
+ this.result = result;
+ }
+
+ public List getResult() {
+ return result;
+ }
+
+ public void setResultType(String resultType) {
+ this.resultType = resultType;
+ }
+
+ public String getResultType() {
+ return resultType;
+ }
+
+ /**
+ * Speech recognition result
+ */
+ public class Result {
+ private double confidence;
+
+ private String ori_word;
+
+ private String pinyin;
+
+ private String word;
+
+ public void setConfidence(double confidence) {
+ this.confidence = confidence;
+ }
+
+ public double getConfidence() {
+ return confidence;
+ }
+
+ public void setOriWord(String ori_word) {
+ this.ori_word = ori_word;
+ }
+
+ public String getOriWord() {
+ return ori_word;
+ }
+
+ public void setPinyin(String pinyin) {
+ this.pinyin = pinyin;
+ }
+
+ public String getPinyin() {
+ return pinyin;
+ }
+
+ public void setWord(String word) {
+ this.word = word;
+ }
+
+ public String getWord() {
+ return word;
+ }
+ }
+}
+
+
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/AiMainSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/AiMainSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..46d9efacaea6701d6813c07b0f86bed8b9642743
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/AiMainSlice.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.ComponentContainer;
+
+/**
+ * AiMainSlice
+ */
+public class AiMainSlice extends AbilitySlice {
+ private AbilitySlice[] sliceArray = {
+ new TextRecognitionSlice(), new ImageSuperResolutionSlice(), new DocumentCorrectionSlice(),
+ new QRCodeGenerationSlice(), new TextImageSuperResolutionSlice(), new WordSegmentationSlice(),
+ new PartOfSpeechTaggingSlice(), new AssistantIntentionRecognitionSlice(), new IMIntentRecognitionSlice(),
+ new KeywordExtractionSlice(), new EntityIdentificationSlice(), new SpeechRecognitionSlice(),
+ new TextToSpeechSlice()
+ };
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_main_slice);
+ }
+
+ @Override
+ protected void onActive() {
+ super.onActive();
+ ComponentContainer container = (ComponentContainer) findComponentById(ResourceTable.Id_rootLayout);
+ for (int i = 0; i < container.getChildCount(); i++) {
+ int index = i;
+ container.getComponentAt(i).setClickedListener(component -> present(sliceArray[index], new Intent()));
+ }
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/AssistantIntentionRecognitionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/AssistantIntentionRecognitionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..01d7f04d6262c3fcc41b8cfc3113fda1e8967dcb
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/AssistantIntentionRecognitionSlice.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.nlu.NluClient;
+import ohos.ai.nlu.NluRequestType;
+import ohos.ai.nlu.ResponseResult;
+import ohos.utils.zson.ZSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Assistant Intention Recognition Slice
+ */
+public class AssistantIntentionRecognitionSlice extends BaseSlice {
+ private TextField inputText;
+
+ private TextField outText;
+
+ private boolean initEngineResult;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_word_segmentation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+
+ initEngine();
+ initComponents();
+ }
+
+ private void initEngine() {
+ NluClient.getInstance().init(this, result -> initEngineResult = true, true);
+ }
+
+ private void initComponents() {
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ inputText.setText("Turn off bluetooth.");
+ }
+
+ private void start(Component component) {
+ Map map = new HashMap<>();
+ map.put("text", inputText.getText());
+ map.put("type", 0);
+ String requestJson = ZSONObject.toZSONString(map);
+ if (initEngineResult) {
+ ResponseResult responseResult = NluClient.getInstance()
+ .getAssistantIntention(requestJson, NluRequestType.REQUEST_TYPE_LOCAL);
+ if (responseResult != null) {
+ String result = responseResult.getResponseResult();
+ outText.setText("Result:" + System.lineSeparator() + result);
+ }
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Assistant Intention Recognition");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ NluClient.getInstance().destroy(this);
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/BaseSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/BaseSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..5037c0d91f6fe3c0863370db50420c50924eaad0
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/BaseSlice.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.aafwk.ability.AbilitySlice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.DirectionalLayout;
+import ohos.agp.components.Text;
+import ohos.agp.window.dialog.ToastDialog;
+
+/**
+ * Base Slice
+ */
+public abstract class BaseSlice extends AbilitySlice {
+ /**
+ * common baseSlice root layout
+ */
+ public DirectionalLayout rootLayout;
+
+ /**
+ * current slice layout
+ */
+ public Component currComponent;
+
+ /**
+ * slice title
+ */
+ public Text aiTitle;
+
+ /**
+ * slice desc
+ */
+ public Text aiDesc;
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_base_layout);
+
+ initCommons();
+ initLayout();
+ setTitle();
+ }
+
+ private void initCommons() {
+ rootLayout = (DirectionalLayout) findComponentById(ResourceTable.Id_root_layout);
+ aiTitle = (Text) findComponentById(ResourceTable.Id_title);
+ aiDesc = (Text) findComponentById(ResourceTable.Id_desc);
+ Component back = findComponentById(ResourceTable.Id_back);
+ back.setClickedListener(component -> terminate());
+ }
+
+ /**
+ * common toast method
+ *
+ * @param msg toast content
+ */
+ public void showTips(String msg) {
+ new ToastDialog(this).setContentText(msg).show();
+ }
+
+ /**
+ * init slice layout
+ */
+ public abstract void initLayout();
+
+ /**
+ * set slice title and desc
+ */
+ public abstract void setTitle();
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (currComponent != null) {
+ rootLayout.removeComponent(currComponent);
+ }
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/DocumentCorrectionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/DocumentCorrectionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..97581be19eedba4f4bb2795fd9d764f910f6c488
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/DocumentCorrectionSlice.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.utils.LogUtil;
+import ohos.samples.aifunctionset.utils.WidgetHelper;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.ai.cv.common.ConnectionCallback;
+import ohos.ai.cv.common.ImageResult;
+import ohos.ai.cv.common.VisionConfiguration;
+import ohos.ai.cv.common.VisionImage;
+import ohos.ai.cv.common.VisionManager;
+import ohos.ai.cv.docrefine.DocCoordinates;
+import ohos.ai.cv.docrefine.DocRefineConfiguration;
+import ohos.ai.cv.docrefine.IDocRefine;
+import ohos.media.image.PixelMap;
+
+/**
+ * Document Correction Slice
+ */
+public class DocumentCorrectionSlice extends BaseSlice {
+ private static final String IMAGE_PATH = "entry/resources/rawfile/doc_check.png";
+
+ private Image originalImage;
+
+ private Image outImage;
+
+ private IDocRefine docRefine;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_document_correction_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initComponents();
+ initEngine();
+ }
+
+ private void initComponents() {
+ originalImage = (Image) findComponentById(ResourceTable.Id_image);
+ outImage = (Image) findComponentById(ResourceTable.Id_out_image);
+ Component startButton = findComponentById(ResourceTable.Id_start);
+ startButton.setClickedListener(this::doSuperResolution);
+ originalImage.setPixelMap(WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH));
+ }
+
+ private void initEngine() {
+ int result = VisionManager.init(this, connectionCallback);
+ LogUtil.info(getLocalClassName(), "VisionManager.init result code : " + result);
+ }
+
+ private void doSuperResolution(Component component) {
+ docRefine = VisionManager.getDocRefine(this);
+ PixelMap pixelMap = WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH);
+
+ VisionImage image = VisionImage.fromPixelMap(pixelMap);
+ DocRefineConfiguration.Builder builder = new DocRefineConfiguration.Builder();
+ builder.setProcessMode(VisionConfiguration.MODE_IN);
+ DocRefineConfiguration configuration = builder.build();
+ docRefine.setVisionConfiguration(configuration);
+ ImageResult imageResult = new ImageResult();
+
+ DocCoordinates docCoordinates = new DocCoordinates();
+ docRefine.docDetect(image, docCoordinates, null);
+ int result = docRefine.docRefine(image, docCoordinates, imageResult, null);
+ showTips("DocDetect : " + (result == 0 ? "Succeeded " : "Failed code = " + result));
+ outImage.setPixelMap(imageResult.getPixelMap());
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Document Correction");
+ }
+
+ private ConnectionCallback connectionCallback = new ConnectionCallback() {
+ @Override
+ public void onServiceConnect() {
+ LogUtil.info(getLocalClassName(), "Service connect succeeded");
+ }
+
+ @Override
+ public void onServiceDisconnect() {
+ LogUtil.info(getLocalClassName(), "Service disconnect succeeded");
+ }
+ };
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (docRefine != null) {
+ docRefine.release();
+ }
+ VisionManager.destroy();
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/EntityIdentificationSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/EntityIdentificationSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..961319a6deabd2969b9b8502432aab5dcd1809cb
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/EntityIdentificationSlice.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.nlu.NluClient;
+import ohos.ai.nlu.NluRequestType;
+import ohos.ai.nlu.ResponseResult;
+import ohos.utils.zson.ZSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Entity Identification Slice
+ */
+public class EntityIdentificationSlice extends BaseSlice {
+ private TextField inputText;
+
+ private TextField outText;
+
+ private boolean initEngineResult;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_word_segmentation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initEngine();
+ initComponents();
+ }
+
+ private void initEngine() {
+ NluClient.getInstance().init(this, result -> initEngineResult = true, true);
+ }
+
+ private void initComponents() {
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ inputText.setText("I like the beach.");
+ }
+
+ private void start(Component component) {
+ Map map = new HashMap<>();
+ map.put("text", inputText.getText());
+ String requestJson = ZSONObject.toZSONString(map);
+ if (initEngineResult) {
+ ResponseResult responseResult = NluClient.getInstance()
+ .getEntity(requestJson, NluRequestType.REQUEST_TYPE_LOCAL);
+ if (responseResult != null) {
+ String result = responseResult.getResponseResult();
+ outText.setText("Result:" + System.lineSeparator() + result);
+ }
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Entity Identification");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ NluClient.getInstance().destroy(this);
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/IMIntentRecognitionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/IMIntentRecognitionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..32b048e96caf3a93ff3960ad2f5c1bffe864febd
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/IMIntentRecognitionSlice.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.nlu.NluClient;
+import ohos.ai.nlu.NluRequestType;
+import ohos.ai.nlu.ResponseResult;
+import ohos.utils.zson.ZSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * IM Intent Recognition Slice
+ */
+public class IMIntentRecognitionSlice extends BaseSlice {
+ private TextField inputText;
+
+ private Component startParse;
+
+ private TextField outText;
+
+ private boolean initEngineResult;
+
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_word_segmentation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+
+ initIMEngine();
+ initComponents();
+ }
+
+ private void initIMEngine() {
+ NluClient.getInstance().init(this, result -> initEngineResult = true, true);
+ }
+
+ private void initComponents() {
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ inputText.setText("Your personal credit card bill this month is $198.00, due date December 30.");
+ }
+
+ private void start(Component component) {
+ Map map = new HashMap<>();
+ map.put("text", inputText.getText());
+ String requestJson = ZSONObject.toZSONString(map);
+ if (initEngineResult) {
+ ResponseResult responseResult = NluClient.getInstance()
+ .getChatIntention(requestJson, NluRequestType.REQUEST_TYPE_LOCAL);
+ if (responseResult != null) {
+ String result = responseResult.getResponseResult();
+ outText.setText("Result:" + System.lineSeparator() + result);
+ }
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("IM Intent Recognition");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ NluClient.getInstance().destroy(this);
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/ImageSuperResolutionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/ImageSuperResolutionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..bd953b90b8aaf74ae82f8161ee021c368713d4c2
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/ImageSuperResolutionSlice.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.utils.LogUtil;
+import ohos.samples.aifunctionset.utils.WidgetHelper;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.ai.cv.common.ConnectionCallback;
+import ohos.ai.cv.common.ImageResult;
+import ohos.ai.cv.common.VisionConfiguration;
+import ohos.ai.cv.common.VisionImage;
+import ohos.ai.cv.common.VisionManager;
+import ohos.ai.cv.sr.IImageSuperResolution;
+import ohos.ai.cv.sr.SisrConfiguration;
+import ohos.media.image.PixelMap;
+
+/**
+ * Image Super Resolution Slice
+ */
+public class ImageSuperResolutionSlice extends BaseSlice {
+ private static final String IMAGE_PATH = "entry/resources/rawfile/super_image.png";
+
+ private Image originalImage;
+
+ private Image outImage;
+
+ private IImageSuperResolution imageSuperResolution;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_image_super_resolution_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initComponents();
+ initEngine();
+ }
+
+ private void initComponents() {
+ originalImage = (Image) findComponentById(ResourceTable.Id_image);
+ outImage = (Image) findComponentById(ResourceTable.Id_out_image);
+ Component startButton = findComponentById(ResourceTable.Id_start);
+ startButton.setClickedListener(this::doSuperResolution);
+ originalImage.setPixelMap(WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH));
+ }
+
+ private void initEngine() {
+ int result = VisionManager.init(this, connectionCallback);
+ LogUtil.info(getLocalClassName(), "VisionManager.init result code : " + result);
+ }
+
+ private void doSuperResolution(Component component) {
+ imageSuperResolution = VisionManager.getSisr(this);
+ SisrConfiguration.Builder builder = new SisrConfiguration.Builder();
+ builder.setProcessMode(VisionConfiguration.MODE_IN);
+ SisrConfiguration config = builder.build();
+ config.setScale(SisrConfiguration.SISR_SCALE_3X);
+ config.setQuality(SisrConfiguration.SISR_QUALITY_HIGH);
+ imageSuperResolution.setVisionConfiguration(config);
+
+ PixelMap pixelMap = WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH);
+ VisionImage image = VisionImage.fromPixelMap(pixelMap);
+ ImageResult imageResult = new ImageResult();
+ int result = imageSuperResolution.doSuperResolution(image, imageResult, null);
+ showTips("DoSuperResolution : " + (result == 0 ? "succeeded " : "failed code = " + result));
+ outImage.setPixelMap(imageResult.getPixelMap());
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Image Super Resolution");
+ }
+
+ private ConnectionCallback connectionCallback = new ConnectionCallback() {
+ @Override
+ public void onServiceConnect() {
+ LogUtil.info(getLocalClassName(), "Service connect succeeded");
+ }
+
+ @Override
+ public void onServiceDisconnect() {
+ LogUtil.info(getLocalClassName(), "Service disconnect succeeded");
+ }
+ };
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (imageSuperResolution != null) {
+ imageSuperResolution.release();
+ }
+ VisionManager.destroy();
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/KeywordExtractionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/KeywordExtractionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..19d64fc285b2428e5f94b2c04d842ff6bb8203d7
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/KeywordExtractionSlice.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.nlu.NluClient;
+import ohos.ai.nlu.NluRequestType;
+import ohos.ai.nlu.ResponseResult;
+import ohos.utils.zson.ZSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Keyword Extraction Slice
+ */
+public class KeywordExtractionSlice extends BaseSlice {
+ private TextField inputText;
+
+ private TextField outText;
+
+ private boolean initEngineResult;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_word_segmentation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+
+ initEngine();
+ initComponents();
+ }
+
+ private void initEngine() {
+ NluClient.getInstance().init(this, result -> initEngineResult = true, true);
+ }
+
+ private void initComponents() {
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ inputText.setText("Let's go to class together today.");
+ }
+
+ private void start(Component component) {
+ Map map = new HashMap<>();
+ map.put("number", "2");
+ map.put("body", inputText.getText());
+ String requestJson = ZSONObject.toZSONString(map);
+ if (initEngineResult) {
+ ResponseResult responseResult = NluClient.getInstance()
+ .getKeywords(requestJson, NluRequestType.REQUEST_TYPE_LOCAL);
+ if (responseResult != null) {
+ String result = responseResult.getResponseResult();
+ outText.setText("Result:" + System.lineSeparator() + result);
+ }
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Keyword Extraction");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ NluClient.getInstance().destroy(this);
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/PartOfSpeechTaggingSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/PartOfSpeechTaggingSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..ec84af31ca279bff5161a00a579c7e60542cab9e
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/PartOfSpeechTaggingSlice.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.nlu.NluClient;
+import ohos.ai.nlu.NluRequestType;
+import ohos.ai.nlu.ResponseResult;
+import ohos.utils.zson.ZSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Part Of Speech Tagging Slice
+ */
+public class PartOfSpeechTaggingSlice extends BaseSlice {
+ private TextField inputText;
+
+ private TextField outText;
+
+ private boolean initEngineResult;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_word_segmentation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+
+ initEngine();
+ initComponents();
+ }
+
+ private void initEngine() {
+ NluClient.getInstance().init(this, result -> initEngineResult = true, true);
+ }
+
+ private void initComponents() {
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ inputText.setText("I want to see a movie about speed and passion.");
+ }
+
+ private void start(Component component) {
+ Map map = new HashMap<>();
+ map.put("text", inputText.getText());
+ map.put("type", 0);
+ String requestJson = ZSONObject.toZSONString(map);
+ if (initEngineResult) {
+ ResponseResult responseResult = NluClient.getInstance()
+ .getWordPos(requestJson, NluRequestType.REQUEST_TYPE_LOCAL);
+ if (responseResult != null) {
+ String result = responseResult.getResponseResult();
+ outText.setText("Result:" + System.lineSeparator() + result);
+ }
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Part of Speech Tagging");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ NluClient.getInstance().destroy(this);
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/QRCodeGenerationSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/QRCodeGenerationSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..e6b85ea6220efe2f1a4180109ab401e33d883de5
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/QRCodeGenerationSlice.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.utils.LogUtil;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.ai.cv.common.ConnectionCallback;
+import ohos.ai.cv.common.VisionManager;
+import ohos.ai.cv.qrcode.IBarcodeDetector;
+import ohos.media.image.ImageSource;
+import ohos.media.image.PixelMap;
+
+/**
+ * QR Code Generation Slice
+ */
+public class QRCodeGenerationSlice extends BaseSlice {
+ private Image outImage;
+
+ private IBarcodeDetector barcodeDetector;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_qr_code_generation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initEngine();
+ initComponents();
+ }
+
+ private void initEngine() {
+ VisionManager.init(this, connectionCallback);
+ }
+
+ private void initComponents() {
+ outImage = (Image) findComponentById(ResourceTable.Id_out_image);
+ Component startButton = findComponentById(ResourceTable.Id_start);
+ startButton.setClickedListener(this::start);
+ }
+
+ private void start(Component component) {
+ barcodeDetector = VisionManager.getBarcodeDetector(this);
+ int length = 600;
+ byte[] byteArray = new byte[length * length * 4];
+ int result = barcodeDetector.detect("This is a TestCase of IBarcodeDetector", byteArray, length, length);
+ showTips("Detect : " + (result == 0 ? "Succeeded " : "Failed code = " + result));
+ if (result == 0) {
+ ImageSource.SourceOptions srcOpts = new ImageSource.SourceOptions();
+ srcOpts.formatHint = "image/png";
+ ImageSource imageSource = ImageSource.create(byteArray, srcOpts);
+ PixelMap pixelMap = imageSource.createPixelmap(null);
+ outImage.setPixelMap(pixelMap);
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("QRCode Generation");
+ }
+
+ private ConnectionCallback connectionCallback = new ConnectionCallback() {
+ @Override
+ public void onServiceConnect() {
+ LogUtil.info(getLocalClassName(), "Service connect succeeded");
+ }
+
+ @Override
+ public void onServiceDisconnect() {
+ LogUtil.info(getLocalClassName(), "Service disconnect succeeded");
+ }
+ };
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (barcodeDetector != null) {
+ barcodeDetector.release();
+ }
+ VisionManager.destroy();
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/SpeechRecognitionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/SpeechRecognitionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..da7a1ee7b3f102e2b8f3c1a9f05f72d3a3c9e681
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/SpeechRecognitionSlice.java
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.bean.AsrBean;
+import ohos.samples.aifunctionset.utils.LogUtil;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.asr.AsrClient;
+import ohos.ai.asr.AsrIntent;
+import ohos.ai.asr.AsrListener;
+import ohos.ai.asr.util.AsrResultKey;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
+import ohos.eventhandler.InnerEvent;
+import ohos.global.resource.RawFileEntry;
+import ohos.global.resource.Resource;
+import ohos.utils.PacMap;
+import ohos.utils.zson.ZSONException;
+import ohos.utils.zson.ZSONObject;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Speech Recognition Slice
+ */
+
+public class SpeechRecognitionSlice extends BaseSlice {
+ private static final String TAG = SpeechRecognitionSlice.class.getSimpleName();
+
+ private static final int EVENT_MSG_INIT = 0x1000001;
+
+ private static final int EVENT_MSG_PARSE_START = 0x1000002;
+
+ private static final int EVENT_MSG_PARSE_END = 0x1000003;
+
+ private static final int EVENT_MSG_ERROR = 0x1000004;
+
+ private static final int VALID_LENGTH = 1280;
+
+ private static final String RAW_AUDIO_WAV = "entry/resources/rawfile/asr_test.wav";
+
+ private static final String RAW_AUDIO_PCM = "entry/resources/rawfile/asr_date_conversion.pcm";
+
+ private AsrClient asrClient;
+
+ private TextField outText;
+
+ private String result;
+
+ private AsrIntent asrIntent;
+
+ private String wavCachePath;
+
+ private String pcmCachePath;
+
+ private EventHandler handler = new EventHandler(EventRunner.current()) {
+ @Override
+ protected void processEvent(InnerEvent event) {
+ switch (event.eventId) {
+ case EVENT_MSG_INIT:
+ showTips("InitAIEngine Success");
+ break;
+ case EVENT_MSG_PARSE_START:
+ outText.setText("Doing now, please wait a moment ...");
+ break;
+ case EVENT_MSG_PARSE_END:
+ parseJson();
+ break;
+ case EVENT_MSG_ERROR:
+ showTips(result);
+ break;
+ }
+ }
+ };
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_speech_recognition_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initData();
+ initComponents();
+ initAIEngine();
+ }
+
+ private void initData() {
+ wavCachePath = new File(getFilesDir(), "asr_test.wav").getPath();
+ pcmCachePath = new File(getFilesDir(), "asr_date_conversion.pcm").getPath();
+ writeToDisk(RAW_AUDIO_WAV, wavCachePath);
+ writeToDisk(RAW_AUDIO_PCM, pcmCachePath);
+ }
+
+ private void initComponents() {
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ }
+
+ private void start(Component component) {
+ showTips("start parse ...");
+ asrClient.startListening(new AsrIntent());
+ File file = new File(wavCachePath);
+ if (!file.exists()) {
+ return;
+ }
+ int initialSize = new Long(file.length()).intValue();
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream(initialSize);
+ BufferedInputStream in = new BufferedInputStream(new FileInputStream(file))) {
+ byte[] buffer = new byte[VALID_LENGTH];
+ int len;
+ while (true) {
+ len = in.read(buffer, 0, VALID_LENGTH);
+ if (len == -1) {
+ break;
+ }
+ bos.reset();
+ bos.write(buffer, 0, len);
+ asrClient.writePcm(bos.toByteArray(), VALID_LENGTH);
+ }
+ } catch (IOException e) {
+ LogUtil.error(TAG, "startParse : IOException ");
+ }
+ }
+
+ private void initAIEngine() {
+ asrClient = AsrClient.createAsrClient(this).orElse(null);
+ if (asrClient != null) {
+ asrIntent = new AsrIntent();
+ useDefaultAsrIntent(asrIntent);
+ asrIntent.setAudioSourceType(AsrIntent.AsrAudioSrcType.ASR_SRC_TYPE_PCM);
+ asrClient.init(asrIntent, asrListener);
+ }
+ }
+
+ private void useDefaultAsrIntent(AsrIntent asrIntent) {
+ asrIntent.setVadEndWaitMs(2000);
+ asrIntent.setVadFrontWaitMs(4800);
+ asrIntent.setTimeoutThresholdMs(20000);
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Speech Recognition");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ release();
+ }
+
+ private void parseJson() {
+ try {
+ AsrBean asrBean = ZSONObject.stringToClass(result, AsrBean.class);
+ if (asrBean != null && asrBean.getResult().size() > 0) {
+ AsrBean.Result resultContent = asrBean.getResult().get(0);
+ outText.setText("Result:" + System.lineSeparator() + resultContent.getWord());
+ }
+ } catch (ZSONException e) {
+ LogUtil.error(TAG, "parseJson ZSONException");
+ }
+ }
+
+ private AsrListener asrListener = new AsrListener() {
+ @Override
+ public void onInit(PacMap pacMap) {
+ result = pacMap.getString(AsrResultKey.RESULTS_RECOGNITION);
+ handler.sendEvent(EVENT_MSG_INIT);
+ }
+
+ @Override
+ public void onBeginningOfSpeech() {
+ LogUtil.info(TAG, "onBeginningOfSpeech");
+ }
+
+ @Override
+ public void onRmsChanged(float value) {
+ LogUtil.info(TAG, "onRmsChanged :" + value);
+ }
+
+ @Override
+ public void onBufferReceived(byte[] bytes) {
+ LogUtil.info(TAG, "onRmsChanged :" + bytes.toString());
+ }
+
+ @Override
+ public void onEndOfSpeech() {
+ LogUtil.info(TAG, "onEndOfSpeech ");
+ }
+
+ @Override
+ public void onError(int errorCode) {
+ result = "onError code :" + errorCode;
+ handler.sendEvent(EVENT_MSG_ERROR);
+ }
+
+ @Override
+ public void onResults(PacMap pacMap) {
+ LogUtil.info(TAG, "onResults :" + result);
+ result = pacMap.getString(AsrResultKey.RESULTS_RECOGNITION);
+ handler.sendEvent(EVENT_MSG_PARSE_END);
+ }
+
+ @Override
+ public void onIntermediateResults(PacMap pacMap) {
+ LogUtil.info(TAG, "onIntermediateResults :" + result);
+ result = pacMap.getString(AsrResultKey.RESULTS_RECOGNITION);
+ handler.sendEvent(EVENT_MSG_PARSE_END);
+ }
+
+ @Override
+ public void onEnd() {
+ LogUtil.info(TAG, "onEnd");
+ }
+
+ @Override
+ public void onEvent(int i, PacMap pacMap) {
+ LogUtil.info(TAG, "onEvent");
+ }
+
+ @Override
+ public void onAudioStart() {
+ LogUtil.info(TAG, "onAudioStart");
+ handler.sendEvent(EVENT_MSG_PARSE_START);
+ }
+
+ @Override
+ public void onAudioEnd() {
+ LogUtil.info(TAG, "onAudioEnd");
+ }
+ };
+
+ private void release() {
+ if (asrClient != null) {
+ asrClient.stopListening();
+ asrClient.cancel();
+ asrClient.destroy();
+ }
+ }
+
+ private void writeToDisk(String rawFilePathString, String targetFilePath) {
+ File file = new File(targetFilePath);
+ if (file.exists()) {
+ return;
+ }
+ RawFileEntry rawFileEntry = getResourceManager().getRawFileEntry(rawFilePathString);
+ try (FileOutputStream output = new FileOutputStream(new File(targetFilePath))) {
+ Resource resource = rawFileEntry.openRawFile();
+ byte[] cache = new byte[1024];
+ int len = resource.read(cache);
+ while (len != -1) {
+ output.write(cache, 0, len);
+ len = resource.read(cache);
+ }
+ } catch (IOException e) {
+ LogUtil.error(TAG, "writeToDisk IOException");
+ }
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextImageSuperResolutionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextImageSuperResolutionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..91c2a12d32bfcc3d0acbfa1b06924751fb46c1ca
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextImageSuperResolutionSlice.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.utils.LogUtil;
+import ohos.samples.aifunctionset.utils.WidgetHelper;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.ai.cv.common.ConnectionCallback;
+import ohos.ai.cv.common.ImageResult;
+import ohos.ai.cv.common.VisionConfiguration;
+import ohos.ai.cv.common.VisionImage;
+import ohos.ai.cv.common.VisionManager;
+import ohos.ai.cv.sr.ITxtImageSuperResolution;
+import ohos.ai.cv.sr.TxtImageSuperResolutionConfiguration;
+import ohos.media.image.PixelMap;
+
+/**
+ * Text Image Super Resolution Slice
+ */
+public class TextImageSuperResolutionSlice extends BaseSlice {
+ private static final String IMAGE_PATH = "entry/resources/rawfile/super_text.png";
+
+ private Image originalImage;
+
+ private Image outImage;
+
+ private ITxtImageSuperResolution txtImageSuperResolution;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_text_image_superresolution_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initComponents();
+ initHiAIEngine();
+ }
+
+ private void initComponents() {
+ originalImage = (Image) findComponentById(ResourceTable.Id_image);
+ outImage = (Image) findComponentById(ResourceTable.Id_out_image);
+ Component startButton = findComponentById(ResourceTable.Id_start);
+ startButton.setClickedListener(this::doSuperResolution);
+ originalImage.setPixelMap(WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH));
+ }
+
+ private void initHiAIEngine() {
+ int result = VisionManager.init(this, connectionCallback);
+ LogUtil.info(getLocalClassName(), "VisionManager.init result code : " + result);
+ }
+
+ private void doSuperResolution(Component component) {
+ txtImageSuperResolution = VisionManager.getTisr(this);
+ PixelMap pixelMap = WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH);
+
+ VisionImage image = VisionImage.fromPixelMap(pixelMap);
+ TxtImageSuperResolutionConfiguration.Builder builder = new TxtImageSuperResolutionConfiguration.Builder();
+ builder.setProcessMode(VisionConfiguration.MODE_IN);
+ TxtImageSuperResolutionConfiguration paras = builder.build();
+ txtImageSuperResolution.setVisionConfiguration(paras);
+
+ ImageResult imageResult = new ImageResult();
+ int result = txtImageSuperResolution.doSuperResolution(image, imageResult, null);
+ showTips("DoSuperResolution : " + (result == 0 ? "Succeeded " : "Failed code = " + result));
+ outImage.setPixelMap(imageResult.getPixelMap());
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Text Image Super Resolution");
+ }
+
+ private ConnectionCallback connectionCallback = new ConnectionCallback() {
+ @Override
+ public void onServiceConnect() {
+ LogUtil.info(getLocalClassName(), "Service connect succeeded");
+ }
+
+ @Override
+ public void onServiceDisconnect() {
+ LogUtil.info(getLocalClassName(), "Service disconnect succeeded");
+ }
+ };
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (txtImageSuperResolution != null) {
+ txtImageSuperResolution.release();
+ }
+ VisionManager.destroy();
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextRecognitionSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextRecognitionSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..41ce9f80f8bba503386d74ebbf31dc225b08ca6e
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextRecognitionSlice.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.utils.LogUtil;
+import ohos.samples.aifunctionset.utils.WidgetHelper;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.cv.common.ConnectionCallback;
+import ohos.ai.cv.common.VisionConfiguration;
+import ohos.ai.cv.common.VisionImage;
+import ohos.ai.cv.common.VisionManager;
+import ohos.ai.cv.text.ITextDetector;
+import ohos.ai.cv.text.Text;
+import ohos.ai.cv.text.TextConfiguration;
+import ohos.ai.cv.text.TextDetectType;
+import ohos.media.image.PixelMap;
+
+/**
+ * Text Recognition Slice
+ */
+public class TextRecognitionSlice extends BaseSlice {
+ private static final String IMAGE_PATH = "entry/resources/rawfile/text_recognition.png";
+
+ private Image originalImage;
+
+ private TextField outText;
+
+ private ITextDetector textDetector;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_text_recognition_slice, null, false);
+ rootLayout.addComponent(currComponent);
+ initComponents();
+ initEngine();
+ }
+
+ private void initComponents() {
+ originalImage = (Image) findComponentById(ResourceTable.Id_image);
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ Component startButton = findComponentById(ResourceTable.Id_start);
+ startButton.setClickedListener(this::doSuperResolution);
+ originalImage.setPixelMap(WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH));
+ }
+
+ private void initEngine() {
+ int result = VisionManager.init(this, connectionCallback);
+ LogUtil.info(getLocalClassName(), "VisionManager.init result code : " + result);
+ }
+
+ private void doSuperResolution(Component component) {
+ textDetector = VisionManager.getTextDetector(this);
+ TextConfiguration.Builder builder = new TextConfiguration.Builder();
+ builder.setProcessMode(VisionConfiguration.MODE_IN);
+ builder.setLanguage(TextConfiguration.ENGLISH);
+ TextConfiguration config = builder.build();
+
+ textDetector.setVisionConfiguration(config);
+ PixelMap pixelMap = WidgetHelper.getPixelMapFromRaw(this, IMAGE_PATH);
+ VisionImage image = VisionImage.fromPixelMap(pixelMap);
+ Text text = new Text();
+ int result = textDetector.detect(image, text, null);
+ showTips("Text Detect : " + (result == 0 ? "Succeeded " : "Failed code = " + result));
+ this.outText.setText("Result:" + System.lineSeparator() + text.getValue());
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Text Recognition");
+ }
+
+ private ConnectionCallback connectionCallback = new ConnectionCallback() {
+ @Override
+ public void onServiceConnect() {
+ LogUtil.info(getLocalClassName(), "Service connect succeeded");
+ }
+
+ @Override
+ public void onServiceDisconnect() {
+ LogUtil.info(getLocalClassName(), "Service disconnect succeeded");
+ }
+ };
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (textDetector != null) {
+ textDetector.release();
+ }
+ VisionManager.destroy();
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextToSpeechSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextToSpeechSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e891d4806032ddf37a42143d95e2252ca507f92
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/TextToSpeechSlice.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+import ohos.samples.aifunctionset.utils.LogUtil;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.tts.TtsClient;
+import ohos.ai.tts.TtsListener;
+import ohos.ai.tts.TtsParams;
+import ohos.ai.tts.constants.TtsEvent;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
+import ohos.eventhandler.InnerEvent;
+import ohos.utils.PacMap;
+
+import java.util.UUID;
+
+/**
+ * Text To Speech Slice
+ */
+public class TextToSpeechSlice extends BaseSlice {
+ private static final String TAG = SpeechRecognitionSlice.class.getSimpleName();
+
+ private static final int EVENT_MSG_INIT = 0x1000001;
+
+ private boolean initItsResult;
+
+ private TextField inputText;
+
+ private EventHandler handler = new EventHandler(EventRunner.current()) {
+ @Override
+ protected void processEvent(InnerEvent event) {
+ initTTSEngine();
+ }
+ };
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_text_to_speech_slice, null, false);
+ rootLayout.addComponent(currComponent);
+
+ initTTSEngine();
+ initComponents();
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Text To Speech");
+ }
+
+ private void initComponents() {
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ Component startPlay = findComponentById(ResourceTable.Id_start_play);
+ startPlay.setClickedListener(this::startPlay);
+ }
+
+ private void startPlay(Component component) {
+ if (initItsResult) {
+ TtsClient.getInstance().speakText(inputText.getText(), null);
+ } else {
+ showTips("InitTTSEngine Failed");
+ }
+ }
+
+ private void initTTSEngine() {
+ TtsClient.getInstance().create(this, ttsListener);
+ TtsParams ttsParams = new TtsParams();
+ ttsParams.setDeviceId(UUID.randomUUID().toString());
+ initItsResult = TtsClient.getInstance().init(ttsParams);
+ if (initItsResult) {
+ showTips("InitTTSEngine Succeeded");
+ } else {
+ handler.sendEvent(EVENT_MSG_INIT, 1000);
+ }
+ }
+
+ private TtsListener ttsListener = new TtsListener() {
+ @Override
+ public void onEvent(int eventType, PacMap pacMap) {
+ if (eventType == TtsEvent.CREATE_TTS_CLIENT_SUCCESS) {
+ LogUtil.info(TAG, "TTS Client create succeeded");
+ }
+ }
+
+ @Override
+ public void onStart(String utteranceId) {
+ LogUtil.info(TAG, utteranceId + " audio synthesis begins");
+ }
+
+ @Override
+ public void onProgress(String utteranceId, byte[] audioData, int progress) {
+ LogUtil.info(TAG, utteranceId + " audio synthesis progress:" + progress);
+ }
+
+ @Override
+ public void onFinish(String utteranceId) {
+ LogUtil.info(TAG, utteranceId + " audio synthesis completed");
+ }
+
+ @Override
+ public void onSpeechStart(String utteranceId) {
+ LogUtil.info(TAG, utteranceId + " begins to speech");
+ }
+
+ @Override
+ public void onSpeechProgressChanged(String utteranceId, int progress) {
+ LogUtil.info(TAG, utteranceId + " speech progress:" + progress);
+ }
+
+ @Override
+ public void onSpeechFinish(String utteranceId) {
+ LogUtil.info(TAG, utteranceId + " speech completed");
+ }
+
+ @Override
+ public void onError(String utteranceId, String errorMessage) {
+ LogUtil.info(TAG, utteranceId + " errorMessage: " + errorMessage);
+ }
+ };
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/WordSegmentationSlice.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/WordSegmentationSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8d7e887d5b6f54729e1beebb9abfe16e0c0101d
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/slice/WordSegmentationSlice.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.slice;
+
+import ohos.samples.aifunctionset.ResourceTable;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.TextField;
+import ohos.ai.nlu.NluClient;
+import ohos.ai.nlu.NluRequestType;
+import ohos.ai.nlu.ResponseResult;
+import ohos.utils.zson.ZSONObject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Word Segmentation Slice
+ */
+public class WordSegmentationSlice extends BaseSlice {
+ private TextField inputText;
+
+ private TextField outText;
+
+ private boolean initEngineResult;
+
+ @Override
+ public void initLayout() {
+ currComponent = LayoutScatter.getInstance(this)
+ .parse(ResourceTable.Layout_word_segmentation_slice, null, false);
+ rootLayout.addComponent(currComponent);
+
+ initEngine();
+ initComponents();
+ }
+
+ private void initEngine() {
+ NluClient.getInstance().init(this, result -> initEngineResult = true, true);
+ }
+
+ private void initComponents() {
+ outText = (TextField) findComponentById(ResourceTable.Id_out_text);
+ inputText = (TextField) findComponentById(ResourceTable.Id_input_text);
+ Component startButton = findComponentById(ResourceTable.Id_start_parse);
+ startButton.setClickedListener(this::start);
+ inputText.setText("It's a nice day. Let's go to the movies.");
+ }
+
+ private void start(Component component) {
+ Map map = new HashMap<>();
+ map.put("text", inputText.getText());
+ map.put("type", 0);
+ String requestJson = ZSONObject.toZSONString(map);
+ if (initEngineResult) {
+ ResponseResult responseResult = NluClient.getInstance()
+ .getWordSegment(requestJson, NluRequestType.REQUEST_TYPE_LOCAL);
+ if (responseResult != null) {
+ String result = responseResult.getResponseResult();
+ outText.setText("Result:" + System.lineSeparator() + result);
+ }
+ }
+ }
+
+ @Override
+ public void setTitle() {
+ aiTitle.setText("Word Segmentation");
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ NluClient.getInstance().destroy(this);
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/utils/LogUtil.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/utils/LogUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..cb18877cdd75f0851af1063527f6722b534ae2a9
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/utils/LogUtil.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.utils;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+import java.util.Locale;
+
+/**
+ * LogUtil
+ */
+public class LogUtil {
+ private static final String TAG_LOG = "AI ";
+
+ private static final int DOMAIN_ID = 0xD000F00;
+
+ private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, DOMAIN_ID, LogUtil.TAG_LOG);
+
+ private static final String LOG_FORMAT = "%s: %s";
+
+ private LogUtil() {
+ /* Do nothing */
+ }
+
+ /**
+ * Print info log
+ *
+ * @param tag log tag
+ * @param msg log message
+ */
+ public static void info(String tag, String msg) {
+ HiLog.info(LABEL_LOG, String.format(Locale.ROOT, LOG_FORMAT, tag, msg));
+ }
+
+ /**
+ * Print error log
+ *
+ * @param tag log tag
+ * @param msg log message
+ */
+ public static void error(String tag, String msg) {
+ HiLog.error(LABEL_LOG, String.format(Locale.ROOT, LOG_FORMAT, tag, msg));
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/utils/WidgetHelper.java b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/utils/WidgetHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..b7cc2333a0e19f197a315b7e2a7c68748390101c
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/java/ohos/samples/aifunctionset/utils/WidgetHelper.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.aifunctionset.utils;
+
+import ohos.app.Context;
+import ohos.global.resource.RawFileEntry;
+import ohos.global.resource.Resource;
+import ohos.media.image.ImageSource;
+import ohos.media.image.PixelMap;
+
+import java.io.IOException;
+
+/**
+ * Widget helper
+ *
+ */
+public final class WidgetHelper {
+ /**
+ * Rawfile to PixelMap
+ *
+ * @param context app context
+ * @param path copy file's path
+ * @return PixelMap pixelMap
+ */
+ public static PixelMap getPixelMapFromRaw(Context context, String path) {
+ PixelMap pixelMap = null;
+ try {
+ RawFileEntry rawFileEntry = context.getResourceManager().getRawFileEntry(path);
+ Resource resource = rawFileEntry.openRawFile();
+ ImageSource imageSource = ImageSource.create(resource, new ImageSource.SourceOptions());
+ pixelMap = imageSource.createPixelmap(null);
+ } catch (IOException e) {
+ LogUtil.error("getPixelMapFromRaw", "IOException :" + e.toString());
+ }
+ return pixelMap;
+ }
+}
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/element/string.json b/AI/AIFunctionSet/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..cb51c43fe4379ea18e6cdb15d45b362386ed5852
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AIFunctionSet"
+ },
+ {
+ "name": "mainability_description",
+ "value": "hap sample empty page"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/graphic/background_ability_main.xml b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/graphic/button_bg.xml b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/button_bg.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f4a98035344fc8f1a3211c66ec8098eb24fdaf66
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/button_bg.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/graphic/text_bg.xml b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/text_bg.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b428e6b4f47cf21e596368de884fe52d98ba90a6
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/text_bg.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/graphic/textfield_bg.xml b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/textfield_bg.xml
new file mode 100644
index 0000000000000000000000000000000000000000..32ba5fbe5cf260dd4fac82f3d051098e6ddc8b38
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/graphic/textfield_bg.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/ability_main.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..fd19d6d82966e8bd9d3bf43cdd98ba5b9c985437
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/base_layout.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/base_layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d598502a7817c48c38cf77e1df10d25e897b7a64
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/base_layout.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/document_correction_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/document_correction_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3aaf67d5edf0c29b140015fabda0f4d707985231
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/document_correction_slice.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/image_super_resolution_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/image_super_resolution_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e5d7eb134ae4ce2dfacf2cd8e0c0bd270efddeee
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/image_super_resolution_slice.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/main_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/main_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7db9500e463c5fa9f83f10b89ddf3285282923b1
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/main_slice.xml
@@ -0,0 +1,296 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/qr_code_generation_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/qr_code_generation_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1ce0bed369e2c12f5bf9500146ef96bc34a1ce62
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/qr_code_generation_slice.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/speech_recognition_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/speech_recognition_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..58f526e42ea85a3378f136adb101992a4cd6e691
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/speech_recognition_slice.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_image_superresolution_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_image_superresolution_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2da2f04b1941c235728d0533e36f24217a3272d1
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_image_superresolution_slice.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_recognition_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_recognition_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..642136719cf5812ebb18fca2112dbe0fc6813649
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_recognition_slice.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_to_speech_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_to_speech_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c78495007138dac65f6804e2797a74423cd7e4e0
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/text_to_speech_slice.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/layout/word_segmentation_slice.xml b/AI/AIFunctionSet/entry/src/main/resources/base/layout/word_segmentation_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f44ffe19db293bb3c9914752dec07f83393714ef
--- /dev/null
+++ b/AI/AIFunctionSet/entry/src/main/resources/base/layout/word_segmentation_slice.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/media/ic_arrow_right.png b/AI/AIFunctionSet/entry/src/main/resources/base/media/ic_arrow_right.png
new file mode 100644
index 0000000000000000000000000000000000000000..59e279b4040841ce540e4d441ced4a6ad0d71d3e
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/base/media/ic_arrow_right.png differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/media/ic_back.png b/AI/AIFunctionSet/entry/src/main/resources/base/media/ic_back.png
new file mode 100644
index 0000000000000000000000000000000000000000..f6b9cad2b03691236f146deebdfacaa2fd40c74d
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/base/media/ic_back.png differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/base/media/icon.png b/AI/AIFunctionSet/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/base/media/icon.png differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/rawfile/asr_date_conversion.pcm b/AI/AIFunctionSet/entry/src/main/resources/rawfile/asr_date_conversion.pcm
new file mode 100644
index 0000000000000000000000000000000000000000..f0ae899da39cbfa22a7bd83c1ce884c0f32ce281
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/rawfile/asr_date_conversion.pcm differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/rawfile/asr_test.wav b/AI/AIFunctionSet/entry/src/main/resources/rawfile/asr_test.wav
new file mode 100644
index 0000000000000000000000000000000000000000..f6e19b9e1218bba112dcce592ed874f55b980c83
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/rawfile/asr_test.wav differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/rawfile/doc_check.png b/AI/AIFunctionSet/entry/src/main/resources/rawfile/doc_check.png
new file mode 100644
index 0000000000000000000000000000000000000000..894b45b383b7eda41d67a6d52f37458194795254
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/rawfile/doc_check.png differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/rawfile/super_image.png b/AI/AIFunctionSet/entry/src/main/resources/rawfile/super_image.png
new file mode 100644
index 0000000000000000000000000000000000000000..d807740ac4d9039d1e325ddbeb8beb91e0c5c70a
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/rawfile/super_image.png differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/rawfile/super_text.png b/AI/AIFunctionSet/entry/src/main/resources/rawfile/super_text.png
new file mode 100644
index 0000000000000000000000000000000000000000..4551ba68e81c152c8f509cba56a99d036ee01ead
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/rawfile/super_text.png differ
diff --git a/AI/AIFunctionSet/entry/src/main/resources/rawfile/text_recognition.png b/AI/AIFunctionSet/entry/src/main/resources/rawfile/text_recognition.png
new file mode 100644
index 0000000000000000000000000000000000000000..2fc6f43af268e77f50c873d99b42d855ed4daeba
Binary files /dev/null and b/AI/AIFunctionSet/entry/src/main/resources/rawfile/text_recognition.png differ
diff --git a/AI/AIFunctionSet/screenshots/phone/main.png b/AI/AIFunctionSet/screenshots/phone/main.png
new file mode 100644
index 0000000000000000000000000000000000000000..82735558f7969b50f1ff2ec7b9476c2c09193c13
Binary files /dev/null and b/AI/AIFunctionSet/screenshots/phone/main.png differ
diff --git a/AI/AIFunctionSet/settings.gradle b/AI/AIFunctionSet/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..7dc3285c045cc590e49d231a4280ef52ba646d91
--- /dev/null
+++ b/AI/AIFunctionSet/settings.gradle
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+include ':entry'