Add label to object which has no text label 91/283791/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 17 Oct 2022 12:34:26 +0000 (21:34 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Thu, 3 Nov 2022 05:44:38 +0000 (14:44 +0900)
- Issue:
The utterance about number is not recognized in text label mode.

- Solution:
This patch adds label information for the objects which have no label
information. For these objects, mmi manager uses index information as
label information. Through this patch, number utterance in text label
mode is properly recognized. However, some utterance like '7번' can not
be recogntized yet.

Change-Id: I9fc025638a479d210f644dc5f47b12ed5f435ac3
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
src/mmimgr/iu/CommandFinder.cpp
src/mmimgr/iu/CommandFinder.h
src/mmimgr/iu/CommandManager.cpp
src/mmimgr/iu/VoiceTouchEngine.cpp
tests/iu/CommandFinder_unittests.cpp

index f63ef34..4f16465 100644 (file)
 
 using namespace std;
 
-CommandFinder::CommandFinder(std::string &text, std::list<std::shared_ptr<ClickableItem>>& commands) :
+CommandFinder::CommandFinder(std::string &text, int index, bool isIndex, std::list<std::shared_ptr<ClickableItem>> &commands) :
                __WORD_MATCHING_RATE(0.3), __CHAR_MATCHING_RATE(0.25), __MIN_WORD_SIZE(3), __commands(commands)
 {
-       _I("[CommandFinder] Initiate command searcher. text(%s)", text.c_str());
+       _I("[CommandFinder] Initiate command searcher. text(%s) index(%d), isIndex(%d)", text.c_str(), index, isIndex);
 
        __loweredText = StringUtil::makeLowerCase(text);
        __splitText = StringUtil::splitText(__loweredText, ' ');
 
-       __index = -1;
-       __isLabel = true;
-}
-
-CommandFinder::CommandFinder(int index, std::list<std::shared_ptr<ClickableItem>>& commands) :
-               __WORD_MATCHING_RATE(0.3), __CHAR_MATCHING_RATE(0.25), __MIN_WORD_SIZE(3), __commands(commands)
-{
-       _I("[CommandFinder] Initiate command searcher. index(%d)", index);
-
        __index = index;
-       __isLabel = false;
+       __isIndex = isIndex;
 }
 
 ClickableItem* CommandFinder::findCommand()
 {
        ClickableItem* result = nullptr;
-       if (__isLabel) {
+       if (__isIndex) {
+               _I("[CommandFinder] Find command by index. index(%d)", __index);
+               result = findCommandByIndex();
+       } else {
                _I("[CommandFinder] Find command by label text. text(%s)", __loweredText.c_str());
                result = findCommandByText();
                if (result != nullptr) {
@@ -67,9 +61,13 @@ ClickableItem* CommandFinder::findCommand()
                if (result != nullptr) {
                        return result;
                }
-       } else {
-               _I("[CommandFinder] Find command by index. index(%d)", __index);
+
+               _I("[CommandFinder] Fail to get command from text. Find command by index. index(%d)", __index);
                result = findCommandByIndex();
+               if (result == nullptr || result->label != to_string(result->index)) {
+                       _D("[CommandFinder] The result is null or not number label");
+                       return nullptr;
+               }
        }
 
        return result;
index dfa0c2c..d274df2 100644 (file)
@@ -28,8 +28,7 @@
 
 class CommandFinder {
        public:
-               CommandFinder(std::string &text, std::list<std::shared_ptr<ClickableItem>> &__commands);
-               CommandFinder(int index, std::list<std::shared_ptr<ClickableItem>> &__commands);
+               CommandFinder(std::string &text, int index, bool isIndex, std::list<std::shared_ptr<ClickableItem>> &commands);
 
                ClickableItem* findCommand();
 
@@ -50,7 +49,7 @@ class CommandFinder {
                std::string __loweredText;
                int __index;
 
-               bool __isLabel;
+               bool __isIndex;
 };
 
 #endif /* __TIZEN_UIX_MMI_IU_COMMAND_FINDER_H__ */
\ No newline at end of file
index f828022..3f75cf5 100644 (file)
@@ -57,13 +57,7 @@ ClickableItem* CommandManager::findCommand(std::string &text, bool isIndex)
                return nullptr;
        }
 
-       unique_ptr<CommandFinder> finder;
-       if (isIndex) {
-               finder = make_unique<CommandFinder>(index, __commands);
-       } else {
-               finder = make_unique<CommandFinder>(text, __commands);
-       }
-
+       auto finder = make_unique<CommandFinder>(text, index, isIndex, __commands);
        auto command = finder->findCommand();
        if (command != nullptr) {
                _I("[CommandManager] Find command. text(%s). command(%s)", text.c_str(), command->label.c_str());
index d150312..f2d1cf9 100644 (file)
@@ -454,12 +454,14 @@ void VoiceTouchEngine::makeClickableItemInfo(int timestamp, JsonProvider &provid
        }
 
        provider.setOutputEvent(MMI_KEY_UI_CLICKABLE_OBJECT);
-       provider.setUiClickableObject(resultType, tooltipType, __itemList.size(), timestamp);
+       provider.setUiClickableObject(resultType, tooltipType, itemList->size(), timestamp);
        provider.setGridDepth(__currentGridInfo.currentStep + 1);
 
        for (auto &item : *itemList) {
-               auto label = (item.label.empty() ? to_string(item.index) : item.label);
-               provider.addInfoClickableObject(item.index, item.coordX, item.coordY, item.width, item.height, label.c_str());
+               if (item.label.empty()) {
+                       item.label = to_string(item.index);
+               }
+               provider.addInfoClickableObject(item.index, item.coordX, item.coordY, item.width, item.height, item.label.c_str());
        }
 }
 
index 9ff9e5a..3c295b3 100644 (file)
@@ -70,20 +70,17 @@ class CommandFinderTest : public testing::Test {
 TEST_F(CommandFinderTest, utc_CommandFinder_Constructor)
 {
     string target = "test1";
-    auto finder1 = new(nothrow) CommandFinder(target, commands);
-    auto finder2 = new(nothrow) CommandFinder(1, commands);
+    auto finder = new(nothrow) CommandFinder(target, 1, false, commands);
 
-    EXPECT_NE(finder1, nullptr);
-    EXPECT_NE(finder2, nullptr);
+    EXPECT_NE(finder, nullptr);
 
-    delete finder1;
-    delete finder2;
+    delete finder;
 }
 
 TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p)
 {
     string target = "test1";
-    auto finder_p = new(nothrow) CommandFinder(target, commands);
+    auto finder_p = new(nothrow) CommandFinder(target, -1, false, commands);
     ASSERT_NE(finder_p, nullptr);
 
     auto command = finder_p->findCommand();
@@ -96,7 +93,7 @@ TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p)
 TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p2)
 {
     string target = "text1";
-    auto finder_p = new(nothrow) CommandFinder(target, commands);
+    auto finder_p = new(nothrow) CommandFinder(target, -1, false, commands);
     ASSERT_NE(finder_p, nullptr);
 
     auto command = finder_p->findCommand();
@@ -108,7 +105,8 @@ TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p2)
 
 TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p3)
 {
-    auto finder_p = new(nothrow) CommandFinder(1, commands);
+    string target = "";
+    auto finder_p = new(nothrow) CommandFinder(target, 1, true, commands);
     ASSERT_NE(finder_p, nullptr);
 
     auto command = finder_p->findCommand();
@@ -121,7 +119,7 @@ TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p3)
 TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_n)
 {
     string target = "no matched text";
-    auto finder_n = new(nothrow) CommandFinder(target, commands);
+    auto finder_n = new(nothrow) CommandFinder(target, -1, false, commands);
     ASSERT_NE(finder_n, nullptr);
 
     auto command = finder_n->findCommand();
@@ -132,7 +130,8 @@ TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_n)
 
 TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_n2)
 {
-    auto finder_n = new(nothrow) CommandFinder(-1, commands);
+    string target = "";
+    auto finder_n = new(nothrow) CommandFinder(target, -1, true, commands);
     ASSERT_NE(finder_n, nullptr);
 
     auto command = finder_n->findCommand();