Java-based library Aho-Corasick string matching algorithm for PHP application -


i have piece of php code can search $list keywords in $post data , echo results there ~80-90% similarity. below code:

$list = array(     "data" => "9",     "data structure" => "10",     "database" => "11",     "creativity" => "12",     "forest" => "13",     "al pacino" => "14",     "humans" => "15",     "technology" => "16"     );  $post = array ('database', 'law', 'tech', 'creative');  $all_key_values = $all_keys = array();  foreach ($post $keyword) {     foreach ($list $word=>$num) {         $sim_chars = similar_text($keyword, $word);         if ($sim_chars/strlen($keyword) > .8 || $sim_chars/strlen($word) > .8) {             $all_key_values[] = $num;             $all_keys[] = $word;         }         elseif (stripos($keyword, $word) !== false || strpos($word, $keyword) !== false) {             $sll_key_values[] = $num;             $all_keys[] = $word;         }     }         }  print_r(implode(',', $all_key_values)); print_r(implode(',', $all_keys)); 

now, problem want search $list keywords in $fulltext using aho-corasick library written in java. can find code in here.

require_once("http://localhost:8080/javabridge/java/java.inc");  $list = array(     "data" => "9",     "data structure" => "10",     "database" => "11",     "creativity" => "12",     "forest" => "13",     "al pacino" => "14",     "humans" => "15",     "technology" => "16"     );  $fulltext = "a forest, referred wood or woods, area high density of trees. cities, depending on various cultural definitions, considered forest may vary in size , have different classifications according how , of forest composed.[1] forest area filled trees tall densely packed area of vegetation may considered forest, underwater vegetation such kelp forests, or non-vegetation such fungi,[2] , bacteria. tree forests cover approximately 9.4 percent of earth's surface (or 30 percent of total land area), though once covered more (about 50 percent of total land area). function habitats organisms, hydrologic flow modulators, , soil conservers, constituting 1 of important aspects of biosphere. typical tree forest composed of overstory (canopy or upper tree layer) , understory. understory further subdivided shrub layer, herb layer, , moss layer , soil microbes. in complex forests, there well-defined lower tree layer. forests central human life because provide diverse range of resources: store carbon, aid in regulating planetary climate, purify water , mitigate natural hazards such floods. forests contain 90 percent of worlds terrestrial biodiversity."; 

so, question how call aho-corasick library in order search $list in $fulltext , find keywords 100% similarity. lot , time.

you cannot include java libraray in php code. write java server application (in java) can accept data php code. number of ways thinkable- socket communication, web services simple command line tool. alternative of course reimplement java library in php- learn lot php , java both algorithm.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -