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;
|
return modificator;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordHolder& AdjectivePair::word()
|
const WordHolder& AdjectivePair::word() const
|
||||||
{
|
{
|
||||||
return wordRecord;
|
return wordRecord;
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,9 @@ namespace AJ
|
|||||||
|
|
||||||
AdjectivePair(AdjectiveStruct iModificator, AdjectiveRecord iWordRecord);
|
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();
|
virtual std::wstring getType();
|
||||||
};
|
};
|
||||||
|
@ -83,6 +83,11 @@ public:
|
|||||||
|
|
||||||
boost::property_tree::wptree CreateTranslationPropertyTree() const;
|
boost::property_tree::wptree CreateTranslationPropertyTree() const;
|
||||||
|
|
||||||
|
bool operator==(const WordHolder& other) const
|
||||||
|
{
|
||||||
|
return word == other.word;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WordModificatorInterface
|
class WordModificatorInterface
|
||||||
@ -99,13 +104,18 @@ public:
|
|||||||
{
|
{
|
||||||
return modificatorTree;
|
return modificatorTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const WordModificatorInterface& other) const
|
||||||
|
{
|
||||||
|
return modificatorTree == other.modificatorTree;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WordPairInterface
|
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;
|
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);
|
std::wstring NounGenderToWString(NounGender g);
|
||||||
|
@ -137,6 +137,29 @@ namespace http {
|
|||||||
return true;
|
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)
|
boost::property_tree::wptree PrepareReport(std::wstring request)
|
||||||
{
|
{
|
||||||
@ -159,6 +182,8 @@ namespace http {
|
|||||||
OT::RecognizeWord(request, wordPairSet);
|
OT::RecognizeWord(request, wordPairSet);
|
||||||
PP::RecognizeWord(request, wordPairSet);
|
PP::RecognizeWord(request, wordPairSet);
|
||||||
|
|
||||||
|
RemoveDuplicates(wordPairSet);
|
||||||
|
|
||||||
boost::property_tree::wptree wordArr;
|
boost::property_tree::wptree wordArr;
|
||||||
|
|
||||||
for (auto& wordPair : wordPairSet)
|
for (auto& wordPair : wordPairSet)
|
||||||
|
@ -154,12 +154,12 @@ NounPair::NounPair(NounStruct iNounModificator, NounRecord iNoun)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WordModificatorInterface& NounPair::wordModificator()
|
const WordModificatorInterface& NounPair::wordModificator() const
|
||||||
{
|
{
|
||||||
return nounModificator;
|
return nounModificator;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordHolder& NounPair::word()
|
const WordHolder& NounPair::word() const
|
||||||
{
|
{
|
||||||
return noun;
|
return noun;
|
||||||
}
|
}
|
||||||
|
@ -151,9 +151,9 @@ namespace NN
|
|||||||
|
|
||||||
NounPair(NounStruct iNounModificator, NounRecord iNoun);
|
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();
|
virtual std::wstring getType();
|
||||||
};
|
};
|
||||||
|
@ -64,12 +64,12 @@ namespace OT
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WordModificatorInterface& OtherWordPair::wordModificator()
|
const WordModificatorInterface& OtherWordPair::wordModificator() const
|
||||||
{
|
{
|
||||||
return modificator;
|
return modificator;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordHolder& OtherWordPair::word()
|
const WordHolder& OtherWordPair::word() const
|
||||||
{
|
{
|
||||||
return wordRecord;
|
return wordRecord;
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,9 @@ namespace OT
|
|||||||
|
|
||||||
OtherWordPair(OtherWordModificator iModificator, OtherWordRecord iWordRecord);
|
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();
|
virtual std::wstring getType();
|
||||||
};
|
};
|
||||||
|
@ -93,12 +93,12 @@ namespace PP
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WordModificatorInterface& PrepositionPair::wordModificator()
|
const WordModificatorInterface& PrepositionPair::wordModificator() const
|
||||||
{
|
{
|
||||||
return modificator;
|
return modificator;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordHolder& PrepositionPair::word()
|
const WordHolder& PrepositionPair::word() const
|
||||||
{
|
{
|
||||||
return wordRecord;
|
return wordRecord;
|
||||||
}
|
}
|
||||||
@ -108,11 +108,11 @@ namespace PP
|
|||||||
return L"preposition";
|
return L"preposition";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void RecognizeWord(std::wstring word, std::vector<std::shared_ptr<WordPairInterface>>& wordPair)
|
void RecognizeWord(std::wstring word, std::vector<std::shared_ptr<WordPairInterface>>& wordPair)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<PrepositionPair>> result;
|
||||||
|
|
||||||
for (auto& wordRecord : PrepositionRecordArr)
|
for (auto& wordRecord : PrepositionRecordArr)
|
||||||
{
|
{
|
||||||
if (wordRecord.GetWord() == word)
|
if (wordRecord.GetWord() == word)
|
||||||
|
@ -51,9 +51,9 @@ namespace PP
|
|||||||
|
|
||||||
PrepositionPair(PrepositionModificator iModificator, PrepositionRecord iWordRecord);
|
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();
|
virtual std::wstring getType();
|
||||||
};
|
};
|
||||||
|
@ -117,12 +117,12 @@ namespace VB
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WordModificatorInterface& VerbPair::wordModificator()
|
const WordModificatorInterface& VerbPair::wordModificator() const
|
||||||
{
|
{
|
||||||
return modificator;
|
return modificator;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordHolder& VerbPair::word()
|
const WordHolder& VerbPair::word() const
|
||||||
{
|
{
|
||||||
return wordRecord;
|
return wordRecord;
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,9 @@ namespace VB
|
|||||||
|
|
||||||
VerbPair(VerbStruct iModificator, VerbRecord iWordRecord);
|
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();
|
virtual std::wstring getType();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user