Module talk:palindromes/testcases

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

I think I'm setting up these tests wrong... @CodeCat what's going on here? DTLHS (talk) 01:56, 26 August 2016 (UTC)[reply]

I don't know what's going on with the error, but everything else works now. I'm not sure if we actually need a separate module for just this one function though. It could just be put into Module:headword. —CodeCat 02:13, 26 August 2016 (UTC)[reply]
It makes it easier to test if it's here (we could use more testcases from other languages) DTLHS (talk) 02:16, 26 August 2016 (UTC)[reply]

Hebrew, Greek, and other considerations[edit]

There are several alphabetical characteristics that should be ignored per language:

  1. Hebrew final characters are considered the same as their initial and medial variants.
  2. Ancient Greek final sigma and diacritics are not considered.

Is there a good way to account for this? We can write per language palindrome conversion functions, but we'd have to put them somewhere. —JohnC5 02:40, 26 August 2016 (UTC)[reply]

I don't see what's wrong with putting them with the rest of the code. We will have to have a language parameter though. DTLHS (talk) 02:43, 26 August 2016 (UTC)[reply]
Or, make a data subpage with a conversion table for each language that needs special consideration. DTLHS (talk) 02:46, 26 August 2016 (UTC)[reply]
Do you mean to put them with the rest of the palindrome code, in the mod:languages, in separate modules (mod:grc-palindrome, mod:he-palindrome), or some other layout? —JohnC5 02:49, 26 August 2016 (UTC)[reply]
How about a specialized local function for each language or script that can do whatever it pleases to the text (in case a conversion table may not be sufficient)? —suzukaze (tc) 02:54, 26 August 2016 (UTC)[reply]
Similar to the translit_module field in the languages module? I'm just trying to zero in on the exact implementation. —JohnC5 03:00, 26 August 2016 (UTC)[reply]
It depends whether the rules can be described with a simple table like the entry_name parameter in the languages module. DTLHS (talk) 03:01, 26 August 2016 (UTC)[reply]
A table should work for Ancient Greek and Hebrew, as far as I can tell (indeed the dia_vowels and bare_vowels tables in Module:grc-accent would be correct if we added sigma logic). I can't speak to other languages though. —JohnC5 03:08, 26 August 2016 (UTC)[reply]
I made a data table in the module- if it gets too big we can move it to a separate data subpage. If you add the rules I will try to figure out how to make use of them. DTLHS (talk) 03:18, 26 August 2016 (UTC)[reply]
I've added some logic for Ancient Greek and Hebrew, though someone who knows more about Hebrew than I should test it. —JohnC5 04:46, 26 August 2016 (UTC)[reply]

English edge cases[edit]

Should these be considered palindromes: 4-6-6-4, 404, 4x4, B2B, d00d, R&R ? DTLHS (talk) 14:03, 27 August 2016 (UTC)[reply]

According to our definition of palindrome, yes. I'm not personally sure how worthwhile the ones with non-alphanumerics are, e.g. R&R. I also think it would be silly to include single characters (a, 1, etc.), because these are trivial and quite meaningless — akin to how (in some sense) any string is an anagram of itself. Equinox 14:06, 27 August 2016 (UTC)[reply]
I think I'm fine with these. I don't know what to say about R&R, since if we remove the ampersand, which might be considered punctuation, this would be considered a repeated letter. —JohnC5 16:28, 27 August 2016 (UTC)[reply]
The only strings containing ampersands that I can find referred to as palindromes in literature are ones that contain the ampersand in the same place when reading from either direction: "Lewd did I live & evil I did dwel", "Snug & raw was I ere I saw war & guns". This matches what I would expect: I wouldn't expect e.g. "foobar rab & oof" to be a palindrome. So, AFAICT ampersands are not punctuation (in this context) but letters like ψ. - -sche (discuss) 16:44, 27 August 2016 (UTC)[reply]