1 : <?php
2 :
3 : /**
4 : * Dictionaries of Old French and Latin
5 : *
6 : * PHP 5
7 : *
8 : * @category DicFro
9 : * @package Model
10 : * @subpackage Query
11 : * @author Michel Corne <mcorne@yahoo.com>
12 : * @copyright 2008-2010 Michel Corne
13 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
14 : * @link http://www.micmap.org/dicfro
15 : */
16 :
17 : require_once 'Model/Query.php';
18 :
19 : /**
20 : * Queries the Tcaf database
21 : *
22 : * @category DicFro
23 : * @package Model
24 : * @subpackage Query
25 : * @author Michel Corne <mcorne@yahoo.com>
26 : * @copyright 2008-2010 Michel Corne
27 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
28 : */
29 :
30 : class Model_Query_Tcaf extends Model_Query
31 : {
32 : /**
33 : * Constructor
34 : *
35 : * @param string $directory the dictionaries directory
36 : * @return void
37 : */
38 : public function __construct($directory = '.')
39 : {
40 10 : parent::__construct($directory . '/tcaf');
41 10 : }
42 :
43 : /**
44 : * Searches the conjugation tables of a verb
45 : *
46 : * @param string $word the verb to search for in any of its forms
47 : * @return array the conjugation tables
48 : */
49 : public function searchVerbConjugation($word)
50 : {
51 3 : $ascii = $this->string->utf8toASCII($word);
52 :
53 3 : $query = "SELECT tense, conjugation, original FROM entry ";
54 3 : $query .= "WHERE ascii IN (SELECT DISTINCT infinitive_ascii FROM word WHERE ascii = :ascii AND tense <> 'comp.') ";
55 3 : $query .= "AND tense <> 'comp.' ";
56 3 : $query .= "ORDER BY ascii";
57 :
58 3 : $result = $this->execute($query, array(':ascii' => $ascii));
59 :
60 3 : return $result;
61 : }
62 :
63 : /**
64 : * Searches the conjugation models of a verb
65 : *
66 : * @param string $word the verb to search for in any of its forms
67 : * @return array the conjugation tables of model verbs
68 : */
69 : public function searchModelConjugation($word)
70 : {
71 2 : $ascii = $this->string->utf8toASCII($word);
72 :
73 2 : $query = "SELECT tense, conjugation, original FROM entry ";
74 2 : $query .= "WHERE ascii IN (SELECT DISTINCT infinitive_ascii FROM word WHERE ascii = :ascii AND tense = 'comp.') ";
75 2 : $query .= "AND tense <> 'comp.' ";
76 2 : $query .= "ORDER BY ascii";
77 :
78 2 : $result = $this->execute($query, array(':ascii' => $ascii));
79 :
80 2 : return $result;
81 : }
82 :
83 : /**
84 : * Searches the verbs composed on a verb
85 : *
86 : * @param string $word the verb to search for in any of its forms
87 : * @return array the list of composed verbs
88 : */
89 : public function searchComposedVerbs($word)
90 : {
91 3 : $ascii = $this->string->utf8toASCII($word);
92 :
93 3 : $query = "SELECT DISTINCT original, infinitive, composed FROM word ";
94 3 : $query .= "WHERE infinitive_ascii IN (SELECT DISTINCT infinitive_ascii FROM word WHERE ascii = :ascii AND tense <> 'comp.') ";
95 3 : $query .= "AND tense = 'comp.' ";
96 3 : $query .= "ORDER BY ascii";
97 :
98 3 : $result = $this->execute($query, array(':ascii' => $ascii));
99 :
100 3 : return $result;
101 : }
102 :
103 : /**
104 : * Searches the forms of any verb same as a given form
105 : *
106 : * @param string $word the form to search for
107 : * @return array the list forms
108 : */
109 : public function searchVerbs($word)
110 : {
111 4 : $ascii = $this->string->utf8toASCII($word);
112 :
113 4 : $query = "SELECT original, infinitive, tense, person FROM word ";
114 4 : $query .= "WHERE ascii = :ascii AND tense <> 'comp.' ";
115 4 : $query .= "ORDER BY ascii";
116 :
117 4 : $result = $this->execute($query, array(':ascii' => $ascii));
118 :
119 4 : return $result;
120 : }
|