Script PHP pour déterminer si la lettre Y est une consonne ou une voyelle

  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 21st, 2012, 8:20 pm

Si je change la boucle de voyelle à
PHP Code: [ Select ]
// Loop Vowels found
         for($j=0; $j<count($vowels_check['vowels']); $j++) {
           
            // Check for Y
            if(strpos($word_array[$i], 'y') !== false) {
 
               // Check position of vowel
               if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
               echo $word_array[$i] . ' in If';
                  // Y is after vowel so it is a constant
                  $return_array[$word][$i] = 'consonant<br>';
                 
               } /*else if(strpos($word_array[$i], 'y') + 1 == $vowels_check['vowels'][$j]['pos']) {
                  echo $word_array[$i] . ' in else If<br>';
                  // Y is before vowel so it is a Vowel
                  $return_array[$word][$i] = 'vowel';
                 
               }*/ else {
                  echo $word_array[$i] . ' in else<br><br>';
                  // Y is before vowel so it is a Vowel
                  $return_array[$word][$i] = 'vowel';
                 
               }
           
            }
           
         }
 
  1. // Loop Vowels found
  2.          for($j=0; $j<count($vowels_check['vowels']); $j++) {
  3.            
  4.             // Check for Y
  5.             if(strpos($word_array[$i], 'y') !== false) {
  6.  
  7.                // Check position of vowel
  8.                if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
  9.                echo $word_array[$i] . ' in If';
  10.                   // Y is after vowel so it is a constant
  11.                   $return_array[$word][$i] = 'consonant<br>';
  12.                  
  13.                } /*else if(strpos($word_array[$i], 'y') + 1 == $vowels_check['vowels'][$j]['pos']) {
  14.                   echo $word_array[$i] . ' in else If<br>';
  15.                   // Y is before vowel so it is a Vowel
  16.                   $return_array[$word][$i] = 'vowel';
  17.                  
  18.                }*/ else {
  19.                   echo $word_array[$i] . ' in else<br><br>';
  20.                   // Y is before vowel so it is a Vowel
  21.                   $return_array[$word][$i] = 'vowel';
  22.                  
  23.                }
  24.            
  25.             }
  26.            
  27.          }
  28.  


Presque tous les cas travaillent sauf Yvonne obtient encore foirée
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Décembre 21st, 2012, 8:20 pm

  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 21st, 2012, 8:30 pm

Ce problème pourrait être dû par la classe de syllabe ne pas scinder Yvonne
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 21st, 2012, 8:32 pm

Fonction y cocher mise à jour
PHP Code: [ Select ]
function check_y($word) {
   
   // Start the class
   $syllable = new Syllable('en-us');
   
   // Make th word lower case
   $word = strtolower($word);
 
   // Check for Y
   if(strpos($word, 'y') === false) {
     
      // No Y found
      return 'No Y Found';
   
   }
   
   // Make an array to return info
   $return_array = array();
   
   // Breakword into syllables
   $syllable->setTreshold(Syllable::TRESHOLD_MOST);
   $word_array = explode('&shy;', utf8_encode($syllable->hyphenateText($word)));
   
   // Loop the word array
   for($i=0; $i<count($word_array); $i++) {
     
      // Check for vowels
      $vowels_check = vowel_check($word_array[$i]);
   
      // Check for no vowels
      if(!$vowels_check['found']) {
         // Check for Y
         if(strpos($word_array[$i], 'y') !== false) {
           
            // No Vowels found so Y is a vowel
            $return_array[$word][$i] = 'vowel';
         
         }
         
      } else {
 
         //echo $word_array[$i] . ' ';
         // Loop Vowels found
         for($j=0; $j<count($vowels_check['vowels']); $j++) {
           
            // Check for Y
            if(strpos($word_array[$i], 'y') !== false) {
 
               // Check position of vowel
               if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
               
                  // Y is after vowel so it is a constant
                  $return_array[$word][$i] = 'consonant<br>';
                 
               } else {
                 
                  // Y is before vowel so it is a Vowel
                  $return_array[$word][$i] = 'vowel';
                 
               }
           
            }
           
         }
         
      }
     
   }
     
   // Return the return array
   return $return_array;
   
}
  1. function check_y($word) {
  2.    
  3.    // Start the class
  4.    $syllable = new Syllable('en-us');
  5.    
  6.    // Make th word lower case
  7.    $word = strtolower($word);
  8.  
  9.    // Check for Y
  10.    if(strpos($word, 'y') === false) {
  11.      
  12.       // No Y found
  13.       return 'No Y Found';
  14.    
  15.    }
  16.    
  17.    // Make an array to return info
  18.    $return_array = array();
  19.    
  20.    // Breakword into syllables
  21.    $syllable->setTreshold(Syllable::TRESHOLD_MOST);
  22.    $word_array = explode('&shy;', utf8_encode($syllable->hyphenateText($word)));
  23.    
  24.    // Loop the word array
  25.    for($i=0; $i<count($word_array); $i++) {
  26.      
  27.       // Check for vowels
  28.       $vowels_check = vowel_check($word_array[$i]);
  29.    
  30.       // Check for no vowels
  31.       if(!$vowels_check['found']) {
  32.          // Check for Y
  33.          if(strpos($word_array[$i], 'y') !== false) {
  34.            
  35.             // No Vowels found so Y is a vowel
  36.             $return_array[$word][$i] = 'vowel';
  37.          
  38.          }
  39.          
  40.       } else {
  41.  
  42.          //echo $word_array[$i] . ' ';
  43.          // Loop Vowels found
  44.          for($j=0; $j<count($vowels_check['vowels']); $j++) {
  45.            
  46.             // Check for Y
  47.             if(strpos($word_array[$i], 'y') !== false) {
  48.  
  49.                // Check position of vowel
  50.                if($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') || strpos($word_array[$i], 'y') == 0) {
  51.                
  52.                   // Y is after vowel so it is a constant
  53.                   $return_array[$word][$i] = 'consonant<br>';
  54.                  
  55.                } else {
  56.                  
  57.                   // Y is before vowel so it is a Vowel
  58.                   $return_array[$word][$i] = 'vowel';
  59.                  
  60.                }
  61.            
  62.             }
  63.            
  64.          }
  65.          
  66.       }
  67.      
  68.    }
  69.      
  70.    // Return the return array
  71.    return $return_array;
  72.    
  73. }
  • wpas
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Juil 12, 2010
  • Messages: 214
  • Loc: Canada
  • Status: Offline

Message Décembre 21st, 2012, 11:12 pm

Plus je creuse dans tout cela, obtenir des opinions les plus divergentes, même pourquoi j'ai contacté quelques anglais enseigne.

Pour essayer un étroit de ce fait, je suis venu avec deux choses que j'ai été compte tenu du fait que je vais utiliser comme une base pour le test.

Règle 1
Si vous remplacez la lettre y le /j/ sonore et le mot sonne presque la même chose alors c'est une consonne, même si vous semblerait avoir un accent.
par exemple, yell serait presque le même son avec /j/ y est conforme
jour sonnerait pas la même chose avec/j /, donc y est une voyelle.

Règle 2
Y est une consonne, lorsqu'il apparaît au début d'une syllabe où il y a une autre voyelle (igname, encore).

Règle 3
S'il n'y a pas de voyelles dans le mot y est une voyelle tels que salle de sport.
Si elle prend la place de la voyelle, y est une voyelle comme système.

Je ne sais pas comment corriger je suis, mais c'est où je voudrais commencer.

Basé sur ce qui précède, j'ai créé ce qui suit pour le test :

Pour les voyelles :

check_test (tout le monde de bébé betty garçon bryan de cyclotourisme candy cri cycle jour sec dynamique elly mouche volant au revoir gym heureux poilue hymne joy lynn Marie beaucoup mon mythe mystère jouer psycho pry poney rapidement rythme rime de seigle dire timide ciel spy sly soja symbole seringue petit try trendy très vinyle pourquoi wyatt yvonne)

Pour les consonnes :

check_test (hey touche kyle yahoo d'yacht lloyd oyster joueur yale yam fil rendement yell jaune Eltsine Oui hier encore yoda yogourt yoke yolanda young vous votre yvette royce)

Dans les deux cas :

check_test("Sydney")

Si quelqu'un a des suggestions supplémentaires, je serais très heureux de vous entendre.
http://www.schembrionics.com
The Ultimate Solutions Center
  • wpas
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Juil 12, 2010
  • Messages: 214
  • Loc: Canada
  • Status: Offline

Message Décembre 22nd, 2012, 12:33 am

Hey scottG

Dans ma hâte d'établir certaines règles, je peux mélangé un peu les choses.

Lorsque vous avez un script de travail, s'il vous plaît conseiller et puis je vais tester avec soin ce que vous avez.

Merci
http://www.schembrionics.com
The Ultimate Solutions Center
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 22nd, 2012, 7:50 am

La règle 1 est la règle qui va être le plus difficile à obtenir correcte.

y a-t-il une corrélation avec la voyelle à l'o qui serait constamment les mêmes

Exemple
Oy ay et uy en voyelles...garçon jour acheter
et ey en consonnes...hey

Si c'est le cas cela devrait rendre les choses un peu plus facile
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 22nd, 2012, 8:04 am

aussi faut-il pas yvette considérer une voyelle puisque y fait un e ?
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 22nd, 2012, 8:32 am

Aussi ces paroles

Ceux-ci ont l'oy qui, dans votre « soy » d'exemple était une voyelle
Royce
Lloyd
Oyster

Et le joueur a un ressembler à un jour
joueur

Si tous mes post sont corrects, je pense que je peux avoir un script modifié qui répond à toutes les règles qui peuvent être mis à l'essai
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 22nd, 2012, 12:44 pm

Ici est mis à jour le code pour tester avec

PHP Code: [ Select ]
<?php
 
// Include the class
require_once(dirname(__FILE__) . '/Syllable.php');
 
function vowel_check($word) {
   
   // Setup an array of vowels
   $vowels = array('a', 'e', 'i', 'o', 'u');
   
   // Make an return array
   $return_array = array("found" => false);
   
   // Make a counter
   $ii = 0;
   
   // Loop the letters
   for($i=0; $i<strlen($word); $i++) {
     
      // Check for vowels
      if(in_array($word[$i], $vowels)) {
         
         // Set found to true
         $return_array['found'] = true;
         
         // Build the info
         $return_array['vowels'][$ii]['letter'] = $word[$i];
         $return_array['vowels'][$ii]['pos'] = strpos($word, $word[$i]);
         
         // Add to counter
         $ii++;
      }
     
   }
   
   // Return $return_array
   return $return_array;
     
}
 
 
function check_y($word) {
   
   // Start the class
   $syllable = new Syllable('en-us');
   
   // Make th word lower case
   $word = strtolower($word);
 
   // Check for Y
   if(strpos($word, 'y') === false) {
     
      // No Y found
      return 'No Y Found';
   
   }
   
   // Make an array to return info
   $return_array = array();
   
   // Breakword into syllables
   $syllable->setTreshold(Syllable::TRESHOLD_MOST);
   $word_array = explode('&shy;', utf8_encode($syllable->hyphenateText($word)));
   
   // Loop the word array
   for($i=0; $i<count($word_array); $i++) {
     
      // Check for vowels
      $vowels_check = vowel_check($word_array[$i]);
   
      // Check for no vowels
      if(!$vowels_check['found']) {
         // Check for Y
         if(strpos($word_array[$i], 'y') !== false) {
           
            if(strpos($word_array[$i], 'y') == 0) {
           
               // No Vowels and y is the first letter of the word
               $return_array[$word][$i] = 'consonant';
           
            } else {
           
               // No Vowels found so Y is a vowel
               $return_array[$word][$i] = 'vowel';
           
            }
         
         }
         
      } else {
 
         
         // Loop Vowels found
         for($j=0; $j<count($vowels_check['vowels']); $j++) {
           
            // Check for Y
            if(strpos($word_array[$i], 'y') !== false) {
               
               // Check position of vowel
               switch(true) {
                 
                  // Vowel before and vowel being o a or u
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
                     
                     // Y is s vowel
                     $return_array[$word][$i] = 'vowel';
                 
                     // Kickout
                     break;
                     
                  // Vowel before and vowel being e or i
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
                     
                     // Y is s consonant
                     $return_array[$word][$i] = 'consonant';
                 
                     // Kickout
                     break;
                 
                  // YV fix the syllable class does not break the yv apart into the correct syllable grouping so this is a fix to
                  // counter act this issue
                  case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
                     
                     // Y is s vowel
                     $return_array[$word][$i] = 'vowel';
                 
                     // Kickout
                     break;
                     
                  // Y is first letter
                  case (strpos($word_array[$i], 'y') == 0):
                     
                     // Y is s consonant
                     $return_array[$word][$i] = 'consonant';
                 
                     // Kickout
                     break;
                 
               }
           
            }
           
         }
         
      }
     
   }
     
   // Return the return array
   return $return_array;
   
}
 
echo '<pre>';
var_dump(check_text('boy Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
 
//var_dump(check_text('anyone baby betty boy bryan by bycycle candy cry cycle day dry dynamic elly fly flying goodbye gym happy hairy hymn joy lynn many mary my mystery myth play pony pry psycho quickly rye rhyme rhythm say shy sky sly spy soy symbol syringe tiny trendy try very vinyl why wyatt yvonne yvette'));
 
//var_dump(check_text('hey key kyle lloyd oyster player yacht yahoo yale yam yarn yield yell yellow yeltsin yes yesterday yet yoda yogurt yoke yolanda you young your royce'));
 
//check_text('Sylvia');
echo '</pre>';
 
function check_text($text) {
   
   // Make sure we have text
   if(empty($text)) {
     
      // Kick back
      return false;
     
   }
   
   // Break text into words
   $text_array = explode(' ', $text);
   
   // Make an array to return info
   $return_array = array();
   
   // Loop Text
   for($i=0; $i<count($text_array); $i++) {
     
      // Check the word
      $temp_array = check_y($text_array[$i]);
     
      if(!empty($temp_array)) {
         
         // Add to the return array
         $return_array[] = $temp_array;
         
      }
     
   }
   
   // Return the array
   return $return_array;
   
}
 
?>
 
  1. <?php
  2.  
  3. // Include the class
  4. require_once(dirname(__FILE__) . '/Syllable.php');
  5.  
  6. function vowel_check($word) {
  7.    
  8.    // Setup an array of vowels
  9.    $vowels = array('a', 'e', 'i', 'o', 'u');
  10.    
  11.    // Make an return array
  12.    $return_array = array("found" => false);
  13.    
  14.    // Make a counter
  15.    $ii = 0;
  16.    
  17.    // Loop the letters
  18.    for($i=0; $i<strlen($word); $i++) {
  19.      
  20.       // Check for vowels
  21.       if(in_array($word[$i], $vowels)) {
  22.          
  23.          // Set found to true
  24.          $return_array['found'] = true;
  25.          
  26.          // Build the info
  27.          $return_array['vowels'][$ii]['letter'] = $word[$i];
  28.          $return_array['vowels'][$ii]['pos'] = strpos($word, $word[$i]);
  29.          
  30.          // Add to counter
  31.          $ii++;
  32.       }
  33.      
  34.    }
  35.    
  36.    // Return $return_array
  37.    return $return_array;
  38.      
  39. }
  40.  
  41.  
  42. function check_y($word) {
  43.    
  44.    // Start the class
  45.    $syllable = new Syllable('en-us');
  46.    
  47.    // Make th word lower case
  48.    $word = strtolower($word);
  49.  
  50.    // Check for Y
  51.    if(strpos($word, 'y') === false) {
  52.      
  53.       // No Y found
  54.       return 'No Y Found';
  55.    
  56.    }
  57.    
  58.    // Make an array to return info
  59.    $return_array = array();
  60.    
  61.    // Breakword into syllables
  62.    $syllable->setTreshold(Syllable::TRESHOLD_MOST);
  63.    $word_array = explode('&shy;', utf8_encode($syllable->hyphenateText($word)));
  64.    
  65.    // Loop the word array
  66.    for($i=0; $i<count($word_array); $i++) {
  67.      
  68.       // Check for vowels
  69.       $vowels_check = vowel_check($word_array[$i]);
  70.    
  71.       // Check for no vowels
  72.       if(!$vowels_check['found']) {
  73.          // Check for Y
  74.          if(strpos($word_array[$i], 'y') !== false) {
  75.            
  76.             if(strpos($word_array[$i], 'y') == 0) {
  77.            
  78.                // No Vowels and y is the first letter of the word
  79.                $return_array[$word][$i] = 'consonant';
  80.            
  81.             } else {
  82.            
  83.                // No Vowels found so Y is a vowel
  84.                $return_array[$word][$i] = 'vowel';
  85.            
  86.             }
  87.          
  88.          }
  89.          
  90.       } else {
  91.  
  92.          
  93.          // Loop Vowels found
  94.          for($j=0; $j<count($vowels_check['vowels']); $j++) {
  95.            
  96.             // Check for Y
  97.             if(strpos($word_array[$i], 'y') !== false) {
  98.                
  99.                // Check position of vowel
  100.                switch(true) {
  101.                  
  102.                   // Vowel before and vowel being o a or u
  103.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
  104.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
  105.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
  106.                      
  107.                      // Y is s vowel
  108.                      $return_array[$word][$i] = 'vowel';
  109.                  
  110.                      // Kickout
  111.                      break;
  112.                      
  113.                   // Vowel before and vowel being e or i
  114.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
  115.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
  116.                      
  117.                      // Y is s consonant
  118.                      $return_array[$word][$i] = 'consonant';
  119.                  
  120.                      // Kickout
  121.                      break;
  122.                  
  123.                   // YV fix the syllable class does not break the yv apart into the correct syllable grouping so this is a fix to
  124.                   // counter act this issue
  125.                   case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
  126.                      
  127.                      // Y is s vowel
  128.                      $return_array[$word][$i] = 'vowel';
  129.                  
  130.                      // Kickout
  131.                      break;
  132.                      
  133.                   // Y is first letter
  134.                   case (strpos($word_array[$i], 'y') == 0):
  135.                      
  136.                      // Y is s consonant
  137.                      $return_array[$word][$i] = 'consonant';
  138.                  
  139.                      // Kickout
  140.                      break;
  141.                  
  142.                }
  143.            
  144.             }
  145.            
  146.          }
  147.          
  148.       }
  149.      
  150.    }
  151.      
  152.    // Return the return array
  153.    return $return_array;
  154.    
  155. }
  156.  
  157. echo '<pre>';
  158. var_dump(check_text('boy Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
  159.  
  160. //var_dump(check_text('anyone baby betty boy bryan by bycycle candy cry cycle day dry dynamic elly fly flying goodbye gym happy hairy hymn joy lynn many mary my mystery myth play pony pry psycho quickly rye rhyme rhythm say shy sky sly spy soy symbol syringe tiny trendy try very vinyl why wyatt yvonne yvette'));
  161.  
  162. //var_dump(check_text('hey key kyle lloyd oyster player yacht yahoo yale yam yarn yield yell yellow yeltsin yes yesterday yet yoda yogurt yoke yolanda you young your royce'));
  163.  
  164. //check_text('Sylvia');
  165. echo '</pre>';
  166.  
  167. function check_text($text) {
  168.    
  169.    // Make sure we have text
  170.    if(empty($text)) {
  171.      
  172.       // Kick back
  173.       return false;
  174.      
  175.    }
  176.    
  177.    // Break text into words
  178.    $text_array = explode(' ', $text);
  179.    
  180.    // Make an array to return info
  181.    $return_array = array();
  182.    
  183.    // Loop Text
  184.    for($i=0; $i<count($text_array); $i++) {
  185.      
  186.       // Check the word
  187.       $temp_array = check_y($text_array[$i]);
  188.      
  189.       if(!empty($temp_array)) {
  190.          
  191.          // Add to the return array
  192.          $return_array[] = $temp_array;
  193.          
  194.       }
  195.      
  196.    }
  197.    
  198.    // Return the array
  199.    return $return_array;
  200.    
  201. }
  202.  
  203. ?>
  204.  
  • wpas
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Juil 12, 2010
  • Messages: 214
  • Loc: Canada
  • Status: Offline

Message Décembre 22nd, 2012, 2:34 pm

Hey ScottG

Après avoir soigneusement au-dessus de tout, j'avais été mauvais dans certains domaines. Après les heures d'étude, je crois que ce qui suit est probablement le plus juste pour la lettre y.

1. les mots avec « oy » la lettre y est une voyelle
par exemple, boy, joie, jouet, roy

2. les mots avec ay, ey et uy la lettre y est une consonne
par exemple, payer, disons, jour, clé, acheter, maire, murray, maloney

3. Y est une consonne, lorsqu'il apparaît au début d'une syllabe où il y a une autre voyelle (igname, pourtant, yolanda, yoda), créant la « yuh » sonore. Dans le lecteur de mot, le « yuh » retentisse, donc y est une consonne.

4. S'il n'y a pas de voyelles dans le mot y est une voyelle tels que gym, Lynn, Yvonne, Yvette, Marie, Betty, Elly et Bryan.
Si elle prend la place de la voyelle, y est une voyelle comme système, Bryan et Wyatt.

5. Autres exemples

-Billy, Sylvia, Missy, Kyle, Blythe, Sylvester et Katy, l'Y est une voyelle
-Dans la salle de gym, ma, cycle, ciel poilu, bébé, le y est une voyelle

-Kay, Eltsine, mai et Kuykendahl, l'Y est une consonne.
-À Sydney, le premier Y est une voyelle, la seconde Y est une consonne.
-In Oui, yam, yell, jaune, yogourt, yale l'y est une consonne.
http://www.schembrionics.com
The Ultimate Solutions Center
  • wpas
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Juil 12, 2010
  • Messages: 214
  • Loc: Canada
  • Status: Offline

Message Décembre 22nd, 2012, 2:44 pm

J'ai couru votre nouveau script et basée sur de nouvelles règles dans mon post précédent suivants besoins changeant :

Kay: y a déclaré que la voyelle, mais doit être conforme
mai: y a déclaré que la voyelle, mais doit être conforme
kuykendahl: y a déclaré que la voyelle, mais doit être conforme
Murray: y a déclaré que la voyelle, mais doit être conforme

J'ai étudié ces mots plus loin et ils n'ont en effet tous spécifié comme y étant une consonne.
http://www.schembrionics.com
The Ultimate Solutions Center
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 22nd, 2012, 3:08 pm

OK alors voici la fonction de y cocher modifiée basée sur le nouvel ensemble de règles

Passé tous les exemples que vous avez fournies
PHP Code: [ Select ]
function check_y($word) {
   
   // Start the class
   $syllable = new Syllable('en-us');
   
   // Make th word lower case
   $word = strtolower($word);
 
   // Check for Y
   if(strpos($word, 'y') === false) {
     
      // No Y found
      return 'No Y Found';
   
   }
   
   // Make an array to return info
   $return_array = array();
   
   // Breakword into syllables
   $syllable->setTreshold(Syllable::TRESHOLD_MOST);
   $word_array = explode('&shy;', utf8_encode($syllable->hyphenateText($word)));
   
   // Loop the word array
   for($i=0; $i<count($word_array); $i++) {
     
      // Check for vowels
      $vowels_check = vowel_check($word_array[$i]);
   
      // Check for no vowels
      if(!$vowels_check['found']) {
         // Check for Y
         if(strpos($word_array[$i], 'y') !== false) {
           
            if(strpos($word_array[$i], 'y') == 0) {
           
               // No Vowels and y is the first letter of the word
               $return_array[$word][$i] = 'consonant';
           
            } else {
           
               // No Vowels found so Y is a vowel
               $return_array[$word][$i] = 'vowel';
           
            }
         
         }
         
      } else {
 
         // Loop Vowels found
         for($j=0; $j<count($vowels_check['vowels']); $j++) {
           
            // Check for Y
            if(strpos($word_array[$i], 'y') !== false) {
               
               // Check position of vowel
               switch(true) {
                 
                  // Vowel before and vowel being o
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
                     
                     // Y is s vowel
                     $return_array[$word][$i] = 'vowel';
                 
                     // Kickout
                     break;
                     
                  // Vowel before and vowel being a, e, i or u
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
                  case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
                     
                     // Y is s consonant
                     $return_array[$word][$i] = 'consonant';
                 
                     // Kickout
                     break;
                 
                  // YV fix the sylible class does not break the yv apart into the correct sylible grouping so this is a fix to
                  // counter act this issue
                  case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
                     
                     // Y is s vowel
                     $return_array[$word][$i] = 'vowel';
                 
                     // Kickout
                     break;
                     
                  // Y is first letter
                  case (strpos($word_array[$i], 'y') == 0):
                     
                     // Y is s consonant
                     $return_array[$word][$i] = 'consonant';
                 
                     // Kickout
                     break;
                 
                  // Y not next two vowels
                  default:
                     
                     // Y is s vowel
                     $return_array[$word][$i] = 'vowel';
                 
                     // Kickout
                     break;
                 
               }
           
            }
           
         }
         
      }
     
   }
     
   // Return the return array
   return $return_array;
   
}
 
  1. function check_y($word) {
  2.    
  3.    // Start the class
  4.    $syllable = new Syllable('en-us');
  5.    
  6.    // Make th word lower case
  7.    $word = strtolower($word);
  8.  
  9.    // Check for Y
  10.    if(strpos($word, 'y') === false) {
  11.      
  12.       // No Y found
  13.       return 'No Y Found';
  14.    
  15.    }
  16.    
  17.    // Make an array to return info
  18.    $return_array = array();
  19.    
  20.    // Breakword into syllables
  21.    $syllable->setTreshold(Syllable::TRESHOLD_MOST);
  22.    $word_array = explode('&shy;', utf8_encode($syllable->hyphenateText($word)));
  23.    
  24.    // Loop the word array
  25.    for($i=0; $i<count($word_array); $i++) {
  26.      
  27.       // Check for vowels
  28.       $vowels_check = vowel_check($word_array[$i]);
  29.    
  30.       // Check for no vowels
  31.       if(!$vowels_check['found']) {
  32.          // Check for Y
  33.          if(strpos($word_array[$i], 'y') !== false) {
  34.            
  35.             if(strpos($word_array[$i], 'y') == 0) {
  36.            
  37.                // No Vowels and y is the first letter of the word
  38.                $return_array[$word][$i] = 'consonant';
  39.            
  40.             } else {
  41.            
  42.                // No Vowels found so Y is a vowel
  43.                $return_array[$word][$i] = 'vowel';
  44.            
  45.             }
  46.          
  47.          }
  48.          
  49.       } else {
  50.  
  51.          // Loop Vowels found
  52.          for($j=0; $j<count($vowels_check['vowels']); $j++) {
  53.            
  54.             // Check for Y
  55.             if(strpos($word_array[$i], 'y') !== false) {
  56.                
  57.                // Check position of vowel
  58.                switch(true) {
  59.                  
  60.                   // Vowel before and vowel being o
  61.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'o'):
  62.                      
  63.                      // Y is s vowel
  64.                      $return_array[$word][$i] = 'vowel';
  65.                  
  66.                      // Kickout
  67.                      break;
  68.                      
  69.                   // Vowel before and vowel being a, e, i or u
  70.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'a'):
  71.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'e'):
  72.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'i'):
  73.                   case ($vowels_check['vowels'][$j]['pos'] + 1 == strpos($word_array[$i], 'y') && $vowels_check['vowels'][$j]['letter'] == 'u'):
  74.                      
  75.                      // Y is s consonant
  76.                      $return_array[$word][$i] = 'consonant';
  77.                  
  78.                      // Kickout
  79.                      break;
  80.                  
  81.                   // YV fix the sylible class does not break the yv apart into the correct sylible grouping so this is a fix to
  82.                   // counter act this issue
  83.                   case (strtolower($word_array[$i][strpos($word_array[$i], 'y')+1]) == 'v'):
  84.                      
  85.                      // Y is s vowel
  86.                      $return_array[$word][$i] = 'vowel';
  87.                  
  88.                      // Kickout
  89.                      break;
  90.                      
  91.                   // Y is first letter
  92.                   case (strpos($word_array[$i], 'y') == 0):
  93.                      
  94.                      // Y is s consonant
  95.                      $return_array[$word][$i] = 'consonant';
  96.                  
  97.                      // Kickout
  98.                      break;
  99.                  
  100.                   // Y not next two vowels
  101.                   default:
  102.                      
  103.                      // Y is s vowel
  104.                      $return_array[$word][$i] = 'vowel';
  105.                  
  106.                      // Kickout
  107.                      break;
  108.                  
  109.                }
  110.            
  111.             }
  112.            
  113.          }
  114.          
  115.       }
  116.      
  117.    }
  118.      
  119.    // Return the return array
  120.    return $return_array;
  121.    
  122. }
  123.  
  • wpas
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Juil 12, 2010
  • Messages: 214
  • Loc: Canada
  • Status: Offline

Message Décembre 22nd, 2012, 10:21 pm

J'ai pensé que si j'ai creusé assez, je trouverais finalement un consensus général sur la façon de déterminer quand la lettre Y est une voyelle ou une consonne. Heureusement pour moi, elle a approuvé les règles, que j'ai l'intention d'utiliser.

Voici ce que j'ai trouvé :

Si une syllabe commence par Y, et la prochaine lettre représente une voyelle, Y représente certainement une consonne. Dans « yo » par exemple, Y représente une consonne.

Si une syllabe commence par Y et la prochaine lettre représente une consonne, le Y représente une voyelle, comme Yvonne, Yvette, Yves, l'yttrium.

Dans des mots comme "rythme", Y représente une voyelle, spécifiquement court et j'ai l'air. Toutefois, en un mot tel que le nom "Reynold", il ne fait pas sens de dire que Y représente une voyelle. C'est la combinaison de deux lettres E-Y qui représente une voyelle y ici est une consonne.

Dans une syllabe mots tels que « par » et "fly", Y représente la voyelle communément appelé depuis longtemps j'ai.
Dans les mots plus longs tels que "Désolé" et "amical", il représente la voyelle longue e (ou peut-être je court à nouveau — haut-parleurs varient).

Dans des mots comme "hey" ou "jour, les combinaisons de lettres de E-Y et A Y représentent ensemble le long A sound dans ces mots ici y est une consonne.

Pour les Y à la fin d'un mot comme « boy », « oy » est une diphtongue, consistant en une voyelle O ressemblant suivie E long ou court j'ai.
Il y a débat entre phonéticiens sur météo y est une voyelle ou consonne. Ils ne pas tous d'accord là-dessus.
Dans mon cas, j'ai choisi de rendre une voyelle.

Alors, Y obtient représenter une voyelle dans de nombreux mots. Il représente court je dans des termes tels "gym" et soit brève I ou E long dans des termes tels « heureux ». Il s'agit d'une diphtongue dans des termes tels « par ».
http://www.schembrionics.com
The Ultimate Solutions Center
  • alemao_brazil
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Fév 20, 2012
  • Messages: 8
  • Status: Offline

Message Décembre 25th, 2012, 1:20 pm

Est-ce quelqu'un a pris un coup de œil sur mes suggestions (preg_match?)
Il semble que j'ai posté en vain, je n'ai vu aucune réponse ou commentaire...
  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Inscription: Juil 06, 2010
  • Messages: 266
  • Status: Offline

Message Décembre 25th, 2012, 2:25 pm

J'ai fait un test avec votre suggestion sur l'utilisation de preg_match et utilisé des mots comme Sydney où y est une voyelle et une consonne il ne retourne rien. Désolé je n'a pas répondu à votre message plus tôt Ive été un peu occupé à construire un arbre de Noël et avant d'aller au lit ou lorsque je me suis réveillé vers le haut et ne pouvait pas dormir, je travaillais sur ma solution. Il peut avoir travaillé si tordu un peu que j'ai jamais vraiment eu le temps de peaufiner ce bien. Voici le code que j'ai utilisé pour tester votre suggestion

PHP Code: [ Select ]
start
<?php
 
function check_y($word) {
   
   // Make an array to return info
   $return_array = array();
   
   # Credits: Sergio Abreu
   # Matches y followed by vowel in any place...
   
   if( preg_match( "/y[aeiou]/i", $word)){
      $return_array[$word] = 'consonant';
   } elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
      $return_array[$word] = 'vowel';
   }
   
   # To restrict y being the first letter, use ^ :
   
   if( preg_match( "/^y[aeiou]/i", $word)){
      $return_array[$word] = 'consonant';
   } elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
     
      $return_array[$word] = 'vowel';
   }
     
   // Return the return array
   return $return_array;
   
}
 
echo '<pre>';
var_dump(check_text('Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
//check_text('Sylvia');
echo '</pre>';
 
function check_text($text) {
   
   // Make sure we have text
   if(empty($text)) {
     
      // Kick back
      return false;
     
   }
   
   // Break text into words
   $text_array = explode(' ', $text);
   
   // Make an array to return info
   $return_array = array();
   
   // Loop Text
   for($i=0; $i<count($text_array); $i++) {
     
      // Add to the return array
      $return_array[] = check_y($text_array[$i]);
     
   }
   
   // Return the array
   return $return_array;
   
}
 
?>
done
 
  1. start
  2. <?php
  3.  
  4. function check_y($word) {
  5.    
  6.    // Make an array to return info
  7.    $return_array = array();
  8.    
  9.    # Credits: Sergio Abreu
  10.    # Matches y followed by vowel in any place...
  11.    
  12.    if( preg_match( "/y[aeiou]/i", $word)){
  13.       $return_array[$word] = 'consonant';
  14.    } elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
  15.       $return_array[$word] = 'vowel';
  16.    }
  17.    
  18.    # To restrict y being the first letter, use ^ :
  19.    
  20.    if( preg_match( "/^y[aeiou]/i", $word)){
  21.       $return_array[$word] = 'consonant';
  22.    } elseif( preg_match( "/[b-z]y/i", $word) && ! preg_match( "/[aeiou]y/i", $word)){
  23.      
  24.       $return_array[$word] = 'vowel';
  25.    }
  26.      
  27.    // Return the return array
  28.    return $return_array;
  29.    
  30. }
  31.  
  32. echo '<pre>';
  33. var_dump(check_text('Sydney Billy Sylvia Missy Kyle Blythe Sylvester Katy Kay Yeltsin May Kuykendahl yes yam yell yellow yogurt yale gym my cycle baby hairy sky Lynn Yvonne Mary Betty Elly Bryan Maloney Murray Wyatt'));
  34. //check_text('Sylvia');
  35. echo '</pre>';
  36.  
  37. function check_text($text) {
  38.    
  39.    // Make sure we have text
  40.    if(empty($text)) {
  41.      
  42.       // Kick back
  43.       return false;
  44.      
  45.    }
  46.    
  47.    // Break text into words
  48.    $text_array = explode(' ', $text);
  49.    
  50.    // Make an array to return info
  51.    $return_array = array();
  52.    
  53.    // Loop Text
  54.    for($i=0; $i<count($text_array); $i++) {
  55.      
  56.       // Add to the return array
  57.       $return_array[] = check_y($text_array[$i]);
  58.      
  59.    }
  60.    
  61.    // Return the array
  62.    return $return_array;
  63.    
  64. }
  65.  
  66. ?>
  67. done
  68.  
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Décembre 25th, 2012, 2:25 pm

Afficher de l'information

  • Total des messages de ce sujet: 33 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 161 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC