Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2.  
  3. class TWord{
  4.  
  5. public $text;
  6. public $type;
  7. public $isFirst;
  8. public $isMultiType;
  9. public $isTyped;
  10. public $isLast;
  11. public $index;
  12. public $parent;
  13.  
  14. function _constructor($word, $index, $parent, $last=false){
  15. $this->index=$index;
  16. $this->isFirst = $index==0?true:false;
  17. $this->isLast = $last;
  18. $this->type = array();
  19. $this->isMultiType = false;
  20. $this->isTyped = false;
  21. $this->text = strtolower(trim($word));
  22. $this->parent = $parent;
  23.  
  24. if($this.text === "ya")
  25. $this->setType("ya");
  26. elseif($this.text === "et")
  27. $this->setType("et");
  28. elseif($this.text === "tar")
  29. $this->setType("tarp");
  30. elseif($this.text === "na'a")
  31. $this->setType("naap");
  32. elseif($this.text === "k^o")
  33. $this->setType("ko");
  34. }
  35.  
  36. function setType($type)
  37. array_push($this->type, $type);
  38. $this->isMultiType = count($this->type)>1?true:false;
  39. $this->isTyped = true;
  40. }
  41.  
  42. function next(){
  43. if($this->isLast == false)
  44. return $this->parent[index+1];
  45. else
  46. return false;
  47. }
  48.  
  49.  
  50. function last(){
  51. if($this->isFirst == false)
  52. return $this->parent[index-1];
  53. else
  54. return false;
  55. }
  56.  
  57.  
  58. }
  59.  
  60. class Translation{
  61. public $tantar;
  62. public $words;
  63. public $english;
  64. public $desc;
  65. public $id;
  66. public $isVan;
  67. public $compounds;
  68. public $term;
  69. public $likelyhood;
  70. public $syllables;
  71.  
  72. function _constructor($term, $likelyhood, $info){
  73. $this->words = array();
  74. $this->compounds = array();
  75. $this->info = array();
  76. $this->term = $term;
  77. $this->likelyhood = $likelyhood;
  78. $this->id = $info['id'];
  79. $this->isVan = $info['isvan'];
  80. $this->desc = $info['desc'];
  81. $this->syllables = $info['syllables'];
  82. $this->english = $info['english'];
  83. foreach($wordTypes as $type)
  84. $words[$type] = array();
  85. }
  86. }
  87.  
  88. function WordLookupT($term, $conn){
  89. $translations = array();
  90. $results = $conn->query('SELECT * FROM words WHERE tantar="' . trim(strtolower($term)) . '"');
  91. if ($results->num_rows >0){
  92. while($row = $result->fetch_assoc()){
  93. array_push($tranlsations, Translation($term,0,$row));
  94. }
  95. }
  96. $results = $conn->query('SELECT * FROM words WHERE tantar LIKE "' . trim(strtolower($term)) . '"');
  97. if ($results->num_rows >0){
  98. while($row = $result->fetch_assoc()){
  99. array_push($tranlsations, Translation($term,1,$row));
  100. }
  101. }
  102. foreach($translations as $tran){
  103. $results = $conn->query('SELECT * FROM translations WHERE id="' . $tran->id . '"');
  104. if ($results->num_rows >0){
  105. while($row = $result->fetch_assoc()){
  106. array_push($tran->words[$row['wordtype']], $row['translation']);
  107. }
  108. }
  109. }
  110. return $translations;
  111. }
  112.  
  113. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement