int width;
int height;
- int objectId;
+ std::string objectId;
std::string label;
int index;
};
+++ /dev/null
-/*
-* Copyright © 2022 Samsung Electronics co., Ltd. All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-
-#include "Command.h"
-
-Command::Command(ClickableItem item)
-{
- __item = item;
-}
-
-ClickableItem Command::getItem()
-{
- return __item;
-}
-
-std::string Command::getLabel()
-{
- return __item.label;
-}
-
-int Command::getIndex()
-{
- return __item.index;
-}
+++ /dev/null
-/*
-* Copyright © 2022 Samsung Electronics co., Ltd. All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-
-#ifndef __TIZEN_UIX_MMI_IU_COMMAND_H__
-#define __TIZEN_UIX_MMI_IU_COMMAND_H__
-
-#include <string>
-#include "ClickableItem.h"
-
-class Command {
- public:
- Command(ClickableItem item);
-
- ClickableItem getItem();
- std::string getLabel();
- int getIndex();
-
- private:
- ClickableItem __item;
-};
-
-#endif /* __TIZEN_UIX_MMI_IU_COMMAND_H__ */
\ No newline at end of file
using namespace std;
-CommandFinder::CommandFinder(std::string text, std::list<std::shared_ptr<Command>>& commands) :
- __WORD_MATCHING_RATE(0.3), __CHAR_MATCHING_RATE(0.25), __commands(commands)
+CommandFinder::CommandFinder(std::string text, 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());
__loweredText = StringUtil::makeLowerCase(text);
__splitText = StringUtil::splitText(__loweredText, ' ');
+ __index = -1;
__isLabel = true;
}
-CommandFinder::CommandFinder(int index, std::list<std::shared_ptr<Command>>& commands) :
- __WORD_MATCHING_RATE(0.3), __CHAR_MATCHING_RATE(0.25), __commands(commands)
+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;
}
-Command* CommandFinder::findCommand()
+ClickableItem* CommandFinder::findCommand()
{
- Command* result = nullptr;
+ ClickableItem* result = nullptr;
if (__isLabel) {
_I("[CommandFinder] Finde command by label text. text(%s)", __loweredText.c_str());
result = findCommandByText();
}
-Command* CommandFinder::findCommandByIndex()
+ClickableItem* CommandFinder::findCommandByIndex()
{
_I("[CommandFinder] Find command by index (%d)", __index);
}
for (auto command : __commands) {
- if (command->getIndex() == __index) {
+ if (command->index == __index) {
return command.get();
}
}
return nullptr;
}
-Command* CommandFinder::findCommandByText()
+ClickableItem* CommandFinder::findCommandByText()
{
_I("[CommandFinder] Find command by text");
for (auto command : __commands) {
- string label = StringUtil::makeLowerCase(command->getLabel());
+ string label = StringUtil::makeLowerCase(command->label);
bool isValid = true;
for (auto& word : __splitText) {
return nullptr;
}
-Command* CommandFinder::findCommandByWord()
+ClickableItem* CommandFinder::findCommandByWord()
{
_I("[CommandFinder] Find command by word");
int maxNumber = __splitText.size() * __WORD_MATCHING_RATE;
- Command* result = nullptr;
+ ClickableItem* result = nullptr;
for (auto command : __commands) {
- string label = StringUtil::makeLowerCase(command->getLabel());
+ string label = StringUtil::makeLowerCase(command->label);
int numOfWord = 0;
for (auto& word : __splitText) {
return result;
}
-Command* CommandFinder::findCommandByChar()
+ClickableItem* CommandFinder::findCommandByChar()
{
_I("[CommandFinder] Find command by word");
- Command* result = nullptr;
+ ClickableItem* result = nullptr;
int resultScore = numeric_limits<int>::max();
for (auto command : __commands) {
- string label = StringUtil::makeLowerCase(command->getLabel());
+ string label = StringUtil::makeLowerCase(command->label);
vector<string> splitLabel = StringUtil::splitText(label, ' ');
int score = 0;
for (auto& word : __splitText) {
- if (word.size() < 3) {
+ if (word.size() < __MIN_WORD_SIZE) {
continue;
}
const int __MIN_THRESHOLD = word.size() * __CHAR_MATCHING_RATE;
int minScore = __MIN_THRESHOLD;
for (auto& labelWord : splitLabel) {
- if (labelWord.size() < 3) {
+ if (labelWord.size() < __MIN_WORD_SIZE) {
continue;
}
int threshold = 0;
for (auto& word : __splitText) {
- if (3 <= word.size()) {
+ if (word.size() >= __MIN_WORD_SIZE) {
threshold += word.size();
}
}
return nullptr;
}
-Command* CommandFinder::findCommandByPron()
+ClickableItem* CommandFinder::findCommandByPron()
{
_I("[CommandFinder] Find command by word");
_E("[CommandFinder] Not implemented");
#include <string>
#include <memory>
-#include "Command.h"
+#include "ClickableItem.h"
class CommandFinder {
public:
- CommandFinder(std::string text, std::list<std::shared_ptr<Command>>& __commands);
- CommandFinder(int index, std::list<std::shared_ptr<Command>>& __commands);
+ CommandFinder(std::string text, std::list<std::shared_ptr<ClickableItem>> &__commands);
+ CommandFinder(int index, std::list<std::shared_ptr<ClickableItem>> &__commands);
- Command* findCommand();
+ ClickableItem* findCommand();
private:
- Command* findCommandByIndex();
- Command* findCommandByText();
- Command* findCommandByWord();
- Command* findCommandByChar();
- Command* findCommandByPron();
+ ClickableItem* findCommandByIndex();
+ ClickableItem* findCommandByText();
+ ClickableItem* findCommandByWord();
+ ClickableItem* findCommandByChar();
+ ClickableItem* findCommandByPron();
private:
const double __WORD_MATCHING_RATE;
const double __CHAR_MATCHING_RATE;
+ const std::size_t __MIN_WORD_SIZE;
- std::list<std::shared_ptr<Command>>& __commands;
+ std::list<std::shared_ptr<ClickableItem>> &__commands;
std::vector<std::string> __splitText;
std::string __loweredText;
int __index;
using namespace std;
-
void CommandManager::addCommand(ClickableItem item)
{
try {
- shared_ptr<Command> command = make_shared<Command>(item);
+ shared_ptr<ClickableItem> command = make_shared<ClickableItem>(item);
__commands.push_back(command);
- } catch (exception e) {
+ } catch (exception &e) {
_E("[CommandManager] Fail to make command. exception(%s)", e.what());
return;
}
__commands.clear();
}
-Command* CommandManager::findCommand(std::string text, bool isIndex)
+ClickableItem* CommandManager::findCommand(std::string text, bool isIndex)
{
int index = -1;
-
try {
index = stoi(text);
- } catch (exception e) {
+ } catch (exception &e) {
_E("[CommandManager] Fail to convert. exception(%s)", e.what());
}
}
auto command = finder->findCommand();
- _I("[CommandManager] Find command. text(%s). command(%s)", text.c_str(), command->getLabel().c_str());
+ _I("[CommandManager] Find command. text(%s). command(%s)", text.c_str(), command->label.c_str());
return command;
}
#define __TIZEN_UIX_MMI_IU_COMMAND_MANAGER_H__
#include <list>
-#include <vector>
#include <string>
#include <memory>
-#include "Command.h"
+#include "ClickableItem.h"
class CommandManager {
public:
void addCommand(ClickableItem item);
void cleanCommands();
- Command* findCommand(std::string text, bool isIndex);
- private:
-
+ ClickableItem* findCommand(std::string text, bool isIndex);
private:
- std::list<std::shared_ptr<Command>> __commands;
+ std::list<std::shared_ptr<ClickableItem>> __commands;
};
#endif /* __TIZEN_UIX_MMI_IU_COMMAND_MANAGER_H__ */
\ No newline at end of file
'iu/mmi_iu.cpp',
'iu/output_intent.cpp',
'iu/output_intent.h',
- 'iu/Command.h',
- 'iu/Command.cpp',
'iu/CommandFinder.cpp',
'iu/CommandFinder.h',
'iu/ClickableItem.h',
'iu/StringUtil.cpp',
- 'iu/StringUtil.h'
+ 'iu/StringUtil.h',
+ 'iu/CommandManager.cpp',
+ 'iu/CommandManager.h',
]
install_headers(