Пример #1
0
Файл: stem.c Проект: DrDub/bow
static int
word_size (const char *word)
{
  register int result;   /* word_size of the word */
  register int state;    /* current state in machine */

  result = 0;
  state = 0;

  /* Run a DFA to compute the word size */
  while (EOS != *word)
    {
      switch (state)
	{
	case 0:
	  state = (is_vowel (*word)) ? 1 : 2;
	  break;
	case 1:
	  state = (is_vowel (*word)) ? 1 : 2;
	  if (2 == state)
	    result++;
	  break;
	case 2:
	  state = (is_vowel (*word) || ('y' == *word)) ? 1 : 2;
	  break;
	}
      word++;
    }
  return (result);
}
Пример #2
0
bool is_stressed_syl(CFSWString syl) {
    bool res = false;
    for (INTPTR i = 0; i < syl.GetLength(); i++) {
        if ((syl.GetAt(i) == colon) || ((is_vowel(syl.GetAt(i))) && (is_vowel(syl.GetAt(i + 1)))))
            res = true;
    }
    return res;
}
Пример #3
0
INTPTR extra_stress(CFSArray<syl_struct> &sv, INTPTR size) {
    if (size == 1) return 0;
    else
        for (INTPTR i = 1; i < size; i++)
            for (INTPTR i1 = 0; i1 < sv[i].syl.GetLength(); i1++) {
                if (sv[i].syl.GetAt(i1) == colon) return i;
                if (i1 > 0)
                    if (is_vowel(sv[i].syl.GetAt(i1)) && is_vowel(sv[i].syl.GetAt(i1 - 1)))
                        return i;
            }
    return 0;
}
Пример #4
0
 string reverseVowels(string s) 
 {
     stack<char> st;
     for (int i=0;i<s.length();++i)
         if (is_vowel(s[i])) st.push(s[i]);
     for (int i=0;i<s.length();++i)
         if (is_vowel(s[i]))
         {
             s[i] = st.top();
             st.pop();
         }
     return s;
 }
Пример #5
0
int main(void){

    char asd[] = "ajeje";
    char foo[] = "FOOBAR";
    
    printf("%d\n", is_vowel('A'));
    printf("%d\n", is_vowel('b'));
    printf("%d\n", char_to_digit('5'));
    printf("%s\n", string_toupper(asd));
    printf("%s\n", string_tolower(foo));
    
    return 0;
}
Пример #6
0
// Adds apostrophes between adjacent vowels.
// Give a character buffer containing the word, and the length of the word (without
// null-terminators).
// Returns a new buffer with the apostrophe-added word.
char* add_apostrophes(const char* word, size_t len)
{
    char* word2 = (char*)malloc(len * 2 + 1);

    int i = 1;
    int j = 1;
    word2[0] = word[0];
    while (i < len) {
        if (is_vowel(word[i-1]) && is_vowel(word[i])) {
            word2[j++] = '\'';
        }
        word2[j++] = word[i++];
    }
    word2[j] = '\0';
    return word2;
}
Пример #7
0
std::string letters_after(long letter, bool vowel_before)
{
// Force lowercase.
  if (letter >= 'A' && letter <= 'Z') {
    letter = letter + 'a' - 'A';
  }

//abcdefghijklmnopqrstuvwxyz
  if (vowel_before) {
    if (is_vowel(letter)) {
      return "bcdfghklmnpqrstvwxyz";
    } else if (letter == 'y') {
      return "abcdefgiklmnoprstuz";
    } else {
      return "abcdefghijklmnopqrstuvwyz";
    }
  } else {
    switch (letter) {
      case 'a': return "bcdefghiklmnpqrstuvwxyz";
      case 'b': return "aeiloruy";
      case 'c': return "aehiloru";
      case 'd': return "aeioruy";
      case 'e': return "abcdefghilmnpqrstuvwyz";
      case 'f': return "aeiloruy";
      case 'g': return "aeiloru";
      case 'h': return "aeiou";
      case 'i': return "abcdefglmnopqrstuvz";
      case 'j': return "aeiou";
    }
  }
  return "a";
}
Пример #8
0
int main() {

    /* I declare it first because I'm lazy enough to change the --std
       in makefile */
    int i,j;

    int consonant_count = 26 - sizeof(vowels);

    /* init the PRNG */
    srand(time(NULL));

    /* create an array of latin letters */
    for (i=0; i<26; i++) letters[i] = i +97;

    /* and now an array of consonants */
    for (i=0,j=0; i<26; i++) {
        if (! is_vowel(letters[i])) consonants[j++] = letters[i];
    }

    printf("%s%c%c%c%c%s\n",
           prefixes[rand() % (sizeof(prefixes) /sizeof(char*))],
           consonants[rand() % consonant_count],
           vowels[rand() % sizeof(vowels)],
           consonants[rand() % consonant_count],
           vowels[rand() % sizeof(vowels)],
           suffixes[rand() % (sizeof(suffixes) /sizeof(char*))]);

    return 0;
}
Пример #9
0
Файл: stem.c Проект: DrDub/bow
static int
contains_vowel (const char *word)
{
  if (EOS == *word)
    return (FALSE);
  else
    return (is_vowel (*word) || (NULL != strpbrk(word+1,"aeiouy")));
}
Пример #10
0
static gboolean
baby_regexp_match (const char *str, const char *regexp)
{
    const char *s;
    const char *ss;
    const char *p;
    

    for (s=str; *s; ++s) {

        gboolean match = TRUE;
        ss = s;
        p = regexp;

        if (*p == '^' && s != str)
            match = FALSE;

        while (match && *ss && *p) {


            if (*p != '.') {

                gboolean flip = FALSE;

                if (*p == '!' && *(p+1) != '\0') {
                    flip = TRUE;
                    ++p;
                }

                if (*p == '+')
                    match = match && is_vowely (*ss);
                else if (*p == '_')
                    match = match && is_vowel (*ss);
                else if (*p == '<')
                    match = match &&  (ss != str && *ss == *(ss-1));
                else if (*p == '@')
                    match = match && (*ss == 'g' || *ss == 'q');
                else if (*p != *ss)
                    match = FALSE;

                if (flip)
                    match = !match;
	
            }

            ++p;
            ++ss;
        }

        if (match && *ss == '\0' && *p != '\0' && *p != '$')
            match = FALSE;

        if (match)
            return TRUE;
    }

    return FALSE;
}
Пример #11
0
static int has_vowel_in_list(const cst_val *v)
{
  const cst_val *t;

  for (t=v; t; t=val_cdr(t))
    if (is_vowel(val_string(val_car(t))))
      return TRUE;
  return FALSE;
}
Пример #12
0
static int has_vowel_in_syl(const cst_item *i)
{
  const cst_item *n;

  for (n=i; n; n=item_prev(n))
    if (is_vowel(item_feat_string(n,"name")))
      return TRUE;
  return FALSE;
}
Пример #13
0
CFSWString DealWithText(CFSWString text) {
    /* Proovin kogu sõnniku minema loopida */
    CFSWString res;
    text.Trim();
    text.Replace(L"\n\n", L"\n", 1);
    text.Replace(L"‘", L"'", 1);
    text.Replace(L"`", L"'", 1);
    text.Replace(L"´", L"'", 1);
    text.Replace(L"’", L"'", 1);

    for (INTPTR i = 0; i < text.GetLength(); i++) {
        CFSWString c = text.GetAt(i);
        CFSWString pc = res.GetAt(res.GetLength() - 1);
        CFSWString nc = text.GetAt(i + 1);
        if (c == L"'") {
            if (is_vowel(pc)) 
                res += L"q";
            else
                res += c;
        }
        else
        if (is_char(c)) res += c;
        else
            if (is_digit(c)) res += c;
        else
            if (is_hyphen(c) && is_char(pc) && is_char(nc)) res += sp;
        else
            if (is_symbol(c)) res += c;
        else
            if (is_colon(c) && !is_colon(pc)) res += c;
        else
            if (is_bbracket(c) && !is_bbracket(pc)) res += c;
        else
            if (is_ebracket(c) && is_ending(nc)) res += L"";
        else
            if (is_ebracket(c) && !is_ebracket(pc)) res += c;
        else
            if (is_comma(c) && !is_comma(pc)) res += c;
        else
            if (is_fchar(c)) res += replace_fchar(c);
        else
            if (is_space(c) && !is_whitespace(pc)) res += c;
        else
            if (is_break(c) && !is_break(pc)) { 
                
                res += c;   
            } //kahtlane
        else
            if (is_tab(c) && !is_whitespace(pc)) res += c;
        else            
            if (is_ending(c) && !is_ending(pc) && !is_whitespace(pc)) res += c;

    }
    res.Trim();        
    return res;

}
Пример #14
0
int main()
{
	//check if it is a vowel
	printf("%d == %d\n", is_vowel('a'), true);
	printf("%d == %d\n", is_vowel('h'), false);

	//check if it is a lettere
	printf("%d == %d\n", is_letter('a'), true);
	printf("%d == %d\n", is_letter('#'), false);

	//checks if it is a consonant
	printf("%d == %d\n", is_consonant('a'), false);
	printf("%d == %d\n", is_consonant('c'), true);
	printf("%d == %d\n", is_consonant('Z'),true);
	printf("%d == %d\n", is_consonant('1'), false);

	return false;
}
/* takes the number of chars in a file,, the file, and a file to read into,
 *  and puts all the non-vowel chars into the second file  */
int copy_non_vowels(int num_chars, char* in_buf, char* out_buf){
	int j = 0;
	for (int i = 0; i < num_chars; ++i){
		if(!is_vowel(in_buf[i])){
			out_buf[j] = in_buf[i];
			++j;
		}
	}
	return j;
}
Пример #16
0
// Extrai apenas as vogais de s
string filter_vowels(const string& s)
{
    string v;

    for (auto c : s)
        if (is_vowel(c))
            v.push_back(c);

    return v;
}
Пример #17
0
int main(int arc, char *argv[]){
  FILE *fp = fopen(argv[1], "r");
  while(true){
    int ch = getc(fp);
    if (ch == EOF) break;
    if ( ! is_vowel(ch))
      printf("%c", (char)ch);
  }
  fclose(fp);
  return 0;
}
Пример #18
0
static int vowel_seg_between(const cst_item *f,const cst_item *l)
{
  const cst_item *s;
  for(s=f;s;s=item_next(s))
    {
      if(is_vowel(item_feat_string(s,"name")))
        return TRUE;
      if(item_equal(s,l))
        break;
    }
  return FALSE;
}
Пример #19
0
int main() {
    bool vowels[26];
    for (int i = 0; i < 26; ++i)
        vowels[i] = is_vowel(i + 'a');

    std::string s;
    std::getline(std::cin, s);

    std::cout << decode(s, vowels) << std::endl;

    return 0;
}
Пример #20
0
int main()
{
	char character;
	printf("Enter a character: ");
	scanf("%c", &character);

	int result = is_vowel(character);
	printf("The result is: %d", result);

	printf("\n\n");

	return 0;
}
Пример #21
0
CFSWString chars_to_phones_part_I(CFSWString &s) {
    CFSWString res;
    for (INTPTR i = 0; i < s.GetLength(); i++) {
        CFSWString c = s.GetAt(i);
        if (c == L']') {
            CFSWString t = CFSWString(s.GetAt(i - 1)).ToUpper();
            res.SetAt(res.GetLength() - 1, t.GetAt(0));
            //vaatab taha; pole kindel, et kas on vajalik
            t = CFSWString(s.GetAt(i - 2)).ToUpper();
            if (can_palat(t)) {
                res.SetAt(res.GetLength() - 2, t.GetAt(0));
                t = CFSWString(s.GetAt(i - 3)).ToUpper();
                if (can_palat(t)) {
                    res.SetAt(res.GetLength() - 2, t.GetAt(0));
                }
            }
            //vaatab ette					
            t = CFSWString(s.GetAt(i + 1)).ToUpper();
            if (can_palat(t)) {
                s.SetAt(i + 1, t.GetAt(0));
                t = CFSWString(s.GetAt(i + 2)).ToUpper();
                if (can_palat(t)) {
                    s.SetAt(i + 2, t.GetAt(0));
                }
            }
        } else
            if (c == L'<') {
            CFSWString t = CFSWString(s.GetAt(i + 1)).ToUpper();
            s.SetAt(i + 1, t.GetAt(0));
        } else
            if (c == L'?') {
        }//Ebanormaalne rõhk. Pärast vaatab, mis teha
        else
            if (c == L'x') res += L"ks";
        else
            if (c == L'y') res += L"i";
        else
            if (c == L'w') res += L"v";
        else
            if (c == L'z') res += L"ts";
        else
            if (c == L'c') {
            res += L"k";
        } else
            if (c == L'ü' && is_vowel(s.GetAt(i + 1)) && s.GetAt(i - 1) == L'ü')
            res += L"i";
        else
            res += c;
    }
    return res;
}
Пример #22
0
int main () {

  freopen( problem ".in", "r", stdin );
  freopen( problem ".out", "w", stdout );

  for ( scanf( "%d", &T ); T; T-- ) {
    scanf( "%s\n", &st );
    if ( is_vowel( st[0] ) )
         printf( "%scow\n", st );
    else printf( "%s%cow\n", st + 1, st[0] );
  }

  return 0;
}
Пример #23
0
Файл: lt.c Проект: kdomen/test
/**
 * @brief  Remove all vowels from a string.
 */
static void remove_vowels(char *string) {
    unsigned int i=0, j=0;
    char buf[sizeof(string)];

    for(i = 0; string[i] != '\0'; i++) {
        if(is_vowel(string[i]) == 0) {
            buf[j] = string[i];
            j++;
        }
    }
    buf[j] = '\0';

    strcpy(string, buf);
}
Пример #24
0
int copy_non_vowels(int num_chars, char* in_buf, char* out_buf) {
  /*Copy all the non-vowels from in_buf to out_buf.  num_chars indicates how many
characters are in in_buf, and this should return the number of non-vowels that were
copied over*/

  int i = 0;
  int non_vowels = 0;
  for (i; i < num_chars; i++) {
    if(!is_vowel(in_buf[i])) {
	out_buf[non_vowels] = in_buf[i];
	non_vowels++;
    }
  }
    return non_vowels;
}
Пример #25
0
static int ru_syl_boundary(const cst_item *i,const cst_val *v)
{
  const char *p;
  const char *n;
  const char *nn;
  if (v == NULL)
    return TRUE;
  n=val_string(val_car(v));
  if (is_silence(n))
    return TRUE;
  if (!has_vowel_in_list(v))
    return FALSE;
  if (!has_vowel_in_syl(i))
    return FALSE;
  if (is_vowel(n))
    return TRUE;
  if (val_cdr(v) == NULL)
    return FALSE;
  p = item_feat_string(i,"name");
  nn = val_string(val_car(val_cdr(v)));
  if(is_vowel(p))
    {
      if(is_vowel(nn))
        return TRUE;
      if(is_sonorant(n)&&!is_sonorant(nn))
        return FALSE;
      if(is_j(n))
        return FALSE;
      return TRUE;
    }
  if(is_sonorant(p))
    return TRUE;
  if(is_j(p))
    return TRUE;
  return FALSE;
}
Пример #26
0
byte makeInt(int scan_code) 
{
	switch(scan_code) 
	{
		case RIGHT_SHIFT_MAKE:
			shiftActivated = 1;
			return 0;
		case LEFT_SHIFT_MAKE:
			shiftActivated = 1;
			return 0;
		case CAPS_LOCK:
			capsLockActivated = !capsLockActivated;
			return 0;
		case ALT_MAKE:
			altActivated = 1;
			return 0;
		case ACCENT_MAKE:
			if (current_keyboard == 1)
			{
				accent = 1;
				return 0;
			}
	}
	if (altActivated && 
		scan_code >= 0x02 && scan_code < 0x02 + MAX_SHELLS)
		changing_shell = 1;  
	if (accent && current_keyboard == 1)
	{
		if (shiftActivated ^ capsLockActivated)
		{
			accent = 0;			
		} else if (is_vowel(scan_code)) {
			accent = 0;
			return accent_vowel(scan_code);
		} else {
			write_buffer(keyboards[current_keyboard][ACCENT_MAKE][0]);
			accent = 0;
		}
	}
	if (is_letter(scan_code))
	{
		return keyboards[current_keyboard]
					[scan_code][shiftActivated ^ capsLockActivated];
	}
	return keyboards[current_keyboard][scan_code][shiftActivated];
}
void disemvowel(FILE* inputFile, FILE* outputFile) {


    int currentChar;
    while((currentChar = fgetc(inputFile)) != EOF) {
      if(!is_vowel(currentChar)){
	fprintf(outputFile, "%c", currentChar);
      }
    }

    // putchar()
  /* 
   * Copy all the non-vowels from inputFile to outputFile.
   * Create input and output buffers, and use fread() to repeatedly read
   * in a buffer of data, copy the non-vowels to the output buffer, and
   * use fwrite to write that out.
   */
}
Пример #28
0
void solve()
{
    for (char *p = line; *p;) {
        while (*p && ! isalpha(*p)) putchar(*p++);

        if (! *p) continue;

        char first = 0;
        if (! is_vowel(*p)) first = *p++;

        while (*p && isalpha(*p))
            putchar(*p++);
        if (first != 0) putchar(first);

        printf("ay");
    }
    putchar('\n');
}
Пример #29
0
CFSWString shift_pattern(CFSWString s) {
    if (s == L'j') return L'j';
    else
        if (s == L'h') return L'h';
    else
        if (s == L'v') return L'v';
    else
        if (s.FindOneOf(L"sS") > -1) return L's';
    else
        if (s.FindOneOf(L"lmnrLN") > -1) return L'L';
    else
        if (s.FindOneOf(L"kptfšT") > -1) return L'Q';
    else
        if (is_vowel(s)) return L'V';
    else
        if (is_consonant(s)) return L'C';
    return s;
}
Пример #30
0
/**
 * check if text has the required number of vowels
 * @param  text         text to be tested for vowels
 * @param  no_of_vowels no of vowels that should be in text
 * @return  bool true if there are required no of vowels, false otherwise
 */
bool has_required_vowels(char* text, int no_of_vowels)
{
    int i = 0;
    int vowels = 0;

    // Check every character, and if it is a vowel, increment the count.
    // Check if count is equal to the required no of vowels,
    // if they're equal return true, otherwise return false at the end.
    for(; i<strlen(text); i++) {
        if (is_vowel(text[i])) {
            vowels += 1;
            if (vowels == no_of_vowels) {
                return true;
            }
        }
    }

    return false;
}