private function findPOSofheadlines() { /* Seperates each headline at spaces and tags their parts of * speech. */ $obj_pos = new PosTagger("../pos/lexicon.txt"); foreach ($this->corpus as $doc_id => $document) { $tags = $obj_pos->tag($document); foreach ($tags as $id => $tag) { //$tags[$id]["token"]=applyPreprocessing($tags[$id]["token"]); $tags[$id]["tag"] = trim($tags[$id]["tag"]); } $this->document_set[$doc_id] = $tags; /* Initially all documents are unclustered. */ array_push($this->unclustered_documents, $doc_id); } }
function posTagText($text) { $tagger = new PosTagger(dirname(__FILE__) . '/../data/postagging-corpus/lexicon.txt'); //global $tagger; $tags = $tagger->tag($text); return $tags; }
#!/usr/bin/env php <?php // little helper function to print the results require_once "pos_tagger.php"; $tagger = new PosTagger('lexicon.txt'); //$t="jump over the fence"; $t = "china exports cooton to russia"; function printTag($tags) { foreach ($tags as $t) { echo $t['token'] . "-" . $t['tag'] . "\n"; } echo "\n"; } $tagger = new PosTagger('lexicon.txt'); $tags = $tagger->tag($t); printTag($tags); /* require_once("../clustering/loadCorpus.php"); $obj_lc=new LoadCorpus(); $corpus=$obj_lc->getAllHeadlines("final"); $fp=fopen("output.".date("ymdHis"), "w"); foreach($corpus as $headline) { $tags = $tagger->tag($headline); $string=""; foreach($tags as $t) { $string.=strtolower($t['token']) . "/" . trim($t['tag']) . " ";
<?php include "PosTagger.php"; function printTag($tags) { foreach ($tags as $t) { echo $t['token'] . "/" . $t['tag'] . " "; } echo "\n"; } $tagger = new PosTagger('lexicon.txt'); $tags = $tagger->tag('Where does Ram live'); printTag($tags);
echo "\n"; }*/ //$studentname=$_POST["st_name"]; if (isset($_POST['st_name'])) { $studentname = $_POST['st_name']; } if (isset($_GET['rollno'])) { $rollNo = $_GET['rollno']; $sql = "SELECT f_name from st_info WHERE Rollno= '{$rollNo}'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $studentname = $row["f_name"]; $studentname1 = $row["l_name"]; } $tagger = new PosTagger('lexicon.txt'); $tags = $tagger->tag($studentname); //printTag($tags); //$i=0; seperatetokens($tags); function checknoun($arr) { $l = count($arr); for ($i = 0; $i < $l; $i++) { $sql = "SELECT * from st_info WHERE f_name= '{$arr[$i]}'"; $result = mysql_query($sql); $n = mysql_num_rows($result); //function checkifname($fname); if (is_resource($result) and $n > 0) { if ($n == 1) { $row = mysql_fetch_array($result); $fname = $row["f_name"];
/** * create keywords from content of page * @param $content plain text content from page * @return string */ public function create_keywords_from_content($content, $url) { $host = parse_url($url)['host']; $tagger = new PosTagger(__DIR__ . "/lexicon.txt"); $tags = $tagger->tag($content); return self::printTag($tags, $host); }