User:Flubot/pagefromfile/άγονος

This script produces the wikitext for adjective forms (-ος -η -ο).

We need:
 * 1) a source file with the stems of the adjectives. Each stem must be in a separate line.
 * 2) python
 * 3) pywikipedia (pagefromfile.py) to upload the output of this script.

Run with: cat source.text | generateforms.py > output.txt Then: python pagefromfile.py -start:xxxx -end:yyyy -file:output.txt -notitle

source.text
άγον άδηλ άζυμ άθε

generateforms.py

 * 1) !/usr/bin/python
 * 2) -*- 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' ')

katalixeis = 'ου ο οι ων η ης ες α ε ους' ktlx = katalixeis.split(u' ') hme = len(ktlx)

riza = re.compile(u'(.*)') eof=0

s = [[' ' for l1 in range(4)] for l2 in range(hme)] n = [] s[0][0]='|g=m|c=gen|n=s}}' s[0][1]='|g=n|c=gen|n=s}}' n.append(2) s[1][0]='|g=m|c=acc|n=s}}' s[1][1]='|g=n|c=nom|n=s}}' s[1][2]='|g=n|c=acc|n=s}}' s[1][3]='|g=n|c=voc|n=s}}' n.append(4) s[2][0]='|g=m|c=nom|n=p}}' s[2][1]='|g=m|c=voc|n=p}}' n.append(2) s[3][0]='|g=m|c=gen|n=p}}' s[3][1]='|g=f|c=gen|n=p}}' s[3][2]='|g=n|c=gen|n=p}}' n.append(3) s[4][0]='|g=f|c=nom|n=s}}' s[4][1]='|g=f|c=acc|n=s}}' s[4][2]='|g=f|c=voc|n=s}}' n.append(3) s[5][0]='|g=f|c=gen|n=s}}' n.append(1) s[6][0]='|g=f|c=nom|n=p}}' s[6][1]='|g=f|c=acc|n=p}}' s[6][2]='|g=f|c=voc|n=p}}' n.append(3) s[7][0]='|g=n|c=nom|n=p}}' s[7][1]='|g=n|c=acc|n=p}}' s[7][2]='|g=n|c=voc|n=p}}' n.append(3) s[8][0]='|g=m|c=voc|n=s}}' n.append(1) s[9][0]='|g=m|c=acc|n=p}}' n.append(1)
 * ου
 * ο
 * οι
 * ων
 * η
 * ης
 * ες
 * α
 * ε
 * 1) ους

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 makeentries(ri): l = [ ] for i in range(hme): l.append(ri+ktlx[i]) print "xxxx" print "%s" % (l[i]) print "==Greek==\n\n===Adjective===" print "\n" % (roman(l[i])) for j in range(n[i]): print "# {{el-form-of-nounadj|%sος%s" % (ri,s[i][j]) print "\n{{DEFAULTSORT:%s}}\n" % (sortkey(l[i])) print "{{count page|Page count}}\nyyyy" return 1

while not eof: line = fin.readline if line == "": eof = 1 else: r0 = riza.search(line) r1 = r0.group(1) if r1 != "": makeentries(r1) fin.close