リビジョン | a38c07adb06743ebda5bbdbb5366fbf80520e617 (tree) |
---|---|
日時 | 2023-03-21 09:08:02 |
作者 | Sergey Gusarov <laborer2008@gmai...> |
コミッター | Sergey Gusarov |
Fixed calculation of gematria for phrases like "march 20"
@@ -48,6 +48,8 @@ | ||
48 | 48 | } |
49 | 49 | |
50 | 50 | //loadFile("/home/sergey/code/osdn/unspecified/gemcalc/resources/eng/words.lst", "english_dictionary"); |
51 | + //loadFile("/home/sergey/code/osdn/unspecified/gemcalc/resources/eng/may_14.txt", "english_custom_phrases"); | |
52 | + | |
51 | 53 | loadFile("/home/sergey/code/osdn/unspecified/gemcalc/resources/eng/generated_dates.txt", "english_dates"); |
52 | 54 | loadFile("/home/sergey/code/osdn/unspecified/gemcalc/resources/eng/generated_numerals.txt", "english_dates"); |
53 | 55 |
@@ -110,9 +112,39 @@ | ||
110 | 112 | int sumReverseOrdinal = 0; |
111 | 113 | int sumReduction = 0; |
112 | 114 | int sumReverseReduction = 0; |
115 | + QString number; | |
113 | 116 | |
114 | - for (const QChar ch : convertedLine) | |
117 | + for (int i = 0; i < convertedLine.size(); i++) | |
115 | 118 | { |
119 | + const QChar ch = convertedLine[i]; | |
120 | + | |
121 | + if (ch.isDigit()) | |
122 | + { | |
123 | + number += ch; | |
124 | + if (i < convertedLine.size() - 1) | |
125 | + continue; | |
126 | + } | |
127 | + | |
128 | + if (number.length() > 0) | |
129 | + { | |
130 | + bool ok; | |
131 | + int a = number.toInt(&ok); | |
132 | + | |
133 | + number = ""; | |
134 | + | |
135 | + if (ok) | |
136 | + { | |
137 | + sumOrdinal += a; | |
138 | + sumReduction += a; | |
139 | + sumReverseOrdinal += a; | |
140 | + sumReverseReduction += a; | |
141 | + } | |
142 | + else | |
143 | + { | |
144 | + CT_TRACE_ERRORN("Invalid phrase in the DB: %s", QTT_UTF8_PRINTABLE(convertedLine)); | |
145 | + } | |
146 | + } | |
147 | + | |
116 | 148 | if (supportedLanguage == SupportedLanguages::slEnglish) |
117 | 149 | { |
118 | 150 | value = englishOrdinal(ch); |