User:Sarri.greek/modules

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Sarri.greektalk ref - audio - notes - nouns - verbs - αβγόαἴρω/αἱρῶΤ' αστέρι του βοριά (song)
CATpg.en :: @elpg.elfontstesttest1vern.labverbs.testtArT1·aT3, T4menu


intro[edit]

recognize hyphen[edit]

I asked Erutuon for help and here are his instructions: I am so thankful! sarri.greek (talk) 02:14, 14 February 2019 (UTC)

see el:Module:tin


@Sarri.greek: The function that you want for testing that a term begins with a Greek letter is mw.ustring.find. (string.find does not always work for Greek letters because it looks at bytes and Greek letters are two or three bytes long in UTF-8.) It returns a number (actually two numbers, but that doesn't matter in the code that you showed me) if the letter was found or nil if it was not, so it can be used in the protasis of an if-statement (if mw.ustring.find(...) then ... end or if mw.ustring.find(...) ~= nil then ... end if you want to explicitly convert to a boolean). To check if a term begins with α, you can use mw.ustring.find(term, '^α'). To check if a term begins with one of multiple characters, put them in square brackets: mw.ustring.find(term, '^[αεηιουω]') checks if term begins with a lowercase vowel letter. ^ at the beginning of the pattern forces the pattern to match only at the beginning of the term, so mw.ustring.find('τη', '^[αεηιουω]') returns nil but mw.ustring.find('τη', '[αεηιουω]') returns a number.
To avoid having to list a bunch of letters with diacritics, you can decompose the term with term = mw.ustring.toNFD(term) before using mw.ustring.find. When decomposed, for instance ά (U+03AC GREEK SMALL LETTER ALPHA WITH TONOS) becomes ά (U+03B1 GREEK SMALL LETTER ALPHA, U+0301 COMBINING ACUTE ACCENT), and mw.ustring.find(mw.ustring.toNFD('ά'), '^[αεηιουω]') will return a number while mw.ustring.find('ά', '^[αεηιουω]') returns nil.
I'm not sure if there is a good Greek module for this type of thing, but I hope this long post helps. I can give a module with examples if you need it. — Eru·tuon 19:52, 15 May 2019 (UTC)
ow this is wonderful: you are a great teacher. I will practice with all the instructions you gave me. Your previous help with the module that recognizes affixes, is a great hit!! We are very grateful. --sarri.greek (talk) 01:47, 16 May 2019 (UTC)
I will experiment with accented letters -which will be very useful-, but in the module I will do the easy thing and reverse the rule: I will state which letters do NOT get the article την (they are just β, γ, δ, θ, φ, χ, λ, μ, ν, ρ, σ, ζ). Thank you!! --sarri.greek (talk) 01:57, 16 May 2019 (UTC)