@@ -10,7 +10,7 @@ public static class CaseCreator
1010 {
1111 private const string CasePath = "\\ Languages\\ Russian\\ WordInfo" ;
1212
13- private static List < string > WordsExtract ( string file )
13+ private static List < string > ExtractWords ( string file )
1414 {
1515 XDocument xDoc = XDocument . Load ( file , LoadOptions . PreserveWhitespace ) ;
1616 XElement root = xDoc . Element ( "LanguageData" ) ;
@@ -34,7 +34,7 @@ public static List<string> FindWordsProcessing(string currentFile, string defTyp
3434 // Если файл соответствует заданному defType, то запускатся в работу
3535 if ( currentFile . Contains ( defType , StringComparison . OrdinalIgnoreCase ) )
3636 {
37- words . AddRange ( WordsExtract ( currentFile ) ) ;
37+ words . AddRange ( ExtractWords ( currentFile ) ) ;
3838 }
3939 return words ;
4040 }
@@ -56,17 +56,17 @@ public static void CreateCase(string directoryPath, Dictionary<string, string> w
5656 }
5757
5858 string tempWord = word . Key ;
59- Words result = MorpherHttpClient . GetMorpherWords ( tempWord ) ;
59+ WordForms result = MorpherHttpClient . GetMorpherWords ( tempWord ) ;
6060 // Case.txt
6161 string tempStringCase = result is null
6262 ? $ "{ tempWord } ; { tempWord } ; { tempWord } ; { tempWord } ; { tempWord } ; { tempWord } "
63- : $ "{ tempWord } ; { result . Р } ; { result . Д } ; { result . В } ; { result . Т } ; { result . П } ";
63+ : $ "{ tempWord } ; { result . Genitive } ; { result . Dative } ; { result . Accusative } ; { result . Instrumental } ; { result . Prepositional } ";
6464 writerCase . WriteLine ( tempStringCase ) ;
6565
6666 // Plural.txt
6767 tempStringCase = result is null
6868 ? $ "{ tempWord } ; { tempWord } "
69- : result . множественное is null ? string . Empty : $ "{ tempWord } ; { result . множественное . И } ";
69+ : result . Plural is null ? string . Empty : $ "{ tempWord } ; { result . Plural . Nominative } ";
7070 writerPlural . WriteLine ( tempStringCase ) ;
7171 }
7272 writerCase . WriteLine ( ) ;
@@ -83,27 +83,79 @@ public static void CreateGender(string directoryPath, Dictionary<string, string>
8383 string pathGenderFemale = pathGender + "\\ Female.txt" ;
8484 StreamWriter writerFemale = new ( pathGenderFemale , true , System . Text . Encoding . UTF8 ) ;
8585 writerFemale . WriteLine ( "// " + defType ) ;
86+ foreach ( var word in words )
87+ {
88+ if ( word . Value != defType )
89+ {
90+ continue ;
91+ }
92+ else if ( word . Key . EndsWith ( "а" , StringComparison . OrdinalIgnoreCase ) || word . Key . EndsWith ( "я" , StringComparison . OrdinalIgnoreCase ) )
93+ {
94+ writerFemale . WriteLine ( word . Key ) ;
95+ words . Remove ( word . Key ) ;
96+ }
97+ }
8698 writerFemale . WriteLine ( ) ;
8799 writerFemale . Close ( ) ;
88100
89101 string pathGenderMale = pathGender + "\\ Male.txt" ;
90102 StreamWriter writerMale = new ( pathGenderMale , true , System . Text . Encoding . UTF8 ) ;
91103 writerMale . WriteLine ( "// " + defType ) ;
104+ foreach ( var word in words )
105+ {
106+ if ( word . Value != defType )
107+ {
108+ continue ;
109+ }
110+ else if ( ( ! word . Key . EndsWith ( "а" , StringComparison . OrdinalIgnoreCase ) ) && ( ! word . Key . EndsWith ( "я" , StringComparison . OrdinalIgnoreCase ) )
111+ && ( ! word . Key . EndsWith ( "о" , StringComparison . OrdinalIgnoreCase ) ) && ( ! word . Key . EndsWith ( "е" , StringComparison . OrdinalIgnoreCase ) )
112+ && ( ! word . Key . EndsWith ( "ы" , StringComparison . OrdinalIgnoreCase ) ) && ( ! word . Key . EndsWith ( "и" , StringComparison . OrdinalIgnoreCase ) ) )
113+ {
114+ writerMale . WriteLine ( word . Key ) ;
115+ words . Remove ( word . Key ) ;
116+ }
117+ }
92118 writerMale . WriteLine ( ) ;
93119 writerMale . Close ( ) ;
94120
95121 string pathGenderNeuter = pathGender + "\\ Neuter.txt" ;
96122 StreamWriter writerNeuter = new ( pathGenderNeuter , true , System . Text . Encoding . UTF8 ) ;
97123 writerNeuter . WriteLine ( "// " + defType ) ;
124+ foreach ( var word in words )
125+ {
126+ if ( word . Value != defType )
127+ {
128+ continue ;
129+ }
130+ else if ( word . Key . EndsWith ( "о" , StringComparison . OrdinalIgnoreCase ) || word . Key . EndsWith ( "е" , StringComparison . OrdinalIgnoreCase ) )
131+ {
132+ writerNeuter . WriteLine ( word . Key ) ;
133+ words . Remove ( word . Key ) ;
134+ }
135+ }
98136 writerNeuter . WriteLine ( ) ;
99137 writerNeuter . Close ( ) ;
100138
101139 string pathGenderPlural = pathGender + "\\ Plural.txt" ;
102140 StreamWriter writerPlural = new ( pathGenderPlural , true , System . Text . Encoding . UTF8 ) ;
103141 writerPlural . WriteLine ( "// " + defType ) ;
142+ foreach ( var word in words )
143+ {
144+ if ( word . Value != defType )
145+ {
146+ continue ;
147+ }
148+ else if ( word . Key . EndsWith ( "ы" , StringComparison . OrdinalIgnoreCase ) || word . Key . EndsWith ( "и" , StringComparison . OrdinalIgnoreCase ) )
149+ {
150+ writerPlural . WriteLine ( word . Key ) ;
151+ words . Remove ( word . Key ) ;
152+ }
153+ }
104154 writerPlural . WriteLine ( ) ;
105155 writerPlural . Close ( ) ;
106156
157+ if ( words . Count < 1 )
158+ return ;
107159 string pathGenderUndefined = pathGender + "\\ Undefined.txt" ;
108160 StreamWriter writerUndefined = new ( pathGenderUndefined , true , System . Text . Encoding . UTF8 ) ;
109161 writerUndefined . WriteLine ( "// " + defType ) ;
0 commit comments