def insertLanguageLinksForWikt(self, wikt, wiktlemmaslist): iwlang = tools.soberlang(wikt) #self.myconn.executemany("update iws set " + iwlang + " = (2 | " + iwlang + ") WHERE lemma = ?", [(x,) for x in wiktlemmaslist] ) print('chan', self.myconn.executemany("update iws set " + iwlang + " = (2 | " + iwlang + ") WHERE lemma = ?", [(x,) for x in wiktlemmaslist] ).rowcount) self.myconn.commit() for row in self.myconn.execute("select * from iws WHERE lemma = ?", (wiktlemmaslist[1],)): print(row['de'])
def getWiktionariesListFromUrl(url): print('διάβασμα της λίστας των Βικιεγχειρημάτων από το δίκτυο...') try: ok, alldata = getHTMLFromPage(url) if not ok: return None return [tools.soberlang(x.split('wiktionary')[0].strip()) for x in alldata.splitlines() if 'wiktionary' in x] except: #print(strerror['geturlerror']) raise #and stop...
def __init__(self, wiktslist, ourlemmas, ourlang): self.wiktslist = wiktslist self.ourlang = ourlang self.cleanwiktlist = [x for x in self.wiktlist if x != self.ourlang] sql = '''CREATE TABLE iws (lemma text,''' sql += ', '.join(['\'' + tools.soberlang(wikt) + '\' INTEGER DEFAULT 0' for wikt in self.cleanwiktlist]) sql += ')' print(sql) self.myconn = sqlite3.connect(":memory:") self.myconn.isolation_level = 'EXCLUSIVE' self.myconn.row_factory = sqlite3.Row self.myconn.execute(sql) print('inserted',self.myconn.executemany("insert into iws(lemma) values (?)", [(x,) for x in ourlemmas]).rowcount) self.myconn.execute('''CREATE INDEX "lemmandx" on iws (lemma ASC)''')