User:Flubot/pagefromfile
Jump to navigation
Jump to search
An example of Greek noun forms to be added by bot.
list-el-ispanida.txt
[edit]xxxx '''Ισπανίδας''' ==Greek== ===Noun=== {{el-noun-form|f|Ispanídas}} # {{genitive of|Ισπανίδα}} {{DEFAULTSORT:ισπανιδασ}} {{count page|[[Wiktionary:Page count]]}} yyyy xxxx '''Ισπανίδων''' ==Greek== ===Noun=== {{el-noun-form|f|Ispanídon}} # {{genitive plural of|Ισπανίδα}} {{DEFAULTSORT:ισπανιδων}} {{count page|[[Wiktionary:Page count]]}} yyyy xxxx '''Ισπανίδες''' ==Greek== ===Noun=== {{el-noun-form|f|Ispanídes}} # {{nominative plural of|Ισπανίδα}} # {{accusative plural of|Ισπανίδα}} # {{vocative plural of|Ισπανίδα}} {{DEFAULTSORT:ισπανιδεσ}} {{count page|[[Wiktionary:Page count]]}} yyyy
Run with: python pagefromfile.py -start:xxxx -end:yyyy -file:list-el-ispanida.txt -notitle
A script that generates wikitext from a source text
[edit]A simple tool that makes easier the creation of the text file I'm going to upload with pagefromfile.py
Runs with: cat source.text | ./pagegenerator.py > final.txt
source.text
[edit]τ<εργαλείο> γ<n> γε<εργαλείου> οακπ<εργαλεία> γπ<εργαλείων> τ<αγάς> γ<m> γακε<αγά> οκαπ<αγάδες> γπ<αγάδων>
pagegenerator.py
[edit]#!/usr/bin/python # -*- coding: utf-8 -*- import sys, re reload(sys) sys.setdefaultencoding('utf8') fin = sys.stdin ch_apo = u'γγ γχ γξ αυγ αυδ αυλ αυμ αυν αυρ αύγ αύδ αύζ αύλ αύμ αύν αύρ αυ αύ ευβ ευγ ευδ ευζ ευλ ευμ ευν ευρ εύβ εύγ εύδ εύζ εύλ εύμ εύν εύρ ευ εύ ϊ α ά β γ δ ε έ ζ η ή θ ι ί κ λ μ ν ξ ου ού ο π ρ σ ς τ υ ύ ϋ φ χ ψ ω ώ ΐ ΰ' ch_se = u'ng nch nx avg avd avl avm avn avr ávg ávd ávz ávl ávm ávn ávr af áφ ev evg evd evz evl evm evn evr év évg évd évz évl évm évn évr ef éf ï a á v g d e é z i í th i í k l m n x ou οú o p r s s t y ý ÿ f ch ps o ó ḯ ÿ́' trapo = ch_apo.split(u' ') trse = ch_se.split(u' ') kl_apo = u'ς ά ό ί ή έ ώ ύ ϊ ϋ ΐ ΰ' kl_se = u'σ α ο ι η ε ω υ ι υ ι υ' klapo = kl_apo.split(u' ') klse = kl_se.split(u' ') title_ = re.compile('^τ<(.*)>') genos_ = re.compile('^γ<(.*)>') ge = re.compile('^γε<(.*)>') ae = re.compile('^αε<(.*)>') ke = re.compile('^κε<(.*)>') okp = re.compile('^οκπ<(.*)>') oakp = re.compile('^οακπ<(.*)>') gp = re.compile('^γπ<(.*)>') ap = re.compile('^απ<(.*)>') gake = re.compile('^γακε<(.*)>') s0 = "xxxx" s1 = "==Greek==\n\n===Noun===\n{{el-noun-form|" s9 = "{{count page|[[Wiktionary:Page count]]}}\nyyyy" nameh="" eof=0 def roman(trnsl): for i in range(len(trapo)): trnsl = trnsl.replace(trapo[i], trse[i]) return trnsl def sortkey(sort): for i in range(len(klapo)): sort = sort.replace(klapo[i], klse[i]) return sort def part1(nameh): print s0 print "'''%s'''" % (nameh) print "%s%s|%s}}" % (s1,genos,roman(nameh)) print return 1 def part3(nameh): print print "{{DEFAULTSORT:%s}}" % (sortkey(nameh)) print print s9 return 1 while not eof: line = fin.readline() if line == "": eof = 1 elif title_.search(line): result = title_.search(line) if result: namer=result.group(1) elif genos_.search(line): result = genos_.search(line) if result: genos=result.group(1) elif ge.search(line): result = ge.search(line) if result: part1(result.group(1)) print "# {{genitive of|%s}}" % (namer) part3(result.group(1)) elif gp.search(line): result = gp.search(line) if result: part1(result.group(1)) print "# {{genitive plural of|%s}}" % (namer) part3(result.group(1)) elif ae.search(line): result = ae.search(line) if result: part1(result.group(1)) print "# {{accusative singular of|%s}}" % (namer) part3(result.group(1)) elif ke.search(line): result = ke.search(line) if result: part1(result.group(1)) print "# {{vocative singular of|%s}}" % (namer) part3(result.group(1)) elif okp.search(line): result = okp.search(line) if result: part1(result.group(1)) print "# {{nominative plural of|%s}}" % (namer) print "# {{vocative plural of|%s}}" % (namer) part3(result.group(1)) elif oakp.search(line): result = oakp.search(line) if result: part1(result.group(1)) print "# {{nominative plural of|%s}}" % (namer) print "# {{accusative plural of|%s}}" % (namer) print "# {{vocative plural of|%s}}" % (namer) part3(result.group(1)) elif ap.search(line): result = ap.search(line) if result: part1(result.group(1)) print "# {{accusative plural of|%s}}" % (namer) part3(result.group(1)) elif gake.search(line): result = ap.search(line) if result: part1(result.group(1)) print "# {{genitive of|%s}}" % (namer) print "# {{accusative singular of|%s}}" % (namer) print "# {{vocative singular of|%s}}" % (namer) part3(result.group(1)) fin.close()