diff options
-rw-r--r-- | engines/titanic/true_talk/tt_vocab.cpp | 23 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_vocab.h | 24 |
2 files changed, 42 insertions, 5 deletions
diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp index 5145e4f1b9..5a52e75bb5 100644 --- a/engines/titanic/true_talk/tt_vocab.cpp +++ b/engines/titanic/true_talk/tt_vocab.cpp @@ -174,6 +174,22 @@ TTword *TTvocab::findWord(const TTstring &str) { return word;
}
+TTword *TTvocab::getWord(TTstring &str, TTword **srcWord) const {
+ TTword *word = getPrimeWord(str, srcWord);
+
+ if (!word) {
+ TTstring tempStr(str);
+ if (tempStr.size() > 2) {
+ word = getPluralizedWord(tempStr);
+
+ if (!word)
+ word = getPrefixedWord(tempStr);
+ }
+ }
+
+ return word;
+}
+
TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
TTsynonym tempSyn;
char c = str.charAt(0);
@@ -208,7 +224,12 @@ TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const { return newWord;
}
-TTword *TTvocab::getPrefixedWord(TTstring &str) {
+TTword *TTvocab::getPluralizedWord(TTstring &str) const {
+ // TODO
+ return nullptr;
+}
+
+TTword *TTvocab::getPrefixedWord(TTstring &str) const {
TTstring tempStr(str);
TTword *word = nullptr;
int prefixLen = 0;
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h index 8b2a080ce9..7da0db3e20 100644 --- a/engines/titanic/true_talk/tt_vocab.h +++ b/engines/titanic/true_talk/tt_vocab.h @@ -53,9 +53,6 @@ private: * Scans the vocab list for an existing word match */ TTword *findWord(const TTstring &str); -public: - TTvocab(int val); - ~TTvocab(); /** * Scans the vocab list for a word with a synonym matching the passed string. @@ -68,12 +65,31 @@ public: TTword *getPrimeWord(TTstring &str, TTword **srcWord = nullptr) const; /** + * Checks the passed word for common pluralization, and if present checks + * for a word match for the base singular word + * @param str Word to check + * @returns New word instance for found match, or nullptr otherwise + */ + TTword *getPluralizedWord(TTstring &str) const; + + /** * Checks the passed word for common prefixes, and checks for a word * match for the word without the given prefix * @param str Word to check * @returns New word instance for found match, or nullptr otherwise */ - TTword *getPrefixedWord(TTstring &str); + TTword *getPrefixedWord(TTstring &str) const; +public: + TTvocab(int val); + ~TTvocab(); + + /** + * Gets a matching word from the vocab list given a passed string + * @param str Word text to scan for + * @param srcWord Optional pointer to store the original word match was found on + * @returns A new word instance if a match if found, or null if not + */ + TTword *getWord(TTstring &str, TTword **srcWord = nullptr) const; }; } // End of namespace Titanic |