array(),"mixedcase"=>array(),"numbers"=>array()); $errors = array(); } if(file_exists("smsdico.txt")) $words = implode("",file("smsdico.txt")); else $words = 'bjr,slt,kif,pcq,pkoi,pk,dc,ac,copin,c,kop1,bo,ché,ya,foto,fotos,lol,mdr,ct,sui,ke,koi,kan,mm,jvé,jai,komen,vré,ki,'. '2m1,asv,bsr,ayé,cad,càd,keske,stp,qd,rdv,tjs,tjr,bcp,meuf,ct,msg,pb,kkun,kk1,tt,fo,kune,ele,el,kil,pa,assé,pouré,ben,vs,ny,avai,'. 'dechire,grave,po,koa,cho,otres,otre,ptit,pti,tro,jparle,voi,posible,ds,moa,fè,bô,arf,acht,tit,ptin,j\'ador,jador,hihi,poskeuh,'. 'zentil,jle,jui,jsui,pis,vala,tits,ouej,keum,loul,tlm,alor,gt,tou,pe,ko,kon,kun'; $words = ereg_replace("[, \n\r\t-]",",",$words); $words = ereg_replace("([, ]){2,}","\\1",$words); $words = explode(",",$words); $text = strip_tags(trim($text)); $text = strtr($text,"àâäéèêëçùûüôöÀÂÉÈÊËÇÙÛÜÔÖ","aaaeeeecuuuooAAEEEECUUUOO"); $text = ereg_replace("([!?.]){2,}","\\1",$text); if(!ereg("[.?!]",$text)) { $points += 10; if($e) $errors[] = "Aucune ponctuation."; } $sentences = explode(". ",ereg_replace("[?!]",".",$text)); foreach($sentences as $s) { if(ereg("^[a-z]",trim($s))) { $points += 5; $errors[] = "Pas de majuscule au début de cette phrase: ".$s; } } $text = ereg_replace("[.,;:]"," ",$text); $text = ereg_replace("[ ]{2,}"," ",$text); $text = explode(" ",stripslashes($text)); foreach($text as $w) { if(!ereg("^[a-zA-Z0-9]+$",$w) || ereg("^[0-9]+$",$w)) continue; if(in_array(strtolower($w),$words)) { $points += 4; if($e) $foundErrors['words'][] = $w; } elseif(ereg("^(([A-Z]+[a-z]+){2,}|([a-z]+[A-Z]+[a-z]*)+)$",$w)) { $points += 3; if($e) $foundErrors['mixedcase'][] = $w; } elseif(ereg("[0-9]+",$w)) { $points += 2; if($e) $foundErrors['numbers'][] = $w; } elseif(strlen($w) == 1) $points++; } if($e) { if(count($foundErrors['words']) > 0) $errors[] = 'Mots correspondants au dictionnaire SMS: '.implode(", ",$foundErrors['words']); if(count($foundErrors['mixedcase']) > 0) $errors[] = 'Mots contenant des mAjUsCuLeS: '.implode(", ",$foundErrors['mixedcase']); if(count($foundErrors['numbers']) > 0) $errors[] = 'Mots contenant des chiffres: '.implode(", ",$foundErrors['numbers']); return array("score"=>$points,"errors"=>$errors); } else return $points; } echo '

Détecteur de langage SMS

'; if($_POST['text']) { $detected = is_sms($_POST['text'],TRUE); if($detected['score'] >= 10) echo '

Langage SMS détecté (plus de ou égal à 10 points).

'; else echo '

Pas de langage SMS détecté (inférieur à 10 points).

'; echo '
Nombre de points détectés
'.$detected['score'].'
Erreurs rencontrées:
'; foreach($detected['errors'] as $e) echo '
'.stripslashes($e).'
'; echo '

'; } echo '

                        Code source | Dictionnaire des mots SMS
'; ?>