Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2024-01-10 (3 days ago) | | Not yet rated by the users | | Total: 528 | | All time: 5,657 This week: 104 |
|
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
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 |
| |
|
|
Innovation award
Nominee: 7x
Winner: 1x |
|
Recommendations
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
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.