Beispiel #1
0
spellresult VfstSpeller::spell(const wchar_t * word, size_t wlen) {
	spellresult result = doSpell(word, wlen);
	if (result == SPELL_FAILED && SimpleChar::isLower(word[0])) {
		// XXX: This slightly inefficient hack allows us to support SPELL_CAP_FIRST
		wchar_t * modifiedWord = StringUtils::copy(word);
		modifiedWord[0] = SimpleChar::upper(word[0]);
		result = doSpell(modifiedWord, wlen);
		if (result == SPELL_OK) {
			result = SPELL_CAP_FIRST;
		}
		delete[] modifiedWord;
	}
	return result;
}
Beispiel #2
0
spellresult HfstSpeller::spell(const wchar_t * word, size_t wlen) {
	spellresult result = doSpell(word, wlen);
	if (result == SPELL_FAILED && SimpleChar::isLower(word[0])) {
		// XXX: This slightly inefficient hack allows us to support SPELL_CAP_FIRST
		wchar_t * modifiedWord = StringUtils::copy(word);
		modifiedWord[0] = SimpleChar::upper(word[0]);
		result = doSpell(modifiedWord, wlen);
		if (result == SPELL_OK) {
			result = SPELL_CAP_FIRST;
		}
		// This is needed to support VOIKKO_OPT_ACCEPT_ALL_UPPERCASE option
		else if (voikkoOptions->accept_all_uppercase && voikko_casetype(modifiedWord, wlen) == CT_FIRST_UPPER) {
			for (size_t i = 1; i < wlen; i++) {
				modifiedWord[i] = SimpleChar::upper(modifiedWord[i]);
			}
			result = doSpell(modifiedWord, wlen);
			if (result == SPELL_OK) {
				result = SPELL_CAP_ERROR;
			}
		}
		delete[] modifiedWord;
	}
	return result;
}