<?php $parser = new parser(); $parser->run(); class parser { /** @var string basename of senti files */ protected $_basename = 'SentiWS_v1.8b'; /** @var string directory where senti is stored */ protected $_basedir = '../../ThirdParty/SentiWS_v1.8b/'; /** @var string output sql file name */ protected $_outputFile = '002_SentiWS_DATA_INSERT.sql'; /** @var array parseable files (combined with $_basename) */ protected $_inputFiles = array('_Negative.txt', '_Positive.txt'); /** @var array $_typeMapping mapping to get full types */ protected $_typeMapping = array('NN' => 'noun', 'ADJX' => 'adjective', 'ADV' => 'adverb', 'VVINF' => 'verb'); /** @var file pointer for outputfile */ protected $_outputHandle; /** * Run method for this parser * @return void */ public function run() { $this->_outputHandle = @fopen(realpath(__DIR__) . '/' . $this->_outputFile, "a"); //attach mode foreach ($this->_inputFiles as $inFile) { echo "Proceed file: " . $this->_basename . $inFile . PHP_EOL; $handler = @fopen(realpath(__DIR__ . '/' . $this->_basedir) . '/' . $this->_basename . $inFile, "r"); $this->textToSQL($handler); }
<?php require_once 'parser.php'; $output = ''; if($_POST) { $parser = new parser(); $parser->run($_POST['text']); $output = $parser->getJSONOutput(); } ?> <!DOCTYPE html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <script type="text/javascript" src="js/awesomechart.js"></script> <style> body{ background: #fff; color: #333; } a, a:visited, a:link, a:active{ color: #333; } a:hover{ color: #00f; }