TITANIC: DE: Fix recognising words with common suffixes

This commit is contained in:
Paul Gilbert 2017-10-06 20:37:28 -04:00
parent 223867b2f5
commit 9b51c1dbbd
2 changed files with 8 additions and 8 deletions

View File

@ -182,10 +182,10 @@ TTword *TTvocab::getWord(TTstring &str, TTword **srcWord) const {
if (!word) { if (!word) {
TTstring tempStr(str); TTstring tempStr(str);
if (tempStr.size() > 2) { if (tempStr.size() > 2) {
word = getSuffixedWord(tempStr); word = getSuffixedWord(tempStr, srcWord);
if (!word) if (!word)
word = getPrefixedWord(tempStr); word = getPrefixedWord(tempStr, srcWord);
} }
} }
@ -230,11 +230,11 @@ TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
return newWord; return newWord;
} }
TTword *TTvocab::getSuffixedWord(TTstring &str) const { TTword *TTvocab::getSuffixedWord(TTstring &str, TTword **srcWord) const {
TTstring tempStr(str); TTstring tempStr(str);
TTword *word = nullptr; TTword *word = nullptr;
if (g_vm->isGerman()) { if (g_language == Common::DE_DEU) {
static const char *const SUFFIXES[11] = { static const char *const SUFFIXES[11] = {
"est", "em", "en", "er", "es", "et", "st", "est", "em", "en", "er", "es", "et", "st",
"s", "e", "n", "t" "s", "e", "n", "t"
@ -243,7 +243,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const {
for (int idx = 0; idx < 11; ++idx) { for (int idx = 0; idx < 11; ++idx) {
if (tempStr.hasSuffix(SUFFIXES[idx])) { if (tempStr.hasSuffix(SUFFIXES[idx])) {
tempStr.deleteSuffix(strlen(SUFFIXES[idx])); tempStr.deleteSuffix(strlen(SUFFIXES[idx]));
word = getPrimeWord(tempStr); word = getPrimeWord(tempStr, srcWord);
if (word) if (word)
break; break;
tempStr = str; tempStr = str;
@ -514,7 +514,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const {
return word; return word;
} }
TTword *TTvocab::getPrefixedWord(TTstring &str) const { TTword *TTvocab::getPrefixedWord(TTstring &str, TTword **srcWord) const {
TTstring tempStr(str); TTstring tempStr(str);
TTword *word = nullptr; TTword *word = nullptr;
int prefixLen = 0; int prefixLen = 0;

View File

@ -68,7 +68,7 @@ private:
* @param str Word to check * @param str Word to check
* @returns New word instance for found match, or nullptr otherwise * @returns New word instance for found match, or nullptr otherwise
*/ */
TTword *getSuffixedWord(TTstring &str) const; TTword *getSuffixedWord(TTstring &str, TTword **srcWord = nullptr) const;
/** /**
* Checks the passed word for common prefixes, and checks for a word * Checks the passed word for common prefixes, and checks for a word
@ -76,7 +76,7 @@ private:
* @param str Word to check * @param str Word to check
* @returns New word instance for found match, or nullptr otherwise * @returns New word instance for found match, or nullptr otherwise
*/ */
TTword *getPrefixedWord(TTstring &str) const; TTword *getPrefixedWord(TTstring &str, TTword **srcWord = nullptr) const;
public: public:
TTvocab(VocabMode vocabMode); TTvocab(VocabMode vocabMode);
~TTvocab(); ~TTvocab();