Refactoring
This commit is contained in:
parent
5fbd4cde89
commit
75ff6e5be6
@ -149,12 +149,12 @@ namespace AJ
|
||||
{
|
||||
}
|
||||
|
||||
WordModificatorInterface& AdjectivePair::wordModificator()
|
||||
const WordModificatorInterface& AdjectivePair::wordModificator() const
|
||||
{
|
||||
return modificator;
|
||||
}
|
||||
|
||||
WordHolder& AdjectivePair::word()
|
||||
const WordHolder& AdjectivePair::word() const
|
||||
{
|
||||
return wordRecord;
|
||||
}
|
||||
|
@ -62,9 +62,9 @@ namespace AJ
|
||||
|
||||
AdjectivePair(AdjectiveStruct iModificator, AdjectiveRecord iWordRecord);
|
||||
|
||||
virtual WordModificatorInterface& wordModificator();
|
||||
virtual const WordModificatorInterface& wordModificator() const;
|
||||
|
||||
virtual WordHolder& word();
|
||||
virtual const WordHolder& word() const;
|
||||
|
||||
virtual std::wstring getType();
|
||||
};
|
||||
|
@ -83,6 +83,11 @@ public:
|
||||
|
||||
boost::property_tree::wptree CreateTranslationPropertyTree() const;
|
||||
|
||||
bool operator==(const WordHolder& other) const
|
||||
{
|
||||
return word == other.word;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class WordModificatorInterface
|
||||
@ -99,13 +104,18 @@ public:
|
||||
{
|
||||
return modificatorTree;
|
||||
}
|
||||
|
||||
bool operator==(const WordModificatorInterface& other) const
|
||||
{
|
||||
return modificatorTree == other.modificatorTree;
|
||||
}
|
||||
};
|
||||
|
||||
struct WordPairInterface
|
||||
{
|
||||
virtual WordModificatorInterface& wordModificator() = 0;
|
||||
virtual const WordModificatorInterface& wordModificator() const = 0;
|
||||
|
||||
virtual WordHolder& word() = 0;
|
||||
virtual const WordHolder& word() const = 0;
|
||||
|
||||
virtual std::wstring getType() = 0;
|
||||
|
||||
@ -113,6 +123,16 @@ struct WordPairInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool operator==(const WordPairInterface& other) const
|
||||
{
|
||||
return wordModificator() == other.wordModificator() && word() == other.word();
|
||||
}
|
||||
|
||||
bool operator!=(const WordPairInterface& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
std::wstring NounGenderToWString(NounGender g);
|
||||
|
@ -137,6 +137,29 @@ namespace http {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoveDuplicates(std::vector<std::shared_ptr<WordPairInterface>>& wordPairSet)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
while (i < wordPairSet.size())
|
||||
{
|
||||
size_t j = i + 1;
|
||||
|
||||
while (j < wordPairSet.size())
|
||||
{
|
||||
if (*wordPairSet[i] == *wordPairSet[j])
|
||||
{
|
||||
wordPairSet.erase(wordPairSet.begin() + j);
|
||||
j--;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boost::property_tree::wptree PrepareReport(std::wstring request)
|
||||
{
|
||||
@ -158,6 +181,8 @@ namespace http {
|
||||
VB::RecognizeVerb(request, wordPairSet);
|
||||
OT::RecognizeWord(request, wordPairSet);
|
||||
PP::RecognizeWord(request, wordPairSet);
|
||||
|
||||
RemoveDuplicates(wordPairSet);
|
||||
|
||||
boost::property_tree::wptree wordArr;
|
||||
|
||||
|
@ -154,12 +154,12 @@ NounPair::NounPair(NounStruct iNounModificator, NounRecord iNoun)
|
||||
{
|
||||
}
|
||||
|
||||
WordModificatorInterface& NounPair::wordModificator()
|
||||
const WordModificatorInterface& NounPair::wordModificator() const
|
||||
{
|
||||
return nounModificator;
|
||||
}
|
||||
|
||||
WordHolder& NounPair::word()
|
||||
const WordHolder& NounPair::word() const
|
||||
{
|
||||
return noun;
|
||||
}
|
||||
|
@ -151,9 +151,9 @@ namespace NN
|
||||
|
||||
NounPair(NounStruct iNounModificator, NounRecord iNoun);
|
||||
|
||||
virtual WordModificatorInterface& wordModificator();
|
||||
virtual const WordModificatorInterface& wordModificator() const;
|
||||
|
||||
virtual WordHolder& word();
|
||||
virtual const WordHolder& word() const;
|
||||
|
||||
virtual std::wstring getType();
|
||||
};
|
||||
|
@ -64,12 +64,12 @@ namespace OT
|
||||
{
|
||||
}
|
||||
|
||||
WordModificatorInterface& OtherWordPair::wordModificator()
|
||||
const WordModificatorInterface& OtherWordPair::wordModificator() const
|
||||
{
|
||||
return modificator;
|
||||
}
|
||||
|
||||
WordHolder& OtherWordPair::word()
|
||||
const WordHolder& OtherWordPair::word() const
|
||||
{
|
||||
return wordRecord;
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ namespace OT
|
||||
|
||||
OtherWordPair(OtherWordModificator iModificator, OtherWordRecord iWordRecord);
|
||||
|
||||
virtual WordModificatorInterface& wordModificator();
|
||||
virtual const WordModificatorInterface& wordModificator() const;
|
||||
|
||||
virtual WordHolder& word();
|
||||
virtual const WordHolder& word() const;
|
||||
|
||||
virtual std::wstring getType();
|
||||
};
|
||||
|
@ -93,12 +93,12 @@ namespace PP
|
||||
{
|
||||
}
|
||||
|
||||
WordModificatorInterface& PrepositionPair::wordModificator()
|
||||
const WordModificatorInterface& PrepositionPair::wordModificator() const
|
||||
{
|
||||
return modificator;
|
||||
}
|
||||
|
||||
WordHolder& PrepositionPair::word()
|
||||
const WordHolder& PrepositionPair::word() const
|
||||
{
|
||||
return wordRecord;
|
||||
}
|
||||
@ -108,11 +108,11 @@ namespace PP
|
||||
return L"preposition";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RecognizeWord(std::wstring word, std::vector<std::shared_ptr<WordPairInterface>>& wordPair)
|
||||
{
|
||||
|
||||
std::vector<std::shared_ptr<PrepositionPair>> result;
|
||||
|
||||
for (auto& wordRecord : PrepositionRecordArr)
|
||||
{
|
||||
if (wordRecord.GetWord() == word)
|
||||
|
@ -51,9 +51,9 @@ namespace PP
|
||||
|
||||
PrepositionPair(PrepositionModificator iModificator, PrepositionRecord iWordRecord);
|
||||
|
||||
virtual WordModificatorInterface& wordModificator();
|
||||
virtual const WordModificatorInterface& wordModificator() const;
|
||||
|
||||
virtual WordHolder& word();
|
||||
virtual const WordHolder& word() const;
|
||||
|
||||
virtual std::wstring getType();
|
||||
};
|
||||
|
@ -117,12 +117,12 @@ namespace VB
|
||||
{
|
||||
}
|
||||
|
||||
WordModificatorInterface& VerbPair::wordModificator()
|
||||
const WordModificatorInterface& VerbPair::wordModificator() const
|
||||
{
|
||||
return modificator;
|
||||
}
|
||||
|
||||
WordHolder& VerbPair::word()
|
||||
const WordHolder& VerbPair::word() const
|
||||
{
|
||||
return wordRecord;
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ namespace VB
|
||||
|
||||
VerbPair(VerbStruct iModificator, VerbRecord iWordRecord);
|
||||
|
||||
virtual WordModificatorInterface& wordModificator();
|
||||
virtual const WordModificatorInterface& wordModificator() const;
|
||||
|
||||
virtual WordHolder& word();
|
||||
virtual const WordHolder& word() const;
|
||||
|
||||
virtual std::wstring getType();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user