コミットメタ情報

リビジョンa38c07adb06743ebda5bbdbb5366fbf80520e617 (tree)
日時2023-03-21 09:08:02
作者Sergey Gusarov <laborer2008@gmai...>
コミッターSergey Gusarov

ログメッセージ

Fixed calculation of gematria for phrases like "march 20"

変更サマリ

差分

diff -r d748d9d34657 -r a38c07adb067 src/calculator.cpp
--- a/src/calculator.cpp Tue Mar 21 02:16:20 2023 +0300
+++ b/src/calculator.cpp Tue Mar 21 03:08:02 2023 +0300
@@ -48,6 +48,8 @@
4848 }
4949
5050 //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+
5153 loadFile("/home/sergey/code/osdn/unspecified/gemcalc/resources/eng/generated_dates.txt", "english_dates");
5254 loadFile("/home/sergey/code/osdn/unspecified/gemcalc/resources/eng/generated_numerals.txt", "english_dates");
5355
@@ -110,9 +112,39 @@
110112 int sumReverseOrdinal = 0;
111113 int sumReduction = 0;
112114 int sumReverseReduction = 0;
115+ QString number;
113116
114- for (const QChar ch : convertedLine)
117+ for (int i = 0; i < convertedLine.size(); i++)
115118 {
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+
116148 if (supportedLanguage == SupportedLanguages::slEnglish)
117149 {
118150 value = englishOrdinal(ch);
旧リポジトリブラウザで表示