PHP Classes

PHP Sentence Parser: Parses and analyzes words in sentences

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (23)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-10 (3 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 528 All time: 5,657 This week: 104Up
Version License PHP version Categories
sentence-interpreter 1.0.8BSD License5Localization, PHP 5, Text processing
Description 

Author

This class can parse, analyze words and interprets sentences.

It takes an English sentence and breaks it into words to determine if it is a phrase or a clause.

It can also counts the total number of words in a sentence, checks if a word is a palindrome and can generate a new sentence with almost the same meaning using synonyms and other grammar-specific rules.

Innovation Award
PHP Programming Innovation award nominee
April 2015
Number 4


Prize: One copy of the Zend Studio
Some applications need to rewrite phrases using different words without losing the original meaning.

This class provides a solution that can parse a sentence into its different parts, so some words can be replaced by synonyms to rewrite the original phrase.

Manuel Lemos
Picture of Samuel Adeshina
  Performance   Level  
Name: Samuel Adeshina <contact>
Classes: 19 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Recommendations

Extract text or links from a web page
i need to parse and extract text

Resume Parser API
Document parse and populate forms and database

spelling checker using php coding
i want to learn and write

hunspell synonym
How to get synonym using Hunspell in PHP

Example

<?php
require_once("index.php");
 
//begin test
 
$sentence_array = array("1"=>"My name is Samuel Adeshina. I am 16 Years Old",
                        
"2"=>"Life is fair only to fair people`, that is one big fair lie from somebody who has never told a fair lie",
                        
"3"=>"English Language is a LANGUAGE a language of languages",
                        
"4"=>"I dont know what else to write, but i know one thing this class has a lot of promise for the english fanatics",
                        
"5"=>"Alright! Lets begin the long journey to testing this program");
 
$random = rand(1, 5);
 
$sentence_to_use = $sentence_array[$random];
 
$sentence = new use_break_sentence($sentence_to_use, true);
 
$numberOfWords = $sentence->use_method("words count", 0);
 
$arrayOfWords = $sentence->use_method("word array", 0);
 
$delimitedWords = $sentence->use_method("delimit words", false);
 
$isValidWord = $sentence->use_method("validity", "dict_files");
 
$partOfSpeech = $sentence->use_method("find pos", 0);
 
$distinctWords = $sentence->use_method("group_words", true);
 
$ngram = $sentence->getNgram('Digestion', 3); //Added: 7/5/2015. A method for getting the n-gram component of a word
 
echo "<center><h1>EXAMPLES (Sentence-Interpreter)</h1></center><br/>SUPPLIED SENTENCE: <h2>".$sentence_to_use."</h2><br/>";
 echo <<<_END
<table border="1">
         <tr style = "background-color: #333; color: #fff">
             <th>Number of Words</th>
             <th>Array Words</th>
             <th>Array of Distinct Words In Sentence</th>
             <th>Array of Words + their Validity</th>
             <th>Array of words + their part of speech</th>
             <th>N-gram Components of the word: Digestion</th>
         </tr>
         <tr>
             <th>
$numberOfWords</th>
             <th>
_END;
           
print_r($arrayOfWords);
            echo
"</th><th>";
           
print_r($distinctWords);
            echo
"</th><th>";
           
print_r($isValidWord);
            echo
"</th><th>";
           
print_r($partOfSpeech);
            echo
"</th><th>";
           
print_r($ngram);
            echo
"</th></tr></table>";
?>


Details

Sentence-Interpreter

This Repository is a PHP Repository that contains classes and functions for analyzing sentences, breaking words into corresponding parts of speech, and so in


Screenshots  
  • desktop.PNG
  Files folder image Files  
File Role Description
Files folder imagedict_files (14 files)
Plain text file break_sentence.php Class Class source
HTML file index.php Class Method Dispatcher
Accessible without login Plain text file LICENSE Lic. Auxiliary data
Accessible without login Plain text file pos-list.txt Data This File Stores A List of English Words + their part of speech
Accessible without login Plain text file README.md Data Auxiliary data
Accessible without login Plain text file readme.txt Lic. NIL
Accessible without login Plain text file test.php Example NIL
Accessible without login HTML file test2.php Test Test.php in another without tables just line breaks
Accessible without login Plain text file todo.txt Data NIL

  Files folder image Files  /  dict_files  
File Role Description
  Accessible without login Plain text file center.dic Data NIL
  Accessible without login Plain text file centre.dic Data NIL
  Accessible without login Plain text file color.dic Data NIL
  Accessible without login Plain text file colour.dic Data NIL
  Accessible without login Plain text file English.txt Data NIL
  Accessible without login Plain text file eng_com.dic Data A dictionary file
  Accessible without login Plain text file en_GB.dic Data NIL
  Accessible without login Plain text file en_US.dic Data NIL
  Accessible without login Plain text file Ise.dic Data NIL
  Accessible without login Plain text file Ize.dic Data NIL
  Accessible without login Plain text file labeled.dic Data NIL
  Accessible without login Plain text file labelled.dic Data NIL
  Accessible without login Plain text file yse.dic Data NIL
  Accessible without login Plain text file yze.dic Data NIL

 Version Control Unique User Downloads Download Rankings  
 95%
Total:528
This week:0
All time:5,657
This week:104Up