diff --git a/rudict/grammar_case_adjective.csv b/rudict/grammar_case_adjective.csv index c5ba587..89e54dc 100644 --- a/rudict/grammar_case_adjective.csv +++ b/rudict/grammar_case_adjective.csv @@ -1,8 +1,8 @@ Склонение;Род;Падеж;Окончание;Пример -IFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ий;рабочий +IFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ий, ой;рабочий ;;NGC_P2_GENITIVE;его;подарок для рабочего ;;NGC_P3_DATIVE;ему;подарок рабочему -;;NGC_P4_ACCUSATIVE;ий;обвиняю рабочий +;;NGC_P4_ACCUSATIVE;ий, ой;обвиняю рабочий ;;NGC_P5_INSTRUMENTAL;им;говорю с рабочим ;;NGC_P6_PREPOSITIONAL;ем;говорю о рабочем ;NC_PLURAL;NGC_P1_NOMINATIVE;ие;рабочие @@ -11,7 +11,7 @@ IFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ий;рабочий ;;NGC_P4_ACCUSATIVE;ие;обвиняю рабочие ;;NGC_P5_INSTRUMENTAL;ими;говорю с рабочими ;;NGC_P6_PREPOSITIONAL;их;говорю о рабочих -IFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ий;рабочий +IFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ий, ой;рабочий ;;NGC_P2_GENITIVE;его;подарок для рабочего ;;NGC_P3_DATIVE;ему;подарок рабочему ;;NGC_P4_ACCUSATIVE;его;обвиняю рабочего @@ -23,7 +23,31 @@ IFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ий;рабочий ;;NGC_P4_ACCUSATIVE;их;обвиняю рабочих ;;NGC_P5_INSTRUMENTAL;ими;говорю с рабочими ;;NGC_P6_PREPOSITIONAL;их;говорю о рабочих -UOFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой, ый;деловой +UFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ый;меловый +;;NGC_P2_GENITIVE;ого;подарок для мелового +;;NGC_P3_DATIVE;ому;подарок меловому +;;NGC_P4_ACCUSATIVE;ый;обвиняю меловый +;;NGC_P5_INSTRUMENTAL;ым;говорю с меловым +;;NGC_P6_PREPOSITIONAL;ом;говорю о меловом +;NC_PLURAL;NGC_P1_NOMINATIVE;ые;меловые +;;NGC_P2_GENITIVE;ых;подарок для меловых +;;NGC_P3_DATIVE;ым;подарок меловым +;;NGC_P4_ACCUSATIVE;ые;обвиняю меловые +;;NGC_P5_INSTRUMENTAL;ыми;говорю с меловыми +;;NGC_P6_PREPOSITIONAL;ых;говорю о меловых +UFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ый;меловой +;;NGC_P2_GENITIVE;ого;подарок для мелового +;;NGC_P3_DATIVE;ому;подарок меловому +;;NGC_P4_ACCUSATIVE;ого;обвиняю мелового +;;NGC_P5_INSTRUMENTAL;ым;говорю с меловым +;;NGC_P6_PREPOSITIONAL;ом;говорю о меловом +;NC_PLURAL;NGC_P1_NOMINATIVE;ые;меловые +;;NGC_P2_GENITIVE;ых;подарок для меловых +;;NGC_P3_DATIVE;ым;подарок меловым +;;NGC_P4_ACCUSATIVE;ые;обвиняю меловые +;;NGC_P5_INSTRUMENTAL;ыми;говорю с меловыми +;;NGC_P6_PREPOSITIONAL;ых;говорю о меловых +UOFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой;деловой ;;NGC_P2_GENITIVE;ого;подарок для делового ;;NGC_P3_DATIVE;ому;подарок деловому ;;NGC_P4_ACCUSATIVE;ой;обвиняю деловой @@ -35,7 +59,7 @@ UOFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой, ый;деловой ;;NGC_P4_ACCUSATIVE;ые;обвиняю деловые ;;NGC_P5_INSTRUMENTAL;ыми;говорю с деловыми ;;NGC_P6_PREPOSITIONAL;ых;говорю о деловых -UOFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой, ый;деловой +UOFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой;деловой ;;NGC_P2_GENITIVE;ого;подарок для делового ;;NGC_P3_DATIVE;ому;подарок деловому ;;NGC_P4_ACCUSATIVE;ого;обвиняю делового @@ -47,6 +71,30 @@ UOFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой, ый;деловой ;;NGC_P4_ACCUSATIVE;ые;обвиняю деловые ;;NGC_P5_INSTRUMENTAL;ыми;говорю с деловыми ;;NGC_P6_PREPOSITIONAL;ых;говорю о деловых +IOFORM_MALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой;другой +;;NGC_P2_GENITIVE;ого;подарок для другого +;;NGC_P3_DATIVE;ому;подарок другому +;;NGC_P4_ACCUSATIVE;ой;обвиняю другой +;;NGC_P5_INSTRUMENTAL;им;говорю с другим +;;NGC_P6_PREPOSITIONAL;ом;говорю о другом +;NC_PLURAL;NGC_P1_NOMINATIVE;ие;другие +;;NGC_P2_GENITIVE;их;подарок для других +;;NGC_P3_DATIVE;им;подарок другим +;;NGC_P4_ACCUSATIVE;ие;обвиняю другие +;;NGC_P5_INSTRUMENTAL;ихи;говорю с другими +;;NGC_P6_PREPOSITIONAL;их;говорю о других +IOFORM_MALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ой;другой +;;NGC_P2_GENITIVE;ого;подарок для другого +;;NGC_P3_DATIVE;ому;подарок другому +;;NGC_P4_ACCUSATIVE;ого;обвиняю другого +;;NGC_P5_INSTRUMENTAL;им;говорю с другим +;;NGC_P6_PREPOSITIONAL;ом;говорю о другом +;NC_PLURAL;NGC_P1_NOMINATIVE;ие;другие +;;NGC_P2_GENITIVE;их;подарок для других +;;NGC_P3_DATIVE;им;подарок другим +;;NGC_P4_ACCUSATIVE;их;обвиняю других +;;NGC_P5_INSTRUMENTAL;ихи;говорю с другими +;;NGC_P6_PREPOSITIONAL;их;говорю о других IFORM_FEMALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;рабочая ;;NGC_P2_GENITIVE;ей;подарок для рабочей ;;NGC_P3_DATIVE;ей;подарок рабочей @@ -71,6 +119,30 @@ IFORM_FEMALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;рабочая ;;NGC_P4_ACCUSATIVE;их;обвиняю рабочих ;;NGC_P5_INSTRUMENTAL;ими;говорю с рабочими ;;NGC_P6_PREPOSITIONAL;их;говорю о рабочих +UFORM_FEMALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;меловая +;;NGC_P2_GENITIVE;ой;подарок для меловой +;;NGC_P3_DATIVE;ой;подарок меловой +;;NGC_P4_ACCUSATIVE;ую;обвиняю меловую +;;NGC_P5_INSTRUMENTAL;ой;говорю с меловой +;;NGC_P6_PREPOSITIONAL;ой;говорю о меловой +;NC_PLURAL;NGC_P1_NOMINATIVE;ые;меловые +;;NGC_P2_GENITIVE;ых;подарок для меловых +;;NGC_P3_DATIVE;ым;подарок меловым +;;NGC_P4_ACCUSATIVE;ые;обвиняю меловые +;;NGC_P5_INSTRUMENTAL;ыми;говорю с меловыми +;;NGC_P6_PREPOSITIONAL;ых;говорю о меловых +UFORM_FEMALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;меловая +;;NGC_P2_GENITIVE;ой;подарок для меловой +;;NGC_P3_DATIVE;ой;подарок меловой +;;NGC_P4_ACCUSATIVE;ую;обвиняю меловую +;;NGC_P5_INSTRUMENTAL;ой;говорю с меловой +;;NGC_P6_PREPOSITIONAL;ой;говорю о меловой +;NC_PLURAL;NGC_P1_NOMINATIVE;ые;меловые +;;NGC_P2_GENITIVE;ых;подарок для меловых +;;NGC_P3_DATIVE;ым;подарок меловым +;;NGC_P4_ACCUSATIVE;ых;обвиняю меловых +;;NGC_P5_INSTRUMENTAL;ыми;говорю с меловыми +;;NGC_P6_PREPOSITIONAL;ых;говорю о меловых UOFORM_FEMALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;деловая ;;NGC_P2_GENITIVE;ой;подарок для деловой ;;NGC_P3_DATIVE;ой;подарок деловой @@ -92,9 +164,33 @@ UOFORM_FEMALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;деловая ;NC_PLURAL;NGC_P1_NOMINATIVE;ые;деловые ;;NGC_P2_GENITIVE;ых;подарок для деловых ;;NGC_P3_DATIVE;ым;подарок деловым -;;NGC_P4_ACCUSATIVE;ые;обвиняю деловые +;;NGC_P4_ACCUSATIVE;ых;обвиняю деловых ;;NGC_P5_INSTRUMENTAL;ыми;говорю с деловыми ;;NGC_P6_PREPOSITIONAL;ых;говорю о деловых +IOFORM_FEMALE_INANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;другая +;;NGC_P2_GENITIVE;ой;подарок для другой +;;NGC_P3_DATIVE;ой;подарок другой +;;NGC_P4_ACCUSATIVE;ую;обвиняю другую +;;NGC_P5_INSTRUMENTAL;ой;говорю с другой +;;NGC_P6_PREPOSITIONAL;ой;говорю о другой +;NC_PLURAL;NGC_P1_NOMINATIVE;ие;другие +;;NGC_P2_GENITIVE;их;подарок для других +;;NGC_P3_DATIVE;им;подарок другим +;;NGC_P4_ACCUSATIVE;ие;обвиняю другие +;;NGC_P5_INSTRUMENTAL;ими;говорю с другими +;;NGC_P6_PREPOSITIONAL;их;говорю о других +IOFORM_FEMALE_ANIMATE;NC_SINGULAR;NGC_P1_NOMINATIVE;ая;другая +;;NGC_P2_GENITIVE;ой;подарок для другой +;;NGC_P3_DATIVE;ой;подарок другой +;;NGC_P4_ACCUSATIVE;ую;обвиняю другую +;;NGC_P5_INSTRUMENTAL;ой;говорю с другой +;;NGC_P6_PREPOSITIONAL;ой;говорю о другой +;NC_PLURAL;NGC_P1_NOMINATIVE;ие;другие +;;NGC_P2_GENITIVE;их;подарок для других +;;NGC_P3_DATIVE;им;подарок другим +;;NGC_P4_ACCUSATIVE;ие;обвиняю других +;;NGC_P5_INSTRUMENTAL;ими;говорю с другими +;;NGC_P6_PREPOSITIONAL;их;говорю о других IFORM_NEUTRAL;NC_SINGULAR;NGC_P1_NOMINATIVE;ее;рабочее ;;NGC_P2_GENITIVE;его;подарок для рабочего ;;NGC_P3_DATIVE;ему;подарок рабочему @@ -107,6 +203,18 @@ IFORM_NEUTRAL;NC_SINGULAR;NGC_P1_NOMINATIVE;ее;рабочее ;;NGC_P4_ACCUSATIVE;ие;обвиняю рабочие ;;NGC_P5_INSTRUMENTAL;ими;говорю с рабочими ;;NGC_P6_PREPOSITIONAL;их;говорю о рабочих +UFORM_NEUTRAL;NC_SINGULAR;NGC_P1_NOMINATIVE;ое;меловое +;;NGC_P2_GENITIVE;ого;подарок для мелового +;;NGC_P3_DATIVE;ому;подарок меловому +;;NGC_P4_ACCUSATIVE;ое;обвиняю меловое +;;NGC_P5_INSTRUMENTAL;ым;говорю с меловым +;;NGC_P6_PREPOSITIONAL;ом;говорю о меловом +;NC_PLURAL;NGC_P1_NOMINATIVE;ые;меловые +;;NGC_P2_GENITIVE;ых;подарок для меловых +;;NGC_P3_DATIVE;ым;подарок меловым +;;NGC_P4_ACCUSATIVE;ые;обвиняю меловые +;;NGC_P5_INSTRUMENTAL;ыми;говорю с меловыми +;;NGC_P6_PREPOSITIONAL;ых;говорю о меловых UOFORM_NEUTRAL;NC_SINGULAR;NGC_P1_NOMINATIVE;ое;деловое ;;NGC_P2_GENITIVE;ого;подарок для делового ;;NGC_P3_DATIVE;ому;подарок деловому @@ -119,3 +227,15 @@ UOFORM_NEUTRAL;NC_SINGULAR;NGC_P1_NOMINATIVE;ое;деловое ;;NGC_P4_ACCUSATIVE;ые;обвиняю деловые ;;NGC_P5_INSTRUMENTAL;ыми;говорю с деловыми ;;NGC_P6_PREPOSITIONAL;ых;говорю о деловых +IOFORM_NEUTRAL;NC_SINGULAR;NGC_P1_NOMINATIVE;ое;другое +;;NGC_P2_GENITIVE;ого;подарок для другого +;;NGC_P3_DATIVE;ому;подарок другому +;;NGC_P4_ACCUSATIVE;ое;обвиняю другое +;;NGC_P5_INSTRUMENTAL;им;говорю с другим +;;NGC_P6_PREPOSITIONAL;ом;говорю о другом +;NC_PLURAL;NGC_P1_NOMINATIVE;ие;другие +;;NGC_P2_GENITIVE;их;подарок для других +;;NGC_P3_DATIVE;им;подарок другим +;;NGC_P4_ACCUSATIVE;ие;обвиняю другие +;;NGC_P5_INSTRUMENTAL;ими;говорю с другими +;;NGC_P6_PREPOSITIONAL;их;говорю о других diff --git a/rudict/grammar_case_adjective.xlsx b/rudict/grammar_case_adjective.xlsx index 810a100..98819a5 100644 Binary files a/rudict/grammar_case_adjective.xlsx and b/rudict/grammar_case_adjective.xlsx differ diff --git a/rudict/rudict/adjective.cpp b/rudict/rudict/adjective.cpp index e5c81a9..2cf10be 100644 --- a/rudict/rudict/adjective.cpp +++ b/rudict/rudict/adjective.cpp @@ -1,5 +1,5 @@ -#include "adjective.h" -#include +#include "adjective.h" +#include #include //Xperimental -- for debug only @@ -7,115 +7,157 @@ #include "boost/regex.hpp" #include "boost/algorithm/string/regex.hpp" - -namespace AJ -{ - - std::vector AdjectiveRecordArr; - + +namespace AJ +{ + + std::vector AdjectiveRecordArr; + std::vector adjectiveDeclencionCaseTable; - - - AdjectiveRecord::AdjectiveRecord() - : standardShortFormAvailable(false) - { - - } - - AdjectiveRecord::AdjectiveRecord(std::wstring line) - { + + + AdjectiveRecord::AdjectiveRecord() + : standardShortFormAvailable(false) + { + + } + + AdjectiveRecord::AdjectiveRecord(std::wstring line) + { std::vector lineArr; boost::split_regex(lineArr, line, boost::wregex(L";")); nominativeMaleForm = lineArr[1]; - standardShortFormAvailable = lineArr[2] == L"1" ? true : false; - + standardShortFormAvailable = lineArr[2] == L"1" ? true : false; + specialShortForm = lineArr[3]; - - } - - - std::vector GetAllAdjectiveEndingArr() - { - std::vector result; - - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - result.push_back(L""); - - return result; - } - - AdjectiveDeclencion WStringToAdjectiveDeclencion(std::wstring str) + + } + + + std::vector GetAllAdjectiveEndingArr() + { + std::vector result; + + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + result.push_back(L""); + + return result; + } + + AdjectiveDeclencion WStringToAdjectiveDeclencion(std::wstring str) { if (str == L"IFORM_MALE_INANIMATE") { return IFORM_MALE_INANIMATE; - } + } if (str == L"IFORM_MALE_ANIMATE") { return IFORM_MALE_ANIMATE; - } + } + if (str == L"UFORM_MALE_INANIMATE") + { + return UFORM_MALE_INANIMATE; + } + if (str == L"UFORM_MALE_ANIMATE") + { + return UFORM_MALE_ANIMATE; + } if (str == L"UOFORM_MALE_INANIMATE") { return UOFORM_MALE_INANIMATE; - } + } if (str == L"UOFORM_MALE_ANIMATE") { return UOFORM_MALE_ANIMATE; - } - + } + if (str == L"IOFORM_MALE_INANIMATE") + { + return IOFORM_MALE_INANIMATE; + } + if (str == L"IOFORM_MALE_ANIMATE") + { + return IOFORM_MALE_ANIMATE; + } + if (str == L"IFORM_FEMALE_INANIMATE") { return IFORM_FEMALE_INANIMATE; - } + } if (str == L"IFORM_FEMALE_ANIMATE") { return IFORM_FEMALE_ANIMATE; - } + } + if (str == L"UFORM_FEMALE_INANIMATE") + { + return UFORM_FEMALE_INANIMATE; + } + if (str == L"UFORM_FEMALE_ANIMATE") + { + return UFORM_FEMALE_ANIMATE; + } if (str == L"UOFORM_FEMALE_INANIMATE") { return UOFORM_FEMALE_INANIMATE; - } + } if (str == L"UOFORM_FEMALE_ANIMATE") { return UOFORM_FEMALE_ANIMATE; - } - + } + if (str == L"IOFORM_FEMALE_INANIMATE") + { + return IOFORM_FEMALE_INANIMATE; + } + if (str == L"IOFORM_FEMALE_ANIMATE") + { + return IOFORM_FEMALE_ANIMATE; + } + + + if (str == L"IFORM_NEUTRAL") { return IFORM_NEUTRAL; - } + } + if (str == L"UFORM_NEUTRAL") + { + return UFORM_NEUTRAL; + } if (str == L"UOFORM_NEUTRAL") { return UOFORM_NEUTRAL; - } - - std::cout << "Error in WStringToAdjectiveDeclencion"; - return IFORM_MALE_INANIMATE; - } - + } + if (str == L"IOFORM_NEUTRAL") + { + return IOFORM_NEUTRAL; + } + + std::cout << "Error in WStringToAdjectiveDeclencion"; + return IFORM_MALE_INANIMATE; + } + std::set getPossibleAdjectiveEndingDivisionSet(std::wstring noun) { std::set result; @@ -139,12 +181,12 @@ namespace AJ } return result; - } - - std::vector GetPossibleTupleArr(std::wstring ending) - { - std::vector result; - + } + + std::vector GetPossibleTupleArr(std::wstring ending) + { + std::vector result; + for (auto& adjective : adjectiveDeclencionCaseTable) { for (int i = 0; i < NGC_SIZE * NC_SIZE; i++) @@ -155,11 +197,11 @@ namespace AJ } } - } - - return result; - } - + } + + return result; + } + bool AdjectiveIsInDictionary(std::wstring nominative) { for (auto& adjective : AdjectiveRecordArr) @@ -185,11 +227,11 @@ namespace AJ return{}; } - - - /* - std::set GetAdjectiveNominative(std::wstring base, AdjectiveDeclencion declencion, NounCount nounCount) - { + + + /* + std::set GetAdjectiveNominative(std::wstring base, AdjectiveDeclencion declencion, NounCount nounCount) + { std::set result; AdjectiveDeclencionCaseTableRecord declencionCaseTableRecord = adjectiveDeclencionCaseTable[static_cast(declencion)]; @@ -206,16 +248,16 @@ namespace AJ } } - return result; - }*/ - - std::set GetNominativeMaleSingular(std::wstring base) - { + return result; + }*/ + + std::set GetNominativeMaleSingular(std::wstring base) + { std::wstring result; if (charIsIFormConsolant(base[base.size() - 1])) { - return{ base + L"" }; + return{ base + L"", base + L"" }; } if (charIsUFormConsolant(base[base.size() - 1])) @@ -224,59 +266,71 @@ namespace AJ } return{}; - - } - - bool IsDeclencionAnimated(AdjectiveDeclencion declention) - { - switch (declention) - { - case AJ::IFORM_MALE_ANIMATE: - case AJ::UOFORM_MALE_ANIMATE: - case AJ::IFORM_FEMALE_ANIMATE: - case AJ::UOFORM_FEMALE_ANIMATE: - return true; - break; - default: - return false; - break; - } - } - - - NounGender GetGenderFromDeclencion(AdjectiveDeclencion declention) - { - switch (declention) - { - case AJ::IFORM_MALE_INANIMATE: - case AJ::IFORM_MALE_ANIMATE: - case AJ::UOFORM_MALE_INANIMATE: - case AJ::UOFORM_MALE_ANIMATE: - return NG_MALE; - break; - case AJ::IFORM_FEMALE_INANIMATE: - case AJ::IFORM_FEMALE_ANIMATE: - case AJ::UOFORM_FEMALE_INANIMATE: - case AJ::UOFORM_FEMALE_ANIMATE: - return NG_FEMALE; - break; - default: - return NG_NEUTRAL; - break; - } - } - - - bool IFormTest(const AdjectiveRecord& r) - { - return charIsIFormConsolant(r.nominativeMaleForm[r.nominativeMaleForm.size() - 3]); - } - - bool UOFormTest(const AdjectiveRecord& r) - { - return charIsUFormConsolant(r.nominativeMaleForm[r.nominativeMaleForm.size() - 3]); - } - + + } + + bool IsDeclencionAnimated(AdjectiveDeclencion declention) + { + switch (declention) + { + case AJ::IFORM_MALE_ANIMATE: + case AJ::UFORM_MALE_ANIMATE: + case AJ::UOFORM_MALE_ANIMATE: + case AJ::IOFORM_MALE_ANIMATE: + case AJ::IFORM_FEMALE_ANIMATE: + case AJ::UFORM_FEMALE_ANIMATE: + case AJ::UOFORM_FEMALE_ANIMATE: + case AJ::IOFORM_FEMALE_ANIMATE: + return true; + break; + default: + return false; + break; + } + } + + + NounGender GetGenderFromDeclencion(AdjectiveDeclencion declention) + { + switch (declention) + { + case AJ::IFORM_MALE_INANIMATE: + case AJ::IFORM_MALE_ANIMATE: + case AJ::UFORM_MALE_INANIMATE: + case AJ::UFORM_MALE_ANIMATE: + case AJ::UOFORM_MALE_INANIMATE: + case AJ::UOFORM_MALE_ANIMATE: + case AJ::IOFORM_MALE_INANIMATE: + case AJ::IOFORM_MALE_ANIMATE: + return NG_MALE; + break; + case AJ::IFORM_FEMALE_INANIMATE: + case AJ::IFORM_FEMALE_ANIMATE: + case AJ::UFORM_FEMALE_INANIMATE: + case AJ::UFORM_FEMALE_ANIMATE: + case AJ::UOFORM_FEMALE_INANIMATE: + case AJ::UOFORM_FEMALE_ANIMATE: + case AJ::IOFORM_FEMALE_INANIMATE: + case AJ::IOFORM_FEMALE_ANIMATE: + return NG_FEMALE; + break; + default: + return NG_NEUTRAL; + break; + } + } + + + bool IFormTest(const AdjectiveRecord& r) + { + return charIsIFormConsolant(r.nominativeMaleForm[r.nominativeMaleForm.size() - 3]); + } + + bool UFormTest(const AdjectiveRecord& r) + { + return charIsUFormConsolant(r.nominativeMaleForm[r.nominativeMaleForm.size() - 3]); + } + std::map> DeclentionConditionMap; @@ -285,20 +339,31 @@ namespace AJ DeclentionConditionMap[IFORM_MALE_INANIMATE] = std::bind(IFormTest, std::placeholders::_1); DeclentionConditionMap[IFORM_MALE_ANIMATE] = std::bind(IFormTest, std::placeholders::_1); - DeclentionConditionMap[UOFORM_MALE_INANIMATE] = std::bind(UOFormTest, std::placeholders::_1); - DeclentionConditionMap[UOFORM_MALE_ANIMATE] = std::bind(UOFormTest, std::placeholders::_1); + DeclentionConditionMap[UFORM_MALE_INANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[UFORM_MALE_ANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[UOFORM_MALE_INANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[UOFORM_MALE_ANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[IOFORM_MALE_INANIMATE] = std::bind(IFormTest, std::placeholders::_1); + DeclentionConditionMap[IOFORM_MALE_ANIMATE] = std::bind(IFormTest, std::placeholders::_1); DeclentionConditionMap[IFORM_FEMALE_INANIMATE] = std::bind(IFormTest, std::placeholders::_1); DeclentionConditionMap[IFORM_FEMALE_ANIMATE] = std::bind(IFormTest, std::placeholders::_1); - DeclentionConditionMap[UOFORM_FEMALE_INANIMATE] = std::bind(UOFormTest, std::placeholders::_1); - DeclentionConditionMap[UOFORM_FEMALE_ANIMATE] = std::bind(UOFormTest, std::placeholders::_1); + DeclentionConditionMap[UFORM_FEMALE_INANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[UFORM_FEMALE_ANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[IOFORM_FEMALE_INANIMATE] = std::bind(IFormTest, std::placeholders::_1); + DeclentionConditionMap[IOFORM_FEMALE_ANIMATE] = std::bind(IFormTest, std::placeholders::_1); + DeclentionConditionMap[UOFORM_FEMALE_INANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[UOFORM_FEMALE_ANIMATE] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[IFORM_NEUTRAL] = std::bind(IFormTest, std::placeholders::_1); - DeclentionConditionMap[UOFORM_NEUTRAL] = std::bind(UOFormTest, std::placeholders::_1); + DeclentionConditionMap[UFORM_NEUTRAL] = std::bind(UFormTest, std::placeholders::_1); + DeclentionConditionMap[IOFORM_NEUTRAL] = std::bind(IFormTest, std::placeholders::_1); + DeclentionConditionMap[UOFORM_NEUTRAL] = std::bind(UFormTest, std::placeholders::_1); - } - + } + bool AdjectiveFitsDeclention(AdjectiveRecord record, AdjectiveTuple tuple) { @@ -312,7 +377,7 @@ namespace AJ } return false; - } + } std::map < AdjectiveEndingDivision::DivisionCase, std::function < bool(AdjectiveTuple) >> DivisionCaseAdjectiveTupleFilterMap; @@ -332,16 +397,16 @@ namespace AJ return AdjectiveFitsDeclention(record, tuple); }; - } - - std::set RecognizeAdjective(std::wstring noun) - { + } + + std::set RecognizeAdjective(std::wstring noun) + { std::set result; auto adjectiveEndingDivisionArr = getPossibleAdjectiveEndingDivisionSet(noun); for (auto adjectiveEndingDivision : adjectiveEndingDivisionArr) - { + { std::wstring base = adjectiveEndingDivision.base; std::wstring ending = adjectiveEndingDivision.ending; AdjectiveEndingDivision::DivisionCase dc = adjectiveEndingDivision.divisionCase; @@ -350,11 +415,11 @@ namespace AJ std::wstring modifiedEnding = ending; std::vector possibleTupleArr = GetPossibleTupleArr(modifiedEnding); - + for (AdjectiveTuple tuple : possibleTupleArr) - { + { if (DivisionCaseAdjectiveTupleFilterMap[dc](tuple)) - { + { std::set nominaviteSingularSet = GetNominativeMaleSingular(modifiedBase); for (auto& nn : nominaviteSingularSet) @@ -371,16 +436,16 @@ namespace AJ } } - } - - } - } - - } - - return result; - } - + } + + } + } + + } + + return result; + } + void LoadAdjectiveDeclencionCaseTable() { @@ -461,8 +526,8 @@ namespace AJ } - } - + } + void LoadFrequentAdjectiveSet() { @@ -500,8 +565,8 @@ namespace AJ } - } - - -} //namespace AJ - + } + + +} //namespace AJ + diff --git a/rudict/rudict/adjective.h b/rudict/rudict/adjective.h index 728932b..38a69f1 100644 --- a/rudict/rudict/adjective.h +++ b/rudict/rudict/adjective.h @@ -89,14 +89,24 @@ namespace AJ { IFORM_MALE_INANIMATE = 0, IFORM_MALE_ANIMATE, + UFORM_MALE_INANIMATE, + UFORM_MALE_ANIMATE, UOFORM_MALE_INANIMATE, UOFORM_MALE_ANIMATE, + IOFORM_MALE_INANIMATE, + IOFORM_MALE_ANIMATE, IFORM_FEMALE_INANIMATE, IFORM_FEMALE_ANIMATE, + UFORM_FEMALE_INANIMATE, + UFORM_FEMALE_ANIMATE, UOFORM_FEMALE_INANIMATE, UOFORM_FEMALE_ANIMATE, + IOFORM_FEMALE_INANIMATE, + IOFORM_FEMALE_ANIMATE, IFORM_NEUTRAL, + UFORM_NEUTRAL, UOFORM_NEUTRAL, + IOFORM_NEUTRAL, }; diff --git a/rudict/rudict/grammarCase.cpp b/rudict/rudict/grammarCase.cpp index fcc29a8..e05a0e7 100644 --- a/rudict/rudict/grammarCase.cpp +++ b/rudict/rudict/grammarCase.cpp @@ -1,6 +1,6 @@ -#include "grammarCase.h" - -#include +#include "grammarCase.h" + +#include NounCount WStringToNounCount(std::wstring str) { @@ -78,10 +78,10 @@ NounGrammaticalCase WStringToNounGrammaticalCase(std::wstring str) std::cout << "Error in WStringToNounGrammaticalCase!" << std::endl; return NGC_P1_NOMINATIVE; -} - - - +} + + + bool charIsConsolant(wchar_t c) //except { diff --git a/rudict/rudict/http/request_handler.cpp b/rudict/rudict/http/request_handler.cpp index 79421bd..d87c27e 100644 --- a/rudict/rudict/http/request_handler.cpp +++ b/rudict/rudict/http/request_handler.cpp @@ -152,8 +152,6 @@ namespace http { std::set nounStructArr = NN::RecognizeNoun(request); - std::cout <<"nounstructarr" << nounStructArr.size() << std::endl; - id = 0; boost::property_tree::wptree nounArr; @@ -163,25 +161,26 @@ namespace http { boost::property_tree::wptree nounTree; nounTree.put(L"id", id); - nounTree.put(L"grammaticalCase", NounGrammaticalCaseToWString(nounStruct.nounGrammaticalCase)); - nounTree.put(L"animated", nounStruct.animated); - nounTree.put(L"count", NounCountToWString(nounStruct.nounCount)); - nounTree.put(L"canBeAnimate", nounStruct.nounRecord.canBeAnimate); - nounTree.put(L"canBeInanimate", nounStruct.nounRecord.canBeInanimate); - nounTree.put(L"gender", nounStruct.nounRecord.gender); - nounTree.put(L"haveMultipleForm", nounStruct.nounRecord.haveMultipleForm); - nounTree.put(L"haveSingleForm", nounStruct.nounRecord.haveSingleForm); - nounTree.put(L"haveStandardMultipleForm", nounStruct.nounRecord.haveStandardMultipleForm); - nounTree.put(L"haveStandardMultipleFormWithMissingLastVowel", nounStruct.nounRecord.haveStandardMultipleFormWithMissingLastVowel); - nounTree.put(L"specialMultipleForm", nounStruct.nounRecord.specialMultipleForm); + nounTree.put(L"word", "noun"); + nounTree.put(L"noun.grammaticalCase", NounGrammaticalCaseToWString(nounStruct.nounGrammaticalCase)); + nounTree.put(L"noun.animated", nounStruct.animated); + nounTree.put(L"noun.count", NounCountToWString(nounStruct.nounCount)); + nounTree.put(L"noun.canBeAnimate", nounStruct.nounRecord.canBeAnimate); + nounTree.put(L"noun.canBeInanimate", nounStruct.nounRecord.canBeInanimate); + nounTree.put(L"noun.gender", nounStruct.nounRecord.gender); + nounTree.put(L"noun.haveMultipleForm", nounStruct.nounRecord.haveMultipleForm); + nounTree.put(L"noun.haveSingleForm", nounStruct.nounRecord.haveSingleForm); + nounTree.put(L"noun.haveStandardMultipleForm", nounStruct.nounRecord.haveStandardMultipleForm); + nounTree.put(L"noun.haveStandardMultipleFormWithMissingLastVowel", nounStruct.nounRecord.haveStandardMultipleFormWithMissingLastVowel); + nounTree.put(L"noun.specialMultipleForm", nounStruct.nounRecord.specialMultipleForm); - nounTree.put(L"nominativeSingularForm", nounStruct.nounRecord.nominativeForm); + nounTree.put(L"noun.nominativeSingularForm", nounStruct.nounRecord.nominativeForm); nounArr.push_back(std::make_pair(L"", nounTree)); id++; } - result.put_child(L"nouns", nounArr); + //result.put_child(L"words", nounArr); //Adjective! @@ -189,27 +188,27 @@ namespace http { id = 0; - boost::property_tree::wptree adjectiveArr; for (auto& adjectiveStruct : adjectiveStructArr) { boost::property_tree::wptree adjectivrTree; adjectivrTree.put(L"id", id); - adjectivrTree.put(L"grammaticalCase", NounGrammaticalCaseToWString(adjectiveStruct.grammaticalCase)); - adjectivrTree.put(L"animated", adjectiveStruct.isDeclentionAnimated); - adjectivrTree.put(L"count", NounCountToWString(adjectiveStruct.count)); + adjectivrTree.put(L"word", "adjective"); + adjectivrTree.put(L"adjective.grammaticalCase", NounGrammaticalCaseToWString(adjectiveStruct.grammaticalCase)); + adjectivrTree.put(L"adjective.animated", adjectiveStruct.isDeclentionAnimated); + adjectivrTree.put(L"adjective.count", NounCountToWString(adjectiveStruct.count)); - adjectivrTree.put(L"gender", adjectiveStruct.gender); + adjectivrTree.put(L"adjective.gender", adjectiveStruct.gender); + + adjectivrTree.put(L"adjective.nominativeSingularForm", adjectiveStruct.adjectiveRecord.nominativeMaleForm); - adjectivrTree.put(L"nominativeSingularForm", adjectiveStruct.adjectiveRecord.nominativeMaleForm); - - adjectiveArr.push_back(std::make_pair(L"", adjectivrTree)); + nounArr.push_back(std::make_pair(L"", adjectivrTree)); id++; } - result.put_child(L"adjectives", adjectiveArr); + result.put_child(L"words", nounArr); diff --git a/rudict/rudict/linux/makefile b/rudict/rudict/linux/makefile index db4eebd..93404bd 100644 --- a/rudict/rudict/linux/makefile +++ b/rudict/rudict/linux/makefile @@ -74,6 +74,8 @@ LOCAL_SRC_FILES += ../http/server.cpp LOCAL_SRC_FILES += ../utf8utf16.cpp LOCAL_SRC_FILES += ../noun.cpp +LOCAL_SRC_FILES += ../adjective.cpp +LOCAL_SRC_FILES += ../grammarCase.cpp LOCAL_SRC_FILES += ../main.cpp