Refactoring
This commit is contained in:
parent
f48b8c6929
commit
1b88f4c095
@ -28,7 +28,7 @@ namespace AJ
|
||||
|
||||
boost::split_regex(lineArr, line, boost::wregex(L" "));
|
||||
|
||||
nominativeMaleForm = lineArr[1];
|
||||
SetWord(lineArr[1]);
|
||||
|
||||
standardShortFormAvailable = lineArr[2] == L"1" ? true : false;
|
||||
|
||||
@ -38,6 +38,38 @@ namespace AJ
|
||||
|
||||
}
|
||||
|
||||
bool AdjectiveStruct::operator<(const AdjectiveStruct& n) const
|
||||
{
|
||||
if (grammaticalCase != n.grammaticalCase)
|
||||
{
|
||||
return grammaticalCase < n.grammaticalCase;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count != n.count)
|
||||
{
|
||||
return count < n.count;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gender != n.gender)
|
||||
{
|
||||
return gender < n.gender;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isDeclentionAnimated != n.isDeclentionAnimated)
|
||||
{
|
||||
return isDeclentionAnimated < n.isDeclentionAnimated;
|
||||
}
|
||||
else
|
||||
{
|
||||
return adjectiveRecord < n.adjectiveRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::wstring> GetAllAdjectiveEndingArr()
|
||||
{
|
||||
@ -160,6 +192,25 @@ namespace AJ
|
||||
return IFORM_MALE_INANIMATE;
|
||||
}
|
||||
|
||||
bool AdjectiveEndingDivision::operator<(const AdjectiveEndingDivision& other) const
|
||||
{
|
||||
if (base != other.base)
|
||||
{
|
||||
return base < other.base;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ending != other.ending)
|
||||
{
|
||||
return ending < other.ending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return divisionCase < other.divisionCase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<AdjectiveEndingDivision> getPossibleAdjectiveEndingDivisionSet(std::wstring noun)
|
||||
{
|
||||
std::set<AdjectiveEndingDivision> result;
|
||||
@ -208,7 +259,7 @@ namespace AJ
|
||||
{
|
||||
for (auto& adjective : AdjectiveRecordArr)
|
||||
{
|
||||
if (adjective.nominativeMaleForm == nominative)
|
||||
if (adjective.GetWord() == nominative)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -221,7 +272,7 @@ namespace AJ
|
||||
{
|
||||
for (auto& adjective : AdjectiveRecordArr)
|
||||
{
|
||||
if (adjective.nominativeMaleForm == nominative)
|
||||
if (adjective.GetWord() == nominative)
|
||||
{
|
||||
return adjective;
|
||||
}
|
||||
@ -231,28 +282,6 @@ namespace AJ
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
std::set<std::wstring> GetAdjectiveNominative(std::wstring base, AdjectiveDeclencion declencion, NounCount nounCount)
|
||||
{
|
||||
std::set<std::wstring> result;
|
||||
|
||||
AdjectiveDeclencionCaseTableRecord declencionCaseTableRecord = adjectiveDeclencionCaseTable[static_cast<int>(declencion)];
|
||||
|
||||
for (auto& grammaticalTableRecord : declencionCaseTableRecord.grammaticalCaseTable)
|
||||
{
|
||||
if (grammaticalTableRecord.grammaticalCase == NGC_P1_NOMINATIVE && grammaticalTableRecord.count == nounCount)
|
||||
{
|
||||
for (auto& e : grammaticalTableRecord.ending)
|
||||
{
|
||||
result.insert(base + e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
std::set<std::wstring> GetNominativeMaleSingular(std::wstring base)
|
||||
{
|
||||
std::wstring result;
|
||||
|
@ -14,10 +14,8 @@
|
||||
namespace AJ
|
||||
{
|
||||
|
||||
struct AdjectiveRecord : public TranslationUnitSetMix
|
||||
struct AdjectiveRecord : public TranslationUnitSetMix, public WordHolder
|
||||
{
|
||||
std::wstring nominativeMaleForm;
|
||||
|
||||
bool standardShortFormAvailable;
|
||||
|
||||
std::wstring specialShortForm;
|
||||
@ -25,10 +23,6 @@ namespace AJ
|
||||
AdjectiveRecord();
|
||||
AdjectiveRecord(std::wstring line);
|
||||
|
||||
bool operator<(const AdjectiveRecord& n) const
|
||||
{
|
||||
return nominativeMaleForm < n.nominativeMaleForm;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -46,38 +40,7 @@ namespace AJ
|
||||
|
||||
AdjectiveRecord adjectiveRecord;
|
||||
|
||||
bool operator<(const AdjectiveStruct& n) const
|
||||
{
|
||||
if (grammaticalCase != n.grammaticalCase)
|
||||
{
|
||||
return grammaticalCase < n.grammaticalCase;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count != n.count)
|
||||
{
|
||||
return count < n.count;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gender != n.gender)
|
||||
{
|
||||
return gender < n.gender;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isDeclentionAnimated != n.isDeclentionAnimated)
|
||||
{
|
||||
return isDeclentionAnimated < n.isDeclentionAnimated;
|
||||
}
|
||||
else
|
||||
{
|
||||
return adjectiveRecord < n.adjectiveRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool operator<(const AdjectiveStruct& n) const;
|
||||
};
|
||||
|
||||
|
||||
@ -132,24 +95,8 @@ namespace AJ
|
||||
DC_COMMON = 0
|
||||
} divisionCase;
|
||||
|
||||
bool operator<(const AdjectiveEndingDivision& other) const
|
||||
{
|
||||
if (base != other.base)
|
||||
{
|
||||
return base < other.base;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ending != other.ending)
|
||||
{
|
||||
return ending < other.ending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return divisionCase < other.divisionCase;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool operator<(const AdjectiveEndingDivision& other) const;
|
||||
|
||||
};
|
||||
|
||||
std::set<AdjectiveEndingDivision> getPossibleAdjectiveEndingDivisionSet(std::wstring noun);
|
||||
@ -179,7 +126,6 @@ namespace AJ
|
||||
|
||||
void FillDivisionCaseMaps();
|
||||
|
||||
|
||||
std::set<AdjectiveStruct> RecognizeAdjective(std::wstring noun);
|
||||
|
||||
|
||||
|
@ -39,6 +39,42 @@ boost::property_tree::wptree TranslationUnitSetMix::CreateTranslationPropertyTre
|
||||
return ptree;
|
||||
}
|
||||
|
||||
bool WordHolder::operator<(const WordHolder& other) const
|
||||
{
|
||||
return word < other.word;
|
||||
}
|
||||
|
||||
|
||||
void WordHolder::SetWord(const std::wstring& w)
|
||||
{
|
||||
word = w;
|
||||
}
|
||||
|
||||
std::wstring WordHolder::GetWord() const
|
||||
{
|
||||
return word;
|
||||
}
|
||||
|
||||
wchar_t WordHolder::GetLastChar() const
|
||||
{
|
||||
if (word.size() > 0)
|
||||
{
|
||||
std::cout << "Error in GetLastChar" << std::endl;
|
||||
}
|
||||
|
||||
return word[word.size() - 1];
|
||||
}
|
||||
|
||||
wchar_t WordHolder::GetPrevLastChar() const
|
||||
{
|
||||
if (word.size() > 1)
|
||||
{
|
||||
std::cout << "Error in GetPrevLastChar" << std::endl;
|
||||
}
|
||||
|
||||
return word[word.size() - 2];
|
||||
}
|
||||
|
||||
|
||||
NounCount WStringToNounCount(std::wstring str)
|
||||
{
|
||||
|
@ -65,6 +65,24 @@ public:
|
||||
boost::property_tree::wptree CreateTranslationPropertyTree() const;
|
||||
};
|
||||
|
||||
class WordHolder
|
||||
{
|
||||
private:
|
||||
std::wstring word;
|
||||
public:
|
||||
|
||||
void SetWord(const std::wstring& w);
|
||||
|
||||
std::wstring GetWord() const;
|
||||
|
||||
wchar_t GetLastChar() const;
|
||||
|
||||
wchar_t GetPrevLastChar() const;
|
||||
|
||||
bool operator<(const WordHolder& other) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
std::wstring NounCountToWString(NounCount nounCount);
|
||||
NounCount WStringToNounCount(std::wstring str);
|
||||
|
@ -35,7 +35,7 @@ NounRecord::NounRecord(std::wstring line)
|
||||
|
||||
boost::split_regex(lineArr, line, boost::wregex(L" "));
|
||||
|
||||
nominativeForm = lineArr[1];
|
||||
SetWord(lineArr[1]);
|
||||
|
||||
if (lineArr[2] == L"м")
|
||||
{
|
||||
@ -157,6 +157,51 @@ NounDeclencion WStringToNounDeclencion(std::wstring str)
|
||||
}
|
||||
|
||||
|
||||
bool NounEndingDivision::operator<(const NounEndingDivision& other) const
|
||||
{
|
||||
if (base != other.base)
|
||||
{
|
||||
return base < other.base;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ending != other.ending)
|
||||
{
|
||||
return ending < other.ending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return divisionCase < other.divisionCase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NounStruct::operator<(const NounStruct& other) const
|
||||
{
|
||||
if (nounGrammaticalCase != other.nounGrammaticalCase)
|
||||
{
|
||||
return nounGrammaticalCase < other.nounGrammaticalCase;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nounCount != other.nounCount)
|
||||
{
|
||||
return nounCount < other.nounCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animated != other.animated)
|
||||
{
|
||||
return animated < other.animated;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nounRecord < other.nounRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::wstring> GetAllNounEndingArr()
|
||||
{
|
||||
std::vector<std::wstring> result
|
||||
@ -197,7 +242,7 @@ bool NounIsInDictionary(std::wstring nounNominative)
|
||||
{
|
||||
for (auto& noun : NounRecordArr)
|
||||
{
|
||||
if (noun.nominativeForm == nounNominative)
|
||||
if (noun.GetWord() == nounNominative)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -283,7 +328,7 @@ std::set<std::wstring> getPluralForm(NounRecord noun)
|
||||
{
|
||||
if (noun.haveStandardMultipleForm)
|
||||
{
|
||||
std::wstring pluralForm = convertToStandardPluralForm(noun.nominativeForm);
|
||||
std::wstring pluralForm = convertToStandardPluralForm(noun.GetWord());
|
||||
|
||||
if (noun.haveStandardMultipleFormEnding)
|
||||
{
|
||||
@ -300,7 +345,7 @@ std::set<std::wstring> getPluralForm(NounRecord noun)
|
||||
|
||||
if (noun.haveStandardMultipleFormWithMissingLastVowel)
|
||||
{
|
||||
std::wstring pluralForm = convertToStandardPluralForm(noun.nominativeForm);
|
||||
std::wstring pluralForm = convertToStandardPluralForm(noun.GetWord());
|
||||
|
||||
wchar_t prevsschar = pluralForm[pluralForm.size() - 4];
|
||||
|
||||
@ -330,7 +375,7 @@ std::set<std::wstring> getPluralForm(NounRecord noun)
|
||||
}
|
||||
else
|
||||
{
|
||||
result.insert(noun.nominativeForm);
|
||||
result.insert(noun.GetWord());
|
||||
}
|
||||
|
||||
|
||||
@ -357,7 +402,7 @@ NounRecord GetNounRecordFromDictionary(std::wstring nounNominative)
|
||||
{
|
||||
for (auto& noun : NounRecordArr)
|
||||
{
|
||||
if (noun.nominativeForm == nounNominative)
|
||||
if (noun.GetWord() == nounNominative)
|
||||
{
|
||||
return noun;
|
||||
}
|
||||
@ -531,95 +576,85 @@ std::wstring GetNounNoninativeSpecialPluralA(std::wstring nounBase, NounDeclenci
|
||||
}
|
||||
|
||||
|
||||
wchar_t GetLastChar(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.nominativeForm[nounRecord.nominativeForm.size() - 1];
|
||||
}
|
||||
|
||||
wchar_t GetPrevLastChar(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.nominativeForm[nounRecord.nominativeForm.size() - 2];
|
||||
}
|
||||
|
||||
|
||||
bool FirstAIFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && (GetLastChar(nounRecord) == L'а' && charIsIFormConsolant(GetPrevLastChar(nounRecord)));
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && (nounRecord.GetLastChar() == L'а' && charIsIFormConsolant(nounRecord.GetPrevLastChar()));
|
||||
}
|
||||
|
||||
bool FirstAIFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && (GetLastChar(nounRecord) == L'а' && charIsIFormConsolant(GetPrevLastChar(nounRecord)));
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && (nounRecord.GetLastChar() == L'а' && charIsIFormConsolant(nounRecord.GetPrevLastChar()));
|
||||
}
|
||||
|
||||
bool FirstAIFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.canBeInanimate && (
|
||||
(GetLastChar(nounRecord) == L'а' && charIsIFormConsolant(GetPrevLastChar(nounRecord))) ||
|
||||
!nounRecord.haveSingleForm && (GetLastChar(nounRecord) == L'и' && charIsIFormConsolant(GetPrevLastChar(nounRecord)))
|
||||
(nounRecord.GetLastChar() == L'а' && charIsIFormConsolant(nounRecord.GetPrevLastChar())) ||
|
||||
!nounRecord.haveSingleForm && (nounRecord.GetLastChar() == L'и' && charIsIFormConsolant(nounRecord.GetPrevLastChar()))
|
||||
);
|
||||
}
|
||||
|
||||
bool FirstAIFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.canBeAnimate && (
|
||||
(GetLastChar(nounRecord) == L'а' && charIsIFormConsolant(GetPrevLastChar(nounRecord))) ||
|
||||
!nounRecord.haveSingleForm && (GetLastChar(nounRecord) == L'и' && charIsIFormConsolant(GetPrevLastChar(nounRecord)))
|
||||
(nounRecord.GetLastChar() == L'а' && charIsIFormConsolant(nounRecord.GetPrevLastChar())) ||
|
||||
!nounRecord.haveSingleForm && (nounRecord.GetLastChar() == L'и' && charIsIFormConsolant(nounRecord.GetPrevLastChar()))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool FirstAUFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && (GetLastChar(nounRecord) == L'а' && charIsUFormConsolant(GetPrevLastChar(nounRecord)));
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && (nounRecord.GetLastChar() == L'а' && charIsUFormConsolant(nounRecord.GetPrevLastChar()));
|
||||
}
|
||||
|
||||
bool FirstAUFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && (GetLastChar(nounRecord) == L'а' && charIsUFormConsolant(GetPrevLastChar(nounRecord)));
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && (nounRecord.GetLastChar() == L'а' && charIsUFormConsolant(nounRecord.GetPrevLastChar()));
|
||||
}
|
||||
|
||||
|
||||
bool FirstAUFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.canBeInanimate && (
|
||||
(GetLastChar(nounRecord) == L'а' && charIsUFormConsolant(GetPrevLastChar(nounRecord))) ||
|
||||
!nounRecord.haveSingleForm && (GetLastChar(nounRecord) == L'ы' && charIsUFormConsolant(GetPrevLastChar(nounRecord)))
|
||||
(nounRecord.GetLastChar() == L'а' && charIsUFormConsolant(nounRecord.GetPrevLastChar())) ||
|
||||
!nounRecord.haveSingleForm && (nounRecord.GetLastChar() == L'ы' && charIsUFormConsolant(nounRecord.GetPrevLastChar()))
|
||||
);
|
||||
}
|
||||
|
||||
bool FirstAUFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.canBeAnimate && (
|
||||
(GetLastChar(nounRecord) == L'а' && charIsUFormConsolant(GetPrevLastChar(nounRecord))) ||
|
||||
!nounRecord.haveSingleForm && (GetLastChar(nounRecord) == L'ы' && charIsUFormConsolant(GetPrevLastChar(nounRecord)))
|
||||
(nounRecord.GetLastChar() == L'а' && charIsUFormConsolant(nounRecord.GetPrevLastChar())) ||
|
||||
!nounRecord.haveSingleForm && (nounRecord.GetLastChar() == L'ы' && charIsUFormConsolant(nounRecord.GetPrevLastChar()))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool FirstYaFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && (GetLastChar(nounRecord) == L'я');
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && (nounRecord.GetLastChar() == L'я');
|
||||
}
|
||||
|
||||
bool FirstYaFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && (GetLastChar(nounRecord) == L'я');
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && (nounRecord.GetLastChar() == L'я');
|
||||
}
|
||||
|
||||
bool FirstYaFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.canBeInanimate && (
|
||||
(GetLastChar(nounRecord) == L'я') ||
|
||||
!nounRecord.haveSingleForm && (GetLastChar(nounRecord) == L'и')
|
||||
(nounRecord.GetLastChar() == L'я') ||
|
||||
!nounRecord.haveSingleForm && (nounRecord.GetLastChar() == L'и')
|
||||
);
|
||||
}
|
||||
|
||||
bool FirstYaFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.canBeAnimate && (
|
||||
(GetLastChar(nounRecord) == L'я') ||
|
||||
!nounRecord.haveSingleForm && (GetLastChar(nounRecord) == L'и')
|
||||
(nounRecord.GetLastChar() == L'я') ||
|
||||
!nounRecord.haveSingleForm && (nounRecord.GetLastChar() == L'и')
|
||||
);
|
||||
}
|
||||
|
||||
@ -628,14 +663,14 @@ bool FirstYaFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
|
||||
bool SecondMaleIFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && charIsIFormConsolant(GetLastChar(nounRecord));
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && charIsIFormConsolant(nounRecord.GetLastChar());
|
||||
}
|
||||
|
||||
bool SecondMaleIFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && (
|
||||
charIsIFormConsolant(GetLastChar(nounRecord)) ||
|
||||
!nounRecord.haveSingleForm && charIsIFormConsolant(GetPrevLastChar(nounRecord)) && GetLastChar(nounRecord) == L'и'
|
||||
charIsIFormConsolant(nounRecord.GetLastChar()) ||
|
||||
!nounRecord.haveSingleForm && charIsIFormConsolant(nounRecord.GetPrevLastChar()) && nounRecord.GetLastChar() == L'и'
|
||||
);
|
||||
|
||||
}
|
||||
@ -643,92 +678,92 @@ bool SecondMaleIFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
|
||||
bool SecondMaleIFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && charIsIFormConsolant(GetLastChar(nounRecord));
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && charIsIFormConsolant(nounRecord.GetLastChar());
|
||||
}
|
||||
|
||||
bool SecondMaleIFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && (
|
||||
charIsIFormConsolant(GetLastChar(nounRecord)) ||
|
||||
!nounRecord.haveSingleForm && charIsIFormConsolant(GetPrevLastChar(nounRecord)) && GetLastChar(nounRecord) == L'и'
|
||||
charIsIFormConsolant(nounRecord.GetLastChar()) ||
|
||||
!nounRecord.haveSingleForm && charIsIFormConsolant(nounRecord.GetPrevLastChar()) && nounRecord.GetLastChar() == L'и'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SecondMaleUFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && charIsUFormConsolant(GetLastChar(nounRecord));
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && charIsUFormConsolant(nounRecord.GetLastChar());
|
||||
}
|
||||
|
||||
bool SecondMaleUFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && (
|
||||
charIsUFormConsolant(GetLastChar(nounRecord)) ||
|
||||
!nounRecord.haveSingleForm && charIsUFormConsolant(GetPrevLastChar(nounRecord)) && GetLastChar(nounRecord) == L'ы'
|
||||
charIsUFormConsolant(nounRecord.GetLastChar()) ||
|
||||
!nounRecord.haveSingleForm && charIsUFormConsolant(nounRecord.GetPrevLastChar()) && nounRecord.GetLastChar() == L'ы'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SecondMaleUFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && charIsUFormConsolant(GetLastChar(nounRecord));
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && charIsUFormConsolant(nounRecord.GetLastChar());
|
||||
}
|
||||
|
||||
bool SecondMaleUFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && (
|
||||
charIsUFormConsolant(GetLastChar(nounRecord)) ||
|
||||
!nounRecord.haveSingleForm && charIsUFormConsolant(GetPrevLastChar(nounRecord)) && GetLastChar(nounRecord) == L'ы'
|
||||
charIsUFormConsolant(nounRecord.GetLastChar()) ||
|
||||
!nounRecord.haveSingleForm && charIsUFormConsolant(nounRecord.GetPrevLastChar()) && nounRecord.GetLastChar() == L'ы'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SecondMaleSSFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && GetLastChar(nounRecord) == L'ь';
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && nounRecord.GetLastChar() == L'ь';
|
||||
}
|
||||
|
||||
bool SecondMaleSSFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_MALE && nounRecord.canBeInanimate && (
|
||||
GetLastChar(nounRecord) == L'ь' ||
|
||||
!nounRecord.haveSingleForm && GetLastChar(nounRecord) == L'и'
|
||||
nounRecord.GetLastChar() == L'ь' ||
|
||||
!nounRecord.haveSingleForm && nounRecord.GetLastChar() == L'и'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SecondMaleSSFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && GetLastChar(nounRecord) == L'ь';
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && nounRecord.GetLastChar() == L'ь';
|
||||
}
|
||||
|
||||
bool SecondMaleSSFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_MALE && nounRecord.canBeAnimate && (
|
||||
GetLastChar(nounRecord) == L'ь' ||
|
||||
!nounRecord.haveSingleForm && GetLastChar(nounRecord) == L'и'
|
||||
nounRecord.GetLastChar() == L'ь' ||
|
||||
!nounRecord.haveSingleForm && nounRecord.GetLastChar() == L'и'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SecondIShortInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && GetLastChar(nounRecord) == L'й';
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && nounRecord.GetLastChar() == L'й';
|
||||
}
|
||||
|
||||
bool SecondIShortAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && GetLastChar(nounRecord) == L'й';
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && nounRecord.GetLastChar() == L'й';
|
||||
}
|
||||
|
||||
bool SecondIShortInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && GetLastChar(nounRecord) == L'й';
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeInanimate && nounRecord.GetLastChar() == L'й';
|
||||
}
|
||||
|
||||
bool SecondIShortAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && GetLastChar(nounRecord) == L'й';
|
||||
return nounRecord.haveSingleForm && nounRecord.canBeAnimate && nounRecord.GetLastChar() == L'й';
|
||||
}
|
||||
|
||||
|
||||
@ -737,54 +772,54 @@ bool SecondIShortAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
|
||||
bool SecondNeutralEFormSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_NEUTRAL && GetLastChar(nounRecord) == L'е';
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_NEUTRAL && nounRecord.GetLastChar() == L'е';
|
||||
}
|
||||
|
||||
bool SecondNeutralEFormPluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_NEUTRAL && (
|
||||
GetLastChar(nounRecord) == L'е' ||
|
||||
!nounRecord.haveSingleForm && GetLastChar(nounRecord) == L'я'
|
||||
nounRecord.GetLastChar() == L'е' ||
|
||||
!nounRecord.haveSingleForm && nounRecord.GetLastChar() == L'я'
|
||||
);
|
||||
}
|
||||
|
||||
bool SecondNeutralOFormSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_NEUTRAL && GetLastChar(nounRecord) == L'о';
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_NEUTRAL && nounRecord.GetLastChar() == L'о';
|
||||
}
|
||||
|
||||
bool SecondNeutralOFormPluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_NEUTRAL && (
|
||||
GetLastChar(nounRecord) == L'о' ||
|
||||
!nounRecord.haveSingleForm && GetLastChar(nounRecord) == L'а'
|
||||
nounRecord.GetLastChar() == L'о' ||
|
||||
!nounRecord.haveSingleForm && nounRecord.GetLastChar() == L'а'
|
||||
);
|
||||
}
|
||||
|
||||
bool ThirdFormInanimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_FEMALE && nounRecord.canBeInanimate && GetLastChar(nounRecord) == L'ь';
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_FEMALE && nounRecord.canBeInanimate && nounRecord.GetLastChar() == L'ь';
|
||||
}
|
||||
|
||||
bool ThirdFormAnimateSingularCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_FEMALE && nounRecord.canBeAnimate && GetLastChar(nounRecord) == L'ь';
|
||||
return nounRecord.haveSingleForm && nounRecord.gender == NG_FEMALE && nounRecord.canBeAnimate && nounRecord.GetLastChar() == L'ь';
|
||||
}
|
||||
|
||||
|
||||
bool ThirdFormInanimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_FEMALE && nounRecord.canBeInanimate && (
|
||||
GetLastChar(nounRecord) == L'ь' ||
|
||||
!nounRecord.haveSingleForm && GetLastChar(nounRecord) == L'и'
|
||||
nounRecord.GetLastChar() == L'ь' ||
|
||||
!nounRecord.haveSingleForm && nounRecord.GetLastChar() == L'и'
|
||||
);
|
||||
}
|
||||
|
||||
bool ThirdFormAnimatePluralCondition(const NounRecord& nounRecord)
|
||||
{
|
||||
return nounRecord.haveMultipleForm && nounRecord.gender == NG_FEMALE && nounRecord.canBeAnimate && (
|
||||
GetLastChar(nounRecord) == L'ь' ||
|
||||
!nounRecord.haveSingleForm && GetLastChar(nounRecord) == L'и'
|
||||
nounRecord.GetLastChar() == L'ь' ||
|
||||
!nounRecord.haveSingleForm && nounRecord.GetLastChar() == L'и'
|
||||
);
|
||||
}
|
||||
|
||||
@ -867,7 +902,7 @@ bool NounScructIsAlreadyInArray(const NounStruct& nounStruct, const std::vector<
|
||||
for (auto& ns : arr)
|
||||
{
|
||||
if (ns.nounGrammaticalCase == nounStruct.nounGrammaticalCase &&
|
||||
ns.nounRecord.nominativeForm == nounStruct.nounRecord.nominativeForm)
|
||||
ns.nounRecord.GetWord() == nounStruct.nounRecord.GetWord())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -14,9 +14,9 @@
|
||||
namespace NN
|
||||
{
|
||||
|
||||
struct NounRecord : public TranslationUnitSetMix
|
||||
struct NounRecord : public TranslationUnitSetMix, public WordHolder
|
||||
{
|
||||
std::wstring nominativeForm;
|
||||
|
||||
NounGender gender;
|
||||
|
||||
bool haveSingleForm;
|
||||
@ -35,13 +35,10 @@ namespace NN
|
||||
|
||||
std::set<std::wstring> precalculatedNominativePluralSet;
|
||||
|
||||
|
||||
NounRecord();
|
||||
NounRecord(std::wstring line);
|
||||
|
||||
bool operator<(const NounRecord& n) const
|
||||
{
|
||||
return nominativeForm < n.nominativeForm;
|
||||
}
|
||||
};
|
||||
|
||||
enum NounDeclencion
|
||||
@ -101,24 +98,8 @@ namespace NN
|
||||
DC_LOST_VOWEL_E
|
||||
} divisionCase;
|
||||
|
||||
bool operator<(const NounEndingDivision& other) const
|
||||
{
|
||||
if (base != other.base)
|
||||
{
|
||||
return base < other.base;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ending != other.ending)
|
||||
{
|
||||
return ending < other.ending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return divisionCase < other.divisionCase;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool operator<(const NounEndingDivision& other) const;
|
||||
|
||||
};
|
||||
|
||||
std::vector<std::wstring> GetAllNounEndingArr();
|
||||
@ -142,31 +123,8 @@ namespace NN
|
||||
bool animated;
|
||||
NounRecord nounRecord;
|
||||
|
||||
bool operator<(const NounStruct& other) const
|
||||
{
|
||||
if (nounGrammaticalCase != other.nounGrammaticalCase)
|
||||
{
|
||||
return nounGrammaticalCase < other.nounGrammaticalCase;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nounCount != other.nounCount)
|
||||
{
|
||||
return nounCount < other.nounCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animated != other.animated)
|
||||
{
|
||||
return animated < other.animated;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nounRecord < other.nounRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool operator<(const NounStruct& other) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -177,9 +135,6 @@ namespace NN
|
||||
std::set<std::wstring> GetNounNoninative(std::wstring nounBase, NounDeclencion nounDeclencion, NounCount nounCount);
|
||||
std::wstring GetNounNoninativeSpecialPluralA(std::wstring nounBase, NounDeclencion nounDeclencion);
|
||||
|
||||
wchar_t GetLastChar(const NounRecord& nounRecord);
|
||||
wchar_t GetPrevLastChar(const NounRecord& nounRecord);
|
||||
|
||||
void SetupDeclentionMap();
|
||||
|
||||
bool NounFitsDeclention(NounRecord nounRecord, NounTuple nounTuple);
|
||||
|
@ -23,20 +23,20 @@ namespace OT
|
||||
|
||||
boost::split_regex(lineArr, line, boost::wregex(L" "));
|
||||
|
||||
word = lineArr[1];
|
||||
SetWord(lineArr[1]);
|
||||
|
||||
type = lineArr[2];
|
||||
|
||||
FillTranslationUnit(lineArr, 3);
|
||||
}
|
||||
|
||||
|
||||
std::set<OtherWordRecord> RecognizeWord(std::wstring word)
|
||||
{
|
||||
std::set<OtherWordRecord> result;
|
||||
|
||||
for (auto& wordRecord : OtherWordRecordArr)
|
||||
{
|
||||
if (wordRecord.word == word)
|
||||
if (wordRecord.GetWord() == word)
|
||||
{
|
||||
result.insert(wordRecord);
|
||||
}
|
||||
|
@ -15,27 +15,14 @@
|
||||
namespace OT
|
||||
{
|
||||
|
||||
struct OtherWordRecord : public TranslationUnitSetMix
|
||||
struct OtherWordRecord : public TranslationUnitSetMix, public WordHolder
|
||||
{
|
||||
std::wstring word;
|
||||
std::wstring type;
|
||||
|
||||
OtherWordRecord();
|
||||
|
||||
OtherWordRecord(std::wstring line);
|
||||
|
||||
bool operator<(const OtherWordRecord& other) const
|
||||
{
|
||||
if (word != other.word)
|
||||
{
|
||||
return word < other.word;
|
||||
}
|
||||
else
|
||||
{
|
||||
return type < other.type;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern std::vector<OtherWordRecord> OtherWordRecordArr;
|
||||
|
@ -28,7 +28,7 @@ namespace PP
|
||||
|
||||
boost::split_regex(lineArr, line, boost::wregex(L" "));
|
||||
|
||||
word = lineArr[1];
|
||||
SetWord(lineArr[1]);
|
||||
|
||||
availableForGenitive = lineArr[2] == L"1" ? true : false;
|
||||
availableForDative = lineArr[3] == L"1" ? true : false;
|
||||
@ -40,14 +40,13 @@ namespace PP
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::set<PrepositionRecord> RecognizeWord(std::wstring word)
|
||||
{
|
||||
std::set<PrepositionRecord> result;
|
||||
|
||||
for (auto& wordRecord : PrepositionRecordArr)
|
||||
{
|
||||
if (wordRecord.word == word)
|
||||
if (wordRecord.GetWord() == word)
|
||||
{
|
||||
result.insert(wordRecord);
|
||||
}
|
||||
|
@ -15,9 +15,8 @@
|
||||
namespace PP
|
||||
{
|
||||
|
||||
struct PrepositionRecord : public TranslationUnitSetMix
|
||||
struct PrepositionRecord : public TranslationUnitSetMix, public WordHolder
|
||||
{
|
||||
std::wstring word;
|
||||
|
||||
bool availableForGenitive;
|
||||
bool availableForDative;
|
||||
@ -29,11 +28,6 @@ namespace PP
|
||||
|
||||
PrepositionRecord(std::wstring line);
|
||||
|
||||
bool operator<(const PrepositionRecord& other) const
|
||||
{
|
||||
return word < other.word;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern std::vector<PrepositionRecord> PrepositionRecordArr;
|
||||
|
@ -31,7 +31,7 @@ namespace VB
|
||||
|
||||
boost::split_regex(lineArr, line, boost::wregex(L" "));
|
||||
|
||||
infinitive = lineArr[1];
|
||||
SetWord(lineArr[1]);
|
||||
|
||||
canBePrefixed = lineArr[2] == L"1" ? true : false;
|
||||
canBeNotPrefixed = lineArr[3] == L"1" ? true : false;
|
||||
@ -43,7 +43,24 @@ namespace VB
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool VerbStruct::operator<(const VerbStruct& v) const
|
||||
{
|
||||
if (verbParams != v.verbParams)
|
||||
{
|
||||
return verbParams < v.verbParams;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selfEnding != v.selfEnding)
|
||||
{
|
||||
return selfEnding < v.selfEnding;
|
||||
}
|
||||
else
|
||||
{
|
||||
return verbRecord < v.verbRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VerbParams WStringToVerbParams(std::wstring str)
|
||||
{
|
||||
@ -195,7 +212,7 @@ namespace VB
|
||||
{
|
||||
for (auto& verb : VerbRecordArr)
|
||||
{
|
||||
if (verb.infinitive == verbInfinitive)
|
||||
if (verb.GetWord() == verbInfinitive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -208,7 +225,7 @@ namespace VB
|
||||
{
|
||||
for (auto& verb : VerbRecordArr)
|
||||
{
|
||||
if (verb.infinitive == verbInfinitive)
|
||||
if (verb.GetWord() == verbInfinitive)
|
||||
{
|
||||
return verb;
|
||||
}
|
||||
@ -303,6 +320,18 @@ namespace VB
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VerbEndingDivision::operator<(const VerbEndingDivision& other) const
|
||||
{
|
||||
if (base != other.base)
|
||||
{
|
||||
return base < other.base;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ending < other.ending;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<VerbEndingDivision> getPossibleVerbEndingDivisionSet(std::wstring verb)
|
||||
{
|
||||
std::set<VerbEndingDivision> result;
|
||||
|
@ -13,9 +13,8 @@
|
||||
|
||||
namespace VB
|
||||
{
|
||||
struct VerbRecord : public TranslationUnitSetMix
|
||||
struct VerbRecord : public TranslationUnitSetMix, public WordHolder
|
||||
{
|
||||
std::wstring infinitive;
|
||||
bool canBePrefixed;
|
||||
bool canBeNotPrefixed;
|
||||
bool canBePerfect;
|
||||
@ -25,11 +24,6 @@ namespace VB
|
||||
|
||||
VerbRecord(std::wstring line);
|
||||
|
||||
bool operator<(const VerbRecord& v) const
|
||||
{
|
||||
return infinitive < v.infinitive;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -90,24 +84,8 @@ namespace VB
|
||||
VerbRecord verbRecord;
|
||||
|
||||
|
||||
bool operator<(const VerbStruct& v) const
|
||||
{
|
||||
if (verbParams != v.verbParams)
|
||||
{
|
||||
return verbParams < v.verbParams;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selfEnding != v.selfEnding)
|
||||
{
|
||||
return selfEnding < v.selfEnding;
|
||||
}
|
||||
else
|
||||
{
|
||||
return verbRecord < v.verbRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool operator<(const VerbStruct& v) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -128,17 +106,7 @@ namespace VB
|
||||
std::wstring base;
|
||||
std::wstring ending;
|
||||
|
||||
bool operator<(const VerbEndingDivision& other) const
|
||||
{
|
||||
if (base != other.base)
|
||||
{
|
||||
return base < other.base;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ending < other.ending;
|
||||
}
|
||||
}
|
||||
bool operator<(const VerbEndingDivision& other) const;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user