From: Suyeon Hwang Date: Mon, 17 Oct 2022 12:34:26 +0000 (+0900) Subject: Add label to object which has no text label X-Git-Tag: accepted/tizen/unified/20221121.163723~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73a80f7bdd1d09ff1f1ad7ca59680c48229bb0ac;p=platform%2Fcore%2Fuifw%2Fmmi-manager.git Add label to object which has no text label - 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 --- diff --git a/src/mmimgr/iu/CommandFinder.cpp b/src/mmimgr/iu/CommandFinder.cpp index f63ef34..4f16465 100644 --- a/src/mmimgr/iu/CommandFinder.cpp +++ b/src/mmimgr/iu/CommandFinder.cpp @@ -27,31 +27,25 @@ using namespace std; -CommandFinder::CommandFinder(std::string &text, std::list>& commands) : +CommandFinder::CommandFinder(std::string &text, int index, bool isIndex, std::list> &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>& 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; diff --git a/src/mmimgr/iu/CommandFinder.h b/src/mmimgr/iu/CommandFinder.h index dfa0c2c..d274df2 100644 --- a/src/mmimgr/iu/CommandFinder.h +++ b/src/mmimgr/iu/CommandFinder.h @@ -28,8 +28,7 @@ class CommandFinder { public: - CommandFinder(std::string &text, std::list> &__commands); - CommandFinder(int index, std::list> &__commands); + CommandFinder(std::string &text, int index, bool isIndex, std::list> &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 diff --git a/src/mmimgr/iu/CommandManager.cpp b/src/mmimgr/iu/CommandManager.cpp index f828022..3f75cf5 100644 --- a/src/mmimgr/iu/CommandManager.cpp +++ b/src/mmimgr/iu/CommandManager.cpp @@ -57,13 +57,7 @@ ClickableItem* CommandManager::findCommand(std::string &text, bool isIndex) return nullptr; } - unique_ptr finder; - if (isIndex) { - finder = make_unique(index, __commands); - } else { - finder = make_unique(text, __commands); - } - + auto finder = make_unique(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()); diff --git a/src/mmimgr/iu/VoiceTouchEngine.cpp b/src/mmimgr/iu/VoiceTouchEngine.cpp index d150312..f2d1cf9 100644 --- a/src/mmimgr/iu/VoiceTouchEngine.cpp +++ b/src/mmimgr/iu/VoiceTouchEngine.cpp @@ -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()); } } diff --git a/tests/iu/CommandFinder_unittests.cpp b/tests/iu/CommandFinder_unittests.cpp index 9ff9e5a..3c295b3 100644 --- a/tests/iu/CommandFinder_unittests.cpp +++ b/tests/iu/CommandFinder_unittests.cpp @@ -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();