Skip to content

Commit

Permalink
Reload dictionaries method
Browse files Browse the repository at this point in the history
  • Loading branch information
Darjuš Kazakevič authored and Darjuš Kazakevič committed Jan 26, 2018
1 parent 9bef93f commit dc82350
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/PHPInsight/Sentiment.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,36 @@ private function _cleanString($string) {
return strtolower(strtr($string, $diac, 'AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn'));
}

/**
* Deletes old data/data.* files
* Creates new files from updated source fi
*/
public function reloadDictionaries(){

foreach($this->classes as $class){
$fn = "{$this->dataFolder}data.{$class}.php";
if (file_exists($fn)) {
unlink($fn);
}
}

$dictionaries = __DIR__ . '/dictionaries/';

foreach($this->classes as $class){
$dict = "{$dictionaries}source.{$class}.php";

require_once($dict);

$data = $class;

$fn = "{$this->dataFolder}data.{$class}.php";
file_put_contents($fn, serialize($$data));
}



}

}

?>

0 comments on commit dc82350

Please sign in to comment.