PHP Classes

VowCon: Determine if words in a string are real or made up

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 46%Total: 358 All time: 6,933 This week: 673Up
Version License PHP version Categories
vowcon 1.2GNU Lesser Genera...4.2Algorithms, PHP 5, Text processing
Description 

Author

This package can be used to determine if words in a string are real or made up.

It provides two classes to analise individual words or sentences to evaluate the presence of vowels and consonants.

The classes provide statistics about the string and a score that can be used to determine if the words really exist or are invented due to the presence of many consecutive consonants.

Innovation Award
PHP Programming Innovation award nominee
January 2014
Number 2


Prize: One copy of the Zend Studio
Sometimes it is necessary to determine if a word was written by a real person or is not a real a word.

This class provides a solution to evaluate the probability of a word or a phrase being real or made up.

It analyses the presence of vowels and consonants and returns a score that can be low if there are too many consecutive consonants.

Manuel Lemos
Picture of Roger Baklund
  Performance   Level  
Name: Roger Baklund is available for providing paid consulting. Contact Roger Baklund .
Classes: 7 packages by
Country: Norway Norway
Age: 57
All time rank: 18056 in Norway Norway
Week rank: 216 Up1 in Norway Norway Up
Innovation award
Innovation award
Nominee: 4x

Example

<?php

require_once('VowCon.php');

echo
"Testing VowConStats class:\n\n";

$words = array("sportsdrink","abc","bcd","aui","aaa","aaaa",
 
"asdasdasd","kjhgf","aeiou","klkla",
 
"recognition", "floccinauccinihilipilification",
 
"paraskevidekatriaphobia","antidisestablishmentarianism");
$v = new VowConStats();
foreach(
$words as $word) {
 
$s = $v->Stats($word);
  echo
sprintf("%-30s => %.2f %s\n",$word,round($s->score,2),
    (
$s->score > 5.0 ? '!!':
    (
$s->score > 3.5 ? '!':'')));
}

echo
"\nTesting VowConAnalyzer class:\n\n";

$v = new VowConAnalyzer();

echo
"For analyzing a collection of words. There are four properties\n".
    
"which can be used to configure the operation. The default values\n".
    
"are as follows:\n\n";
echo
'MaxAvgScore: '.$v->MaxAvgScore."\n".
    
'MaxWordScore: '.$v->MaxWordScore."\n".
    
'MaxBadPercent: '.$v->MaxBadPercent."\n".
    
'BadWordLimit: '.$v->BadWordLimit."\n\n".

# load words, parameter can be array of words or a string
# which will be split using the Split() method
$v->LoadText($words);

echo
"Status for the test word collection:\n\n";

echo
'$v->GetTextStatus() => '.$v->GetTextStatus()."\n";

echo
'count($v->words) => '.count($v->words)."\n";
echo
'$v->TextStats->MaxScore => '.$v->TextStats->MaxScore."\n";
echo
'$v->TextStats->AvgScore => '.$v->TextStats->AvgScore."\n";
echo
'$v->TextStats->BadPercent => '.$v->TextStats->BadPercent."\n";

echo
"\nLooping over the collection:\n\n";
foreach(
$v->words as $word) {
 
$s = $v->GetWordScore($word);
  echo
sprintf("%-30s => %.2f %s\n",$word,round($s,2),
   
$v->WordIsValid($word)? # using BadWordLimit
   
'OK':($s > $v->MaxWordScore ? 'Above max word score':'Above bad word limit'));
}



?>


Details

VowCon

This package provides two classes which can be used for analyzing text with regards to patterns of vowels and consonants. In natural language, there is a certain balance between the two: there are rarely very many consecutive consonants or vowels in a real word.

Many spambots include a randomly generated word in their payload, these words will fail the tests provided by this package.


Screenshots  
  • screenshot1.png
  • screenshot2.png
  Files folder image Files  
File Role Description
Files folder imagescreenshots (2 files)
Accessible without login Plain text file README.md Data Auxiliary data
Plain text file ScandinavianVowConAnalyzer.class.php Class Adds scandinavian (norwegian/danish) vowels
Plain text file VowCon.php Class Defines VowConStats and VowConAnalyzer classes
Accessible without login Plain text file VowCon_test_1.php Example basic tests

  Files folder image Files  /  screenshots  
File Role Description
  Accessible without login Image file vowcon_test_1.png Icon Icon image
  Accessible without login Image file vowcon_test_2.png Icon Icon image

 Version Control Reuses Unique User Downloads Download Rankings  
 75%1
Total:358
This week:0
All time:6,933
This week:673Up
 User Ratings  
 
 All time
Utility:66%StarStarStarStar
Consistency:66%StarStarStarStar
Documentation:-
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:46%StarStarStar
Rank:3199