Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class TWord{
- public $text;
- public $type;
- public $isFirst;
- public $isMultiType;
- public $isTyped;
- public $isLast;
- public $index;
- public $parent;
- function _constructor($word, $index, $parent, $last=false){
- $this->index=$index;
- $this->isFirst = $index==0?true:false;
- $this->isLast = $last;
- $this->type = array();
- $this->isMultiType = false;
- $this->isTyped = false;
- $this->text = strtolower(trim($word));
- $this->parent = $parent;
- if($this.text === "ya")
- $this->setType("ya");
- elseif($this.text === "et")
- $this->setType("et");
- elseif($this.text === "tar")
- $this->setType("tarp");
- elseif($this.text === "na'a")
- $this->setType("naap");
- elseif($this.text === "k^o")
- $this->setType("ko");
- }
- function setType($type)
- array_push($this->type, $type);
- $this->isMultiType = count($this->type)>1?true:false;
- $this->isTyped = true;
- }
- function next(){
- if($this->isLast == false)
- return $this->parent[index+1];
- else
- return false;
- }
- function last(){
- if($this->isFirst == false)
- return $this->parent[index-1];
- else
- return false;
- }
- }
- class Translation{
- public $tantar;
- public $words;
- public $english;
- public $desc;
- public $id;
- public $isVan;
- public $compounds;
- public $term;
- public $likelyhood;
- public $syllables;
- function _constructor($term, $likelyhood, $info){
- $this->words = array();
- $this->compounds = array();
- $this->info = array();
- $this->term = $term;
- $this->likelyhood = $likelyhood;
- $this->id = $info['id'];
- $this->isVan = $info['isvan'];
- $this->desc = $info['desc'];
- $this->syllables = $info['syllables'];
- $this->english = $info['english'];
- foreach($wordTypes as $type)
- $words[$type] = array();
- }
- }
- function WordLookupT($term, $conn){
- $translations = array();
- $results = $conn->query('SELECT * FROM words WHERE tantar="' . trim(strtolower($term)) . '"');
- if ($results->num_rows >0){
- while($row = $result->fetch_assoc()){
- array_push($tranlsations, Translation($term,0,$row));
- }
- }
- $results = $conn->query('SELECT * FROM words WHERE tantar LIKE "' . trim(strtolower($term)) . '"');
- if ($results->num_rows >0){
- while($row = $result->fetch_assoc()){
- array_push($tranlsations, Translation($term,1,$row));
- }
- }
- foreach($translations as $tran){
- $results = $conn->query('SELECT * FROM translations WHERE id="' . $tran->id . '"');
- if ($results->num_rows >0){
- while($row = $result->fetch_assoc()){
- array_push($tran->words[$row['wordtype']], $row['translation']);
- }
- }
- }
- return $translations;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement