<?php /************************************************************* * This script is developed by Arturs Sosins aka ar2rsawseen, http://webcodingeasy.com **************************************************************/ echo "<table border='0' cellpadding='50' cellspacing='0'><tr><td>"; echo "<form method='post' action=''>"; echo "<p><textarea name='text' rows='30' cols='80'>The Red Planet is about to be spectacular! \n\n This month and next, Earth is catching up with Mars in an encounter that \n will culminate in the closest approach between the two planets in \n recorded history. The next time Mars may come this close is\n in 2287. Due to the way Jupiter's gravity tugs on \n Mars and perturbs its orbit, astronomers can only be \n certain that Mars has not come this close to Earth \n in the last 5,000 years, but it may be as long as \n 60,000 years before it happens again. \n\n The encounter will culminate on August 27th when\n Mars comes to within 34,649,589 miles of Earth and\n will be (next to the moon) the brightest object in \n the night sky. It will attain a magnitude of -2.9\n and will appear 25.11 arc seconds wide. At a modest\n 75-power magnification \n\n Mars will look as large as the full moon to the naked eye. \n\n Mars will be easy to spot. At the\n beginning of August it will rise in the east at 10p.m. \n and reach its azimuth at about 3 a.m. \n\n By the end of August when the two planets are\n closest, Mars will rise at nightfall and reach its \n highest point in the sky at 12:30a.m. That's pretty\n convenient to see something that no human being has \n seen in recorded history. So, mark your calendar at\n the beginning of August to see Mars grow \n progressively brighter and brighter throughout the \n month.</textarea></p>"; echo "<p><input type='submit' value='Get proper nouns' /></p>"; echo "</td><td><h3>Proper nouns: </h3>"; if (isset($_POST["text"])) { include "./proper_nouns.php"; $pn = new proper_nouns(); echo "<pre>"; $arr = $pn->get($_POST["text"]); print_r($arr); echo "</pre>"; } echo "</td></tr></table>";
<?php /************************************************************* * This script is developed by Arturs Sosins aka ar2rsawseen, http://webcodingeasy.com **************************************************************/ //sample text $text = "My dear Mr. Bennet, said his lady to him one day,have you heard that Netherfield Park in London is let at last? \nMr. Bennet replied that he had not.\nBut it is, returned she for Mrs. Long has just been here, and she told me and Jane all about it.\nMr. Bennet made no answer. His wife cried impatiently. Even the kind Dr. Smith knew better. Mr. Bennet was so odd a mixture of quick\nparts, sarcastic humour, reserve, and caprice, that the experience of three-and-twenty years living in England had been insufficient to\nmake his wife understand his character. Her mind, like her sister Lizzy's, was less difficult to develop."; include "./proper_nouns.php"; //create instance $pn = new proper_nouns(); //get array with proper nouns $arr = $pn->get($text); echo "<pre>"; //output text echo $text . "\n"; //print result print_r($arr); echo "</pre>";
<?php $route = '/proper-nouns/'; $app->post($route, function () use($app) { $ReturnObject = array(); $request = $app->request(); $param = $request->params(); if (isset($param['text'])) { $text = trim(mysql_real_escape_string($param['text'])); } else { $text = ''; } $pn = new proper_nouns($punctuation = $pun); $propernouns = $pn->get($text); $P = array(); foreach ($propernouns as $propernoun) { //echo $propernoun . "<br />"; if (strlen($propernoun) > 3) { array_push($P, $propernoun); } } $app->response()->header("Content-Type", "application/json"); echo format_json(json_encode($P)); });