public function testParseFGC() { $DP = new DataParser(DD, FL, FGC, null, $this->lang); $DP->loadData(); $data = (array) json_decode($DP->parseData()); $this->assertTrue(isset($data['fieldGroups'])); }
/** * @param $name * @return array */ public static function fetchData($name, $wave = 0) { $tt = new DataParser('Towers.csv', 'TowerTranslator'); self::$towerArray = $tt->getCharacteristic(); foreach (self::$towerArray as $kk => $vv) { if (array_search($name, $vv, false)) { return self::$towerArray[$kk]; } } return []; }
public function init($args) { parent::init($args); if (isset($args['PERSON_CLASS'])) { $this->setPersonClass($args['PERSON_CLASS']); } }
public function init($args) { parent::init($args); if (isset($args['EVENT_CLASS'])) { $this->setEventClass($args['EVENT_CLASS']); } }
public function init($args) { parent::init($args); if (isset($args['SIMPLE_MODE'])) { $this->simpleMode = $args['SIMPLE_MODE']; } }
public function clearInternalCache() { parent::clearInternalCache(); $this->root = null; $this->elementStack = array(); $this->data = ''; $this->items = array(); }
/** * @param $name * @return array */ public static function fetchData($name, $wave = 0) { $tt = new DataParser('Waves.csv', 'EnemyTranslator'); self::$enemyArray = $tt->getCharacteristic(); foreach (self::$enemyArray as $kk => $vv) { if ($wave != 0) { if ($vv['wave'] == $wave) { return self::$enemyArray[$kk]; } } else { if (array_search($name, $vv, false)) { return self::$enemyArray[$kk]; } } } return []; }
public function init($args) { parent::init($args); if (isset($args['BASE_URL']) && $args['BASE_URL']) { $urlArray = parse_url($args['BASE_URL']); $this->baseUrl = $urlArray['scheme'] . "://" . $urlArray['host']; $this->relativeUrl = dirname($args['BASE_URL']); } }
public function testParseRDFWithEmptyArray() { // Arrange $a = new DataParser(json_decode(' { "@graph": [ ], "@context": { "page": { "@id": "http://semantic-mediawiki.org/swivt/1.0#page", "@type": "@id" } } } ', true)); // Assert $this->assertEquals(0, count($a->parseDataRDF())); }
public function init($args) { parent::init($args); if (isset($args['EVENT_CLASS'])) { $this->setEventClass($args['EVENT_CLASS']); } if (isset($args['CALENDAR_CLASS'])) { $this->setCalendarClass($args['CALENDAR_CLASS']); } }
public function init($args) { parent::init($args); $this->baseURL = $args['BASE_URL']; if (isset($args['ARCGIS_LAYER_ID'])) { $this->defaultLayerId = $args['ARCGIS_LAYER_ID']; } if (isset($args['ID_FIELD'])) { $this->idField = $args['ID_FIELD']; } }
public function init($args) { parent::init($args); $this->baseURL = $args['BASE_URL']; if (isset($args['ARCGIS_LAYER_ID'])) { $this->defaultLayerId = $args['ARCGIS_LAYER_ID']; } if (isset($args['ID_FIELD'])) { $this->idField = $args['ID_FIELD']; } $this->category = array(mapIdForFeedData($args)); }
public function init($args) { parent::init($args); $this->feedId = mapIdForFeedData($args); if (isset($args['PLACEMARK_CLASS'])) { $this->placemarkClass = $args['PLACEMARK_CLASS']; } else { $this->placemarkClass = $this->DEFAULT_PLACEMARK_CLASS; } if (isset($args['TITLE_FIELD'])) { $this->configTitleField = $args['TITLE_FIELD']; } if (isset($args['SUBTITLE_FIELD'])) { $this->configSubtitleField = $args['SUBTITLE_FIELD']; } }
public function parse($formData, $schema) { $result = new \StdClass(); foreach ($formData as $key => $value) { $schemaNode = JsonPath::getSchemaNode($key, $schema); if ($schemaNode && !empty($schemaNode->type)) { switch ($schemaNode->type) { case 'object': $parsedValue = $this->parse($value, $schemaNode); break; case 'string': $parsedValue = (string) $value; break; case 'boolean': $parsedValue = (bool) $value; break; case 'number': $parsedValue = (int) $value; break; case 'array': $parsedValue = array(); foreach ($value as $item) { $parsedValue[] = DataParser::parse($item, $schemaNode->items); } break; default: echo 'Datatype not supported by DataParser: ' . $schemaNode->type . PHP_EOL; print_r($value); print_r($schemaNode); exit; } $result->{$key} = $parsedValue; } } return $result; }
curl_setopt($ch, CURLOPT_POST, true); $response = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); // save LM result $LM_export_path = './temp/4ft_result_' . date('md_His') . '.pmml'; $LM_export = new DOMDocument('1.0', 'UTF-8'); $LM_export->loadXML($response, LIBXML_NOBLANKS); $LM_export->save($LM_export_path); } else { // localhost dev env $LM_import_path = './temp/4ft_task_' . date('md_His') . '.pmml'; $LM_import = new DOMDocument('1.0', 'UTF-8'); $LM_import->loadXML($serializer->serializeRules($data), LIBXML_NOBLANKS); $LM_import->save($LM_import_path); // import LM task exec(DEV_LM_PATH . DS . 'LMSwbImporter.exe /DSN:"LM Barbora.mdb MB" /Input:"' . $LM_import_path . '" /Alias:"' . DEV_LM_PATH . DS . 'Sewebar' . DS . 'Template' . DS . 'LM.PMML.Alias.txt" /Quiet /NoProgress /AppLog:"./temp/_LM_log.dat"'); // run LM task $XPath = new DOMXPath($LM_import); $taskName = $XPath->evaluate('//*[@modelName]/@modelName')->item(0)->value; exec(DEV_LM_PATH . DS . 'LMTaskPooler.exe /DSN:"LM Barbora.mdb MB" /TaskName:"' . $taskName . '" /Quiet /NoProgress /AppLog:"./temp/_LM_log.dat"'); // export LM task $LM_export_path = './temp/4ft_result_' . date('md_His') . '.pmml'; exec(DEV_LM_PATH . DS . 'LMSwbExporter.exe /DSN:"LM Barbora.mdb MB" /TaskName:"' . $taskName . '" /Template:"' . DEV_LM_PATH . DS . '/Sewebar/Template/4ftMiner.Task.ARD.Template.PMML" /Alias:"' . DEV_LM_PATH . DS . 'Sewebar' . DS . 'Template' . DS . 'LM.PMML.Alias.txt" /Output:"' . $LM_export_path . '" /Quiet /NoProgress /AppLog:"./temp/_LM_log.dat"'); $response = file_get_contents($LM_export_path); //$response = preg_replace('/[^(\x20-\x7F)]*/','', $response); } $DP = new DataParser(DDPath, unserialize(FLPath), FGCPath, $response, null, LANG); $DP->loadData(); $DP->parseData(); echo $DP->getER();
/** * The initialization function. Sets the common parameters based on the $args. This method is * called by the public factory method. Subclasses can override this method, but must call parent::init() * FIRST. Optional parameters include PARSER_CLASS, BASE_URL, TITLE and CACHE_LIFETIME. Arguments * are also passed to the data parser object * @param array $args an associative array of arguments and paramters */ protected function init($args) { $this->initArgs = $args; if (isset($args['DEBUG_MODE'])) { $this->setDebugMode($args['DEBUG_MODE']); } // use a parser class if set, otherwise use the default parser class from the controller $args['PARSER_CLASS'] = isset($args['PARSER_CLASS']) ? $args['PARSER_CLASS'] : $this->DEFAULT_PARSER_CLASS; // instantiate the parser class and add it to the controller $parser = DataParser::factory($args['PARSER_CLASS'], $args); $this->setParser($parser); $parser->setDataController($this); if (isset($args['BASE_URL'])) { $this->setBaseURL($args['BASE_URL']); } if (isset($args['TITLE'])) { $this->setTitle($args['TITLE']); } if (isset($args['CACHE_LIFETIME'])) { $this->setCacheLifetime($args['CACHE_LIFETIME']); } $this->initStreamContext($args); }
*/ sleep(3); echo '{"Repayment":1,"Amount":0.61,"Duration":0.51,"Age":0.5,"Salary":0.19}'; die; } else { // localhost dev env $LM_import_path = './temp/etree_task_' . date('md_His') . '.pmml'; $LM_import = new DOMDocument('1.0', 'UTF-8'); $LM_import->loadXML($serializer->serializeRules($data), LIBXML_NOBLANKS); $LM_import->save($LM_import_path); // import LM task $cmd = DEV_LM_PATH . DS . 'LMSwbImporter.exe /DSN:"LM Barbora.mdb MB" /Input:"' . $LM_import_path . '" /Alias:"' . DEV_LM_PATH . DS . 'Sewebar' . DS . 'Template' . DS . 'LM.PMML.Alias.txt" /Quiet /NoProgress /AppLog:"./temp/_LM_log.dat"'; //echo $cmd.'<br>'; exec($cmd); // run LM task $XPath = new DOMXPath($LM_import); $taskName = $XPath->evaluate('//*[@modelName]/@modelName')->item(0)->value; $cmd = DEV_LM_PATH . DS . 'LMTaskPooler.exe /DSN:"LM Barbora.mdb MB" /TaskName:"' . $taskName . '" /Quiet /NoProgress /AppLog:"./temp/_LM_log.dat"'; //echo $cmd.'<br>'; exec($cmd); // export LM task $LM_export_path = './temp/etree_result_' . date('md_His') . '.pmml'; $cmd = DEV_LM_PATH . DS . 'LMSwbExporter.exe /DSN:"LM Barbora.mdb MB" /TaskName:"' . $taskName . '" /Template:"' . DEV_LM_PATH . DS . '/Sewebar/Template/ETreeMiner.Task.Template.PMML" /Alias:"' . DEV_LM_PATH . DS . 'Sewebar' . DS . 'Template' . DS . 'LM.PMML.Alias.txt" /Output:"' . $LM_export_path . '" /Quiet /NoProgress /AppLog:"./temp/_LM_log.dat"'; exec($cmd); //echo $cmd.'<br>'; $response = $LM_export_path; } $DP = new DataParser(DDPath, unserialize(FLPath), FGCPath, null, $response, LANG); $DP->loadData(); $DP->parseData(); echo $DP->getRecommendedAttributes();
//this is a workaround. Possible problems occur with a %-sign. //see list on http://www.w3schools.com/tags/ref_urlencode.asp $convertlist = array("-C3-AF" => "ï", "-27" => "'", "-2D" => "-", "-3A" => ":", "-C3-AB" => "ë", "-C3-B6" => "ö"); $result = file_get_contents($fusekiDataset . '/query?output=json&query=' . urlencode($query)); foreach ($convertlist as $key => $val) { $result = str_replace($key, $val, $result); } //$result = str_replace("-C3-AF", "ï", str_replace("-27", "'", str_replace("-2D", "-", str_replace("-3A", ":", file_get_contents($fusekiDataset.'/query?output=json&query=' . urlencode($query)))))); //file_put_contents('php://stderr', print_r('---result waar alle JSON data waarschijnlijk instaat is:', TRUE)); //file_put_contents('php://stderr', print_r($result, TRUE));//-C3-AF ï // Normalize result back to dutch foreach ($languageConvertlist[$FusekiLanguage] as $key => $val) { $result = str_replace($val, $key, $result); } // Parse data $parser = new DataParser(json_decode($result, true)); $objects = $parser->parseDataRDF(); //file_put_contents('php://stderr', print_r($objects, TRUE)); if (count($objects) == 0) { return ""; } //file_put_contents('php://stderr', print_r(json_decode($result, true), TRUE)); $parser->calcDistances($parser->getStart($concept, $objects)); // Handle data $visitor = new NodeMapVisitor(); foreach ($objects as $object) { //file_put_contents('php://stderr', print_r('---objects:', TRUE)); //file_put_contents('php://stderr', print_r($objects, TRUE)); $object->accept($visitor); } // Return JSON
public function testCutLeftWins() { $a = new DataParser(); $this->assertEquals("123", $a->cut("123x5x789", 4, "x")); }
public function init($args) { parent::init($args); $this->categoryId = mapIdForFeedData($args); }
public function parseResponse(DataResponse $response) { if ($authority = $response->getContext('authority')) { $this->authority = $authority; } return parent::parseResponse($response); }
protected function init($args) { $this->initArgs = $args; if (isset($args['DEBUG_MODE'])) { $this->setDebugMode($args['DEBUG_MODE']); } if (isset($args['OPTIONS']) && is_array($args['OPTIONS'])) { $this->setOptions($args['OPTIONS']); } if (isset($args['AUTHORITY'])) { if ($authority = AuthenticationAuthority::getAuthenticationAuthority($args['AUTHORITY'])) { $this->setAuthority($authority); } } if (!isset($args['PARSER_CLASS'])) { if ($this->DEFAULT_PARSER_CLASS) { $args['PARSER_CLASS'] = $this->DEFAULT_PARSER_CLASS; } elseif (isset($args['DEFAULT_PARSER_CLASS']) && strlen($args['DEFAULT_PARSER_CLASS'])) { $args['PARSER_CLASS'] = $args['DEFAULT_PARSER_CLASS']; } else { $args['PARSER_CLASS'] = 'PassthroughDataParser'; } } if (!isset($args['CACHE_LIFETIME'])) { $args['CACHE_LIFETIME'] = $this->DEFAULT_CACHE_LIFETIME; } // instantiate the parser class $parser = DataParser::factory($args['PARSER_CLASS'], $args); $this->setParser($parser); $cacheClass = isset($args['CACHE_CLASS']) ? $args['CACHE_CLASS'] : 'DataCache'; $this->cache = DataCache::factory($cacheClass, $args); }
function parseWSDL($wsdl_data) { $parser = DataParser::factory('WSDLParser', array()); $wsdl = $parser->parseData($wsdl_data); return $wsdl; }
<?php include_once __DIR__ . '/QueryBuilder.class.php'; include_once __DIR__ . '/DataParser.class.php'; include_once __DIR__ . '/visitor/NodeMapVisitor.class.php'; // Load data $querybuilder = new QueryBuilder($_POST["depth"], $_POST["concept"]); $query = $querybuilder->generateQuery($_POST["relations"]); $result = file_get_contents('http://localhost:3030/ds/query?output=json&query=' . urlencode($query)); // Parse data $parser = new DataParser(json_decode($result, true)); $objects = $parser->parseDataRDF(); // Handle data $visitor = new NodeMapVisitor(); foreach ($objects as $object) { $object->accept($visitor); } // Return JSON echo $visitor->getUsableJSON();
protected function init($args) { $args['PARSER_CLASS'] = isset($args['PARSER_CLASS']) ? $args['PARSER_CLASS'] : $this->DEFAULT_PARSER_CLASS; $parser = DataParser::factory($args['PARSER_CLASS'], $args); $this->setParser($parser); if (isset($args['BASE_URL'])) { $this->setBaseURL($args['BASE_URL']); } if (isset($args['TITLE'])) { $this->setTitle($args['TITLE']); } if (isset($args['CACHE_LIFETIME'])) { $this->setCacheLifetime($args['CACHE_LIFETIME']); } }
if (array_key_exists($img, $urlExists)) { $imgPath = LOGO_STORE . ($urlExists[$img] ? $img : LOGO_DEFAULT); echo "{$img} has been already controlled\n"; } else { $header_response = get_headers(LOGO_STORE . $img, 1); // echo $header_response[0] . "\n"; $urlExists[$img] = !strpos($header_response[0], "404"); $imgPath = LOGO_STORE . ($urlExists[$img] ? $img : LOGO_DEFAULT); } } $data[$i][$descrKey] = $text; $data[$i][$logoKey] = $imgPath; } // end elaboration // exit(); $parser = new DataParser(); $data = $parser->renameKeys($data, $replacements); $data = $parser->repairFragmentsInArray($data); include 'clicktags.php'; $urls = clickTags(); $dataGrouped = $parser->groupBy($data, '#PLACEHOLDER1#'); // rearrange $sectorsData in order to have a hash map from companies names to array of hash maps // of with company's sectors and corresponding adv links $companyToSectors = $parser->groupBy($sectorsData, 'company'); // create well-formed string containing links to the sectors correspondign to each company name $companyToSectorsText = []; foreach ($companyToSectors as $companyName => $arr) { $text = []; $len = count($arr); for ($i = 0; $i < $len; $i++) { $tmp = str_replace('#SECTOR_URL#', $arr[$i]['adv_link'], SINGLE_SECTOR_TEMPLATE);
protected function init($args) { //get global options from the site data_retriever section $args = array_merge(Kurogo::getOptionalSiteSection('data_retriever'), $args); $this->initArgs = $args; if (isset($args['DEBUG_MODE'])) { $this->setDebugMode($args['DEBUG_MODE']); } if (isset($args['DEFAULT_CACHE_LIFETIME'])) { $this->DEFAULT_CACHE_LIFETIME = $args['DEFAULT_CACHE_LIFETIME']; } if (isset($args['OPTIONS']) && is_array($args['OPTIONS'])) { $this->setOptions($args['OPTIONS']); } if (isset($args['AUTHORITY'])) { if ($authority = AuthenticationAuthority::getAuthenticationAuthority($args['AUTHORITY'])) { $this->setAuthority($authority); } } if (!isset($args['PARSER_CLASS'])) { if ($this->DEFAULT_PARSER_CLASS) { $args['PARSER_CLASS'] = $this->DEFAULT_PARSER_CLASS; } elseif (isset($args['DEFAULT_PARSER_CLASS']) && strlen($args['DEFAULT_PARSER_CLASS'])) { $args['PARSER_CLASS'] = $args['DEFAULT_PARSER_CLASS']; } else { $args['PARSER_CLASS'] = 'PassthroughDataParser'; } } if (isset($args['CACHE_LIFETIME'])) { $this->cacheLifetime = $args['CACHE_LIFETIME']; } else { $args['CACHE_LIFETIME'] = $this->DEFAULT_CACHE_LIFETIME; } if (isset($args['SHOW_WARNINGS'])) { $this->showWarnings = (bool) $args['SHOW_WARNINGS']; } // instantiate the parser class $parser = DataParser::factory($args['PARSER_CLASS'], $args); $this->setParser($parser); $cacheClass = isset($args['CACHE_CLASS']) ? $args['CACHE_CLASS'] : 'DataCache'; $this->cache = DataCache::factory($cacheClass, $args); }
<?php require_once '../config/Config.php'; require_once '../lib/Bootstrap.php'; $DP = new DataParser(DDPath, unserialize(FLPath), FGCPath, null, null, LANG); $DP->loadData(); echo $DP->parseData();