public function parseQuery($query) { switch ($query) { /***********************************************************************************/ // Include defparse class and create new object with 3 variables. /***********************************************************************************/ case "def": if (isset($this->langParameters) and isset($this->word) and isset($this->source) and isset($this->count)) { $DefParse = new DefParse($this->langParameters); $wikitext = $this->get_wiki_text($this->langParameters, $this->source, $this->word); if (isset($DefParse)) { $parsedDefinition = $DefParse->getDef($wikitext, $this->count); } } break; /***********************************************************************************/ // Include posparse class and create new object with 3 variables. /***********************************************************************************/ /***********************************************************************************/ // Include posparse class and create new object with 3 variables. /***********************************************************************************/ case "pos": include 'lib/class.posparse.php'; if (isset($this->langParameters) and isset($this->word) and isset($this->source) and isset($this->count)) { $posparse = new PosParse($this->langParameters); $wikitext = $this->get_wiki_text($this->langParameters, $this->source, $this->word); if (isset($DefParse)) { $parsedDefinition = $posparse->get_pos($wikitext, $this->count); } } break; /***********************************************************************************/ // Include synparse class and create new object with 3 variables. /***********************************************************************************/ /***********************************************************************************/ // Include synparse class and create new object with 3 variables. /***********************************************************************************/ case "syn": include 'lib/class.synparse.php'; if (isset($this->langParameters) and isset($this->word) and isset($this->source) and isset($this->count)) { $SynParse = new SynParse($this->langParameters); $wikitext = $this->get_wiki_text($this->langParameters, $this->source, $this->word); if (isset($DefParse)) { $parsedDefinition = $SynParse->get_syn($wikitext, $this->count); } } break; /***********************************************************************************/ // Include hyperparse class and create new object with 3 variables. (Hypernyms) /***********************************************************************************/ /***********************************************************************************/ // Include hyperparse class and create new object with 3 variables. (Hypernyms) /***********************************************************************************/ case "hyper": include 'lib/class.hyperparse.php'; if (isset($this->langParameters) and isset($this->word) and isset($this->source) and isset($this->count)) { $HyperParse = new HyperParse($this->langParameters); $wikitext = $this->get_wiki_text($this->langParameters, $this->source, $this->word); if (isset($DefParse)) { $parsedDefinition = $HyperParse->get_hyper($wikitext, $this->count); } } break; /***********************************************************************************/ // Include genderparse class and create new object with 3 variables. (Gender) /***********************************************************************************/ /***********************************************************************************/ // Include genderparse class and create new object with 3 variables. (Gender) /***********************************************************************************/ case "gender": include 'lib/class.genderparse.php'; if (isset($this->langParameters) and isset($this->word) and isset($this->source) and isset($this->count)) { $GenderParse = new GenderParse($this->langParameters); $wikitext = $this->get_wiki_text($this->langParameters, $this->source, $this->word); if (isset($DefParse)) { $parsedDefinition = $GenderParse->get_gender($wikitext, $this->count); } } break; /***********************************************************************************/ /***********************************************************************************/ default: echo "You must specify a valid query type ('pos', 'def', 'syn', 'hyper', or 'gender')."; break; } if (isset($parsedDefinition)) { return $parsedDefinition; } else { return []; } }
$HyperParse = new HyperParse($langParameters); $wikitext = get_wiki_text($langParameters, $wikiSource, $word); $hyperArray = $HyperParse->get_hyper($wikitext, $count); printResults($hyperArray); break; /***********************************************************************************/ // Include genderparse class and create new object with 3 variables. (Gender) /***********************************************************************************/ /***********************************************************************************/ // Include genderparse class and create new object with 3 variables. (Gender) /***********************************************************************************/ case "gender": include 'classes/class.genderparse.php'; $GenderParse = new GenderParse($langParameters); $wikitext = get_wiki_text($langParameters, $wikiSource, $word); $genderArray = $GenderParse->get_gender($wikitext, $count); printResults($genderArray); break; /***********************************************************************************/ /***********************************************************************************/ default: echo "You must specify a valid query type ('pos', 'def', 'syn', 'hyper', or 'gender')."; break; } /***********************************************************************************/ // Include wikiextract class and create new object with 2 variables. Returns the // contents of the wiktionary entry for a given word. /***********************************************************************************/ function get_wiki_text($langParameters, $wikiSource, $word) { include 'classes/class.wikiextract.php';