PHP Classes

PHP Get All Words: Extract all words from string excluding stop words

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 48%Total: 371 All time: 6,803 This week: 673Up
Version License PHP version Categories
get-words 1.0.0GNU General Publi...5PHP 5, Text processing
Description 

Author

This class can extract all words from string excluding stop words.

It can take a given text string and extracts the list of all words it contains to a array.

An optional list of stop words may be provided to be excluded from the list of words to return.

The class may lower the case of the words to consider words with upper and lower case letters the same.

Innovation Award
PHP Programming Innovation award nominee
April 2016
Number 13


Prize: One ebook of choice by Packt
PHP provides an extensive set of functions to manipulate text strings including several ways to split a string into its words.

However, there is no built-in way to detect and exclude stop words.

This class can extract the words of a text excluding stop words. I can also consider words that may appear duplicated but with different case.

Manuel Lemos
Picture of Lionel F. Lebeau
  Performance   Level  
Name: Lionel F. Lebeau <contact>
Classes: 4 packages by
Country: France France
Age: 63
All time rank: 245268 in France France
Week rank: 295 Up8 in France France Up
Innovation award
Innovation award
Nominee: 2x

Recommendations

Get all words in sentence
Some class to get all of words in sentence

Example

<?php
// français
//$text = "Un été à Quibron.";
//$stopwords = array('un','à');

// anglais avec apostrophe et I dans les deux casses
//$text = "Now in 2016, it's 12:28. I am mikel and i from USA";
//$stopwords = array('a','I','the');

// anglais multilignes
/*$text = "After having owned the BMW X3, the MDX is a pleasure to drive.
 Reliability is great for 25,000 miles. Only things wrong are Bluetooth; rings and cannot hear whose on the other end and many viable addresses do not show up on Navigation system.
 Dealer service excellent.
 A few miss-steps in design; no lights for A/C controls at night; rear view pic doesn't come on in reverse for 10 seconds, some wind noise, transmission can be rough and erratic. No ipod plug which I didn't realize until after I purchased. Front end design could be improved, very masculine.
 Sounds like a lot but I do really like this car.
 Also test drove BMW X5 and Lexus 400.";*/
//$stopwords = array('a','I','the','no');

// chinois
/*$text = "????????????????????????????????????????????????????????

????????

?????";*/
//$stopwords = array('?????','???');

// arabe :
//$text = "???? ?? ???.";
//$stopwords = array('??');

// hébreux :
//$text = "???? ??? ???.";
//$stopwords = array('???');

// allemand :
//$text = "Können Sie mir helfen Über das? ";
//$stopwords = array('über');

$getwords = new get_words($text,$stopwords,true);
$words = $getwords->getWords();
//var_dump($words);
if(PHP_SAPI != 'cli'){
    print
'<pre>';
   
print_r($words);
    print
'</pre>';
}else{
   
print_r($words);
}
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file Examples.php Example Examples
Plain text file get_words.php Class class to get words

 Version Control Unique User Downloads Download Rankings  
 0%
Total:371
This week:0
All time:6,803
This week:673Up
 User Ratings  
 
 All time
Utility:66%StarStarStarStar
Consistency:66%StarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:48%StarStarStar
Rank:2969