<?php header('Access-Control-Allow-Origin: *'); header('content-type: application/json; charset=utf-8'); //require_once('nerprocess.php'); //$query = "The Inspector General of Kashmir said though the number of local recruitments was not alarming, it has seen a rise this year. Compared to last year where 64 local recruitments took place, this year it increased to 72. India accuses Pakistan of training and arming militants, and infiltrating them across the de facto border, called the Line of Control, dividing Kashmir. Pakistan denies those allegations."; $query = $_GET["q"]; if ($query) { $shmid = shmop_open(1234567890, 'c', 0666, 90000000); $size = shmop_size($shmid); $allChar = shmop_read($shmid, 0, $size); $result = nerTagger($query); $entity = pregMatch($result); $key = array_keys($entity); $finalEntity = array(); $add = "\n"; for ($i = 0; $i < count($key); $i++) { $nowKey = $key[$i]; for ($j = 0; $j < count($entity[$nowKey]); $j++) { $nowchar = $entity[$nowKey][$j] . $add; if (strpos($allChar, $nowchar) !== false) { if (!array_key_exists($entity[$nowKey][$j], $finalEntity)) { $finalEntity[$entity[$nowKey][$j]] = $entity[$nowKey][$j]; } } } } echo $_GET['callback'] . "(" . json_encode($finalEntity) . ")"; } else { echo "need param: q!"; }
/** * check decimal with . is optional and after decimal places up to 6th precision * @param string expecting form field name * @param mixed The default value that should be used when empty. * @return boolean */ public function isDecimal($val, $default = null) { $val = $this->field($val, $default); return (bool) pregMatch("/^\\d+(\\.\\d{1,6})?\$/'", $val); }
<?php switch ($_GET['o']) { case 0: //preg_match_all pregMatchAll($_GET['r'], $_GET['s']); break; case 1: //preg_match pregMatch($_GET['r'], $_GET['s']); break; case 2: //preg_split pregSplit($_GET['r'], $_GET['s']); break; } $flag = $_GET['f']; /* * */ function pregMatch($regex, $str) { if (isset($flag) && $flag != null && $flag != "") { @preg_match("{$regex}", "{$str}", $match, $flag); } else { @preg_match("{$regex}", "{$str}", $match); } print_r($match); } /* *