# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys sys.path.insert(0,'../') import db.litebase if __name__ == '__main__': #you can create the dictionary using arramouz database (http://arramooz.sourceforge.net/) # ory ou can find it by downloading #"http://sourceforge.net/projects/mishkal/files/mishkal2013-05-18.tar.bz2/download" # in ./lib/qalsadi/data/arabicdictionary.sqlite srcdb = litebase.liteBase('arabicdictionary.sqlite') dstdb = litebase.liteBase('words.sqlite') tab = litebase.liteTable() tab.beginTable("nouns") tab.addColumn('id', litebase.litePK_INT_INC(), u'', False) tab.addColumn('word', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.addColumn('pattern', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.endTable() print tab.getSqlQuery() dstdb.addTable(tab) src = srcdb.getTable('nouns') rows = src.getData()
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import os from db.litebase import liteBase import pattern import arudquery #~ import wazn if __name__ == '__main__': dbpath = os.path.realpath('test/arabicdict.sqlite') print dbpath srcdb = liteBase(dbpath) tab = srcdb.getTable('nouns') queryengine = arudquery.ArQuery() arpattern = pattern.Pattern(u'مَفْعَل') queryengine.setPattern(arpattern)#wazn.V3I4R3B queryengine.setEnd(u'ب') conditions = queryengine.getResult() print conditions rows = tab.getData(conditions) for row in rows: word = tab.getColumnIndex('word') patt = tab.getColumnIndex('pattern')
sys.path.insert(0, '../') import re from db import litebase from trans.buckwalter import Buckwalter import pattern if __name__ == '__main__': # '''theword = "AbotAE" theword_u = "AbtAE" print distance(theword, "AfotaAEa") print getTemplate(theword, theword_u) exit()''' srcdb = litebase.liteBase(os.path.realpath('../test/ardic.sqlite')) dstdb = litebase.liteBase(os.path.realpath('../test/words.sqlite')) tab = litebase.liteTable() tab.beginTable("words") tab.addColumn('id', litebase.litePK_INT_INC(), u'', False) tab.addColumn('word', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.addColumn('pattern', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.addColumn('vocalized', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.endTable() # print tab.getSqlQuery() dstdb.addTable(tab) src = srcdb.getTable('ardict')
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys import codecs from db.litebase import liteBase, liteINTEGER, liteVARCHAR from db.litebase import liteTable if __name__ == '__main__': dstdb = liteBase('tatoeba.db') f = codecs.open("sentences.csv", "r", "utf-8") i = 0; for line in f: e = line.split("\t"); if len(e) < 3: continue if e[1] in ("ara", "fra", "eng", "jpn"): if not dstdb.containsTable(e[1]): tab = liteTable() tab.beginTable(e[1]) tab.addColumn('id', liteINTEGER(), u'', False) tab.addColumn('sent', liteVARCHAR(60), u'DEFAULT NULL', True) tab.endTable() dstdb.addTable(tab)
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import os from db.litebase import liteBase import pattern import arudquery #~ import wazn if __name__ == '__main__': dbpath = os.path.realpath('test/arabicdict.sqlite') print dbpath srcdb = liteBase(dbpath) tab = srcdb.getTable('nouns') queryengine = arudquery.ArQuery() arpattern = pattern.Pattern(u'مَفْعَل') queryengine.setPattern(arpattern) #wazn.V3I4R3B queryengine.setEnd(u'ب') conditions = queryengine.getResult() print conditions rows = tab.getData(conditions) for row in rows: word = tab.getColumnIndex('word') patt = tab.getColumnIndex('pattern')
import re from db import litebase from trans.buckwalter import Buckwalter import pattern if __name__ == '__main__': # '''theword = "AbotAE" theword_u = "AbtAE" print distance(theword, "AfotaAEa") print getTemplate(theword, theword_u) exit()''' srcdb = litebase.liteBase(os.path.realpath('../test/ardic.sqlite')) dstdb = litebase.liteBase(os.path.realpath('../test/words.sqlite')) tab = litebase.liteTable() tab.beginTable("words") tab.addColumn('id', litebase.litePK_INT_INC(), u'', False) tab.addColumn('word', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.addColumn('pattern', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.addColumn('vocalized', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.endTable() # print tab.getSqlQuery() dstdb.addTable(tab) src = srcdb.getTable('ardict')
# See the License for the specific language governing permissions and # limitations under the License. # import sys sys.path.insert(0, '../') import db.litebase if __name__ == '__main__': #you can create the dictionary using arramouz database (http://arramooz.sourceforge.net/) # ory ou can find it by downloading #"http://sourceforge.net/projects/mishkal/files/mishkal2013-05-18.tar.bz2/download" # in ./lib/qalsadi/data/arabicdictionary.sqlite srcdb = litebase.liteBase('arabicdictionary.sqlite') dstdb = litebase.liteBase('words.sqlite') tab = litebase.liteTable() tab.beginTable("nouns") tab.addColumn('id', litebase.litePK_INT_INC(), u'', False) tab.addColumn('word', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.addColumn('pattern', litebase.liteVARCHAR(20), u'DEFAULT NULL', True) tab.endTable() print tab.getSqlQuery() dstdb.addTable(tab) src = srcdb.getTable('nouns') rows = src.getData()
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import sys import os import codecs from db.litebase import liteBase, liteINTEGER, liteVARCHAR from db.litebase import liteTable if __name__ == '__main__': path = os.path.realpath("tatoeba.db") tatodb = liteBase(path) linksTable = liteTable() if not tatodb.containsTable("links"): linksTable.beginTable("links") linksTable.addColumn('jpnId', liteINTEGER(), u'', True) linksTable.addColumn('id', liteINTEGER(), u'', False) linksTable.endTable() tatodb.addTable(linksTable) else: linksTable = tatodb.getTable("links") f = codecs.open("links.csv", "r", "utf-8") lastskip = "0" jpnTable = tatodb.getTable('jpn') i = 0