QString get_Possessive_form(QString word) { if (word.length()>=2) { int last_index=getLastLetter_index(word); QChar last=getLastLetter(word,last_index); QChar before=getLastLetter(word.left(last_index)); if (last==alef && isConsonant(before)) return removeLastDiacritic(word).append(waw).append(ya2); else if (last==alef && before==waw ) return removeLastDiacritic(removeLastLetter(word)).append(ya2); else if (last==alef && before==ya2 ) return removeLastDiacritic(removeLastLetter(word)).append(shadde); else if (last==ta2_marbouta && isConsonant(before)) return removeLastDiacritic(removeLastLetter(word)).append(ya2); else if (last==ya2) return removeLastDiacritic(word).append(shadde); else if (isConsonant(last) || last==waw) return removeLastDiacritic(word).append(ya2); else { out << "Unknown Rule for Possessive form\n"; return QString::null; } } else return word.append(ya2); }
/* ** Return TRUE if the word ends with three letters which ** are consonant-vowel-consonent and where the final consonant ** is not 'w', 'x', or 'y'. ** ** The word is reversed here. So we are really checking the ** first three letters and the first one cannot be in [wxy]. */ static int star_oh(const char *z){ return z[0]!=0 && isConsonant(z) && z[0]!='w' && z[0]!='x' && z[0]!='y' && z[1]!=0 && isVowel(z+1) && z[2]!=0 && isConsonant(z+2); }
inline void syllabize( std::vector<std::string>& mTarget, const std::string& mWord) { auto itr(std::begin(mWord)); auto itrEnd(std::end(mWord)); auto valid([&itr, &itrEnd]() -> bool { return itr != itrEnd; }); while(valid()) { std::string currentSyllable; // CASE: beginning VC if(valid() && itr == std::begin(mWord) && isVowel(*itr) && isConsonant(*(itr + 1))) { currentSyllable += *itr++; mTarget.emplace_back(currentSyllable); continue; } // CASE: C...V if(valid() && isConsonant(*itr)) { while(valid() && isConsonant(*itr)) { currentSyllable += *itr++; if(valid() && isVowel(*itr)) { currentSyllable += *itr++; if(valid() && isConsonant(*itr)) { char lastConsonant(*itr); if(itr + 1 < itrEnd && *itr == lastConsonant && *(itr + 1) == lastConsonant) { currentSyllable += *itr++; } } break; } } } // CASE: V else if(valid() && isVowel(*itr)) { currentSyllable += *itr++; } mTarget.emplace_back(currentSyllable); } }
/* Like mgt0 above except we are looking for a value of m>1 instead ** or m>0 */ static int m_gt_1(const char *z){ while( isVowel(z) ){ z++; } if( *z==0 ) return 0; while( isConsonant(z) ){ z++; } if( *z==0 ) return 0; while( isVowel(z) ){ z++; } if( *z==0 ) return 0; while( isConsonant(z) ){ z++; } return *z!=0; }
/* Measure the number of consonant sequences between * `k0` and `j`. If C is a consonant sequence and V * a vowel sequence, and <..> indicates arbitrary * presence: * * <C><V> gives 0 * <C>VC<V> gives 1 * <C>VCVC<V> gives 2 * <C>VCVCVC<V> gives 3 * .... */ static int getMeasure() { int position; int index; position = 0; index = k0; while (TRUE) { if (index > j) { return position; } if (!isConsonant(index)) { break; } index++; } index++; while (TRUE) { while (TRUE) { if (index > j) { return position; } if (isConsonant(index)) { break; } index++; } index++; position++; while (TRUE) { if (index > j) { return position; } if (!isConsonant(index)) { break; } index++; } index++; } }
/* `TRUE` when `i - 2, i - 1, i` has the form * `consonant - vowel - consonant` and also if the second * C is not `"w"`, `"x"`, or `"y"`. this is used when * trying to restore an `e` at the end of a short word. * * Such as: * * `cav(e)`, `lov(e)`, `hop(e)`, `crim(e)`, but `snow`, * `box`, `tray`. */ static int cvc(int index) { int character; if (index < k0 + 2 || !isConsonant(index) || isConsonant(index - 1) || !isConsonant(index - 2)) { return FALSE; } character = b[index]; if (character == 'w' || character == 'x' || character == 'y') { return FALSE; } return TRUE; }
/* `TRUE` when `j` and `(j-1)` are the same consonant. */ static int isDoubleConsonant(int index) { if (b[index] != b[index - 1]) { return FALSE; } return isConsonant(index); }
static int isVowel(const char *z){ int j; char x = *z; if( x==0 ) return 0; assert( x>='a' && x<='z' ); j = cType[x-'a']; if( j<2 ) return 1-j; return isConsonant(z + 1); }
/* `TRUE` when `k0, ... j` contains a vowel. */ static int vowelInStem() { int index; index = k0 - 1; while (++index <= j) { if (!isConsonant(index)) { return TRUE; } } return FALSE; }
static int isConsonant(int index) { switch (b[index]) { case 'a': case 'e': case 'i': case 'o': case 'u': return FALSE; case 'y': return (index == k0) ? TRUE : !isConsonant(index - 1); default: return TRUE; } }
bool PhoneticSymbol::isValidSymbol(std::string const& symbol) { bool vowel = isVowel(symbol); bool consonant = isConsonant(symbol); if (vowel || consonant) { return true; } // ブレスの判定 int symbolCharacterCount = symbol.size(); if (symbol.find("br") == 0 && symbolCharacterCount > 2) { // br001とかをfalseにするためのチェック std::string s = symbol.substr(2); try { StringUtil::parseInt<int>(s); return true; } catch (StringUtil::IntegerParseException&) { return false; } } return false; }
QString ReadableGenerator::generate() { QString password; int consonantCounter = 0; int vowelCounter = 0; for (int i = 0; i < length; ++i) { QChar c = this->generateCharacter(); if (isConsonant(c)) { ++consonantCounter; if (consonantCounter > consonantMaximum) { c = this->generateVowel(); consonantCounter = 0; } } else if (isVowel(c)) { ++vowelCounter; if (vowelCounter > vowelMaximum) { c = this->generateVowel(); vowelCounter = 0; } } password.insert(i, c); } return password; }
int TMyFirstClass::countConsonants(std::string &_string) { return std::count_if(_string.begin(), _string.end(), isConsonant()); }
/* ** Return TRUE if the word ends in a double consonant. ** ** The text is reversed here. So we are really looking at ** the first two characters of z[]. */ static int doubleConsonant(const char *z){ return isConsonant(z) && z[0]==z[1] && isConsonant(z+1); }
/* ** Return TRUE if there is a vowel anywhere within z[0..n-1] */ static int hasVowel(const char *z){ while( isConsonant(z) ){ z++; } return *z!=0; }
bool isConsonant (const gchar *ch) { return isConsonant (_(ch)); }
bool isConsonant (string ch) { return isConsonant (_(ch)); }
bool isConsonant (guint ch) { return isConsonant (_(ch)); }