User:Sarri.greek/modules
Appearance
choose this page's desktop style: | vectorClassic2010 - vector2022 - monobook & mobile |
logged-in users: | Global Preferences > ✓ O > Save |
Sarri.greek • talk —
ref -
audio -
notes -
nouns -
verbs -
αβγό •
αἴρω&αἱρῶ •
Τ' αστέρι του βοριά (song)
CAT •
pg.en ::
@el •
pg.el —
fonts •
test •
test1 •
verb.lab •
verbs.test •
style •
tAr •
T1·a •
T3, T4 •
menu
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 ornil
if it was not, so it can be used in the protasis of an if-statement (if mw.ustring.find(...) then ... end
orif mw.ustring.find(...) ~= nil then ... end
if you want to explicitly convert to a boolean). To check if a term begins with α, you can usemw.ustring.find(term, '^α')
. To check if a term begins with one of multiple characters, put them in square brackets:mw.ustring.find(term, '^[αεηιουω]')
checks ifterm
begins with a lowercase vowel letter.^
at the beginning of the pattern forces the pattern to match only at the beginning of the term, somw.ustring.find('τη', '^[αεηιουω]')
returns nil butmw.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 usingmw.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), andmw.ustring.find(mw.ustring.toNFD('ά'), '^[αεηιουω]')
will return a number whilemw.ustring.find('ά', '^[αεηιουω]')
returnsnil
. - 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)