public function execute($args) { if (count($args) == 0) { $this->error("Argument is not enough for command mmseg!"); return; } if (count($args) == 1) { if (file_exists($args[0])) { $cmd = "dict"; $input = $args[0]; $output = null; } else { $this->error("Argument is not enough for command mmseg!"); return; } } else { if (count($args) == 2) { if (file_exists($args[0])) { $cmd = "dict"; $input = $args[0]; $output = $args[1]; } else { $cmd = $args[0]; $input = $args[1]; $output = null; } } else { $cmd = $args[0]; $input = $args[1]; $output = $args[2]; } } switch ($cmd) { case "dict": if (!isset($output)) { $output = MmsegCommand::DICT_NAME; } mmseg_create_dict($input, $output); break; case "syno": if (!isset($output)) { $output = MmsegCommand::SYNO_DICT_NAME; } mmseg_create_dict($input, $output); break; case "thes": if (!isset($output)) { $output = MmsegCommand::THESAURUS_DICT_NAME; } mmseg_create_dict($input, $output); break; } echo "Saved to file {$output}!\n"; }
public function createDict($input_file, $output_dir = "/usr/local/etc/") { mmseg_create_dict($input_file, Clips\path_join($output_dir, DICT_NAME)); }