Commit baa295c5 authored by Siltaar's avatar Siltaar
Browse files

separation between month definitions generation and test ; tests in nodejs ;...

separation between month definitions generation and test ; tests in nodejs ; alternative implementation in Python ; update month definitions to 2019 -> needs more work
parent 48ad4b35
reimplementations/Python/__pycache__
reimplementations/ReasonML/_build
reimplementations/ReasonML/.merlin
......@@ -49,14 +49,17 @@ Another version, using `async`/`await` :
== Architecture
`month_nb.js` only contains a loop going through a JSON tree data structure
made of regular expression strings as keys (for the nodes), sub-objects as
branchs and numbers as leafs. The data structure itself resides in the
made of regular expression strings as keys (for the nodes), sub-objects for
branchs and numbers for leafs. The data structure itself resides in the
`month_nb.json` file.
This clear separation between code and data is wanted to ease the re-use of
`month_nb.json` data structure with other languages, to reimplement a
`month_nb` feature.
An experimental *Python implementation* is provided with currently only 49
working languages.
== Supported languages
......@@ -88,15 +91,15 @@ the tree).
To test `month_nb.js` against the language definition file, run :
```sh
$ cd test
$ phantomjs driver_test_month_nb.js
$ node --experimental-modules test_month_nb.mjs
```
The `phantomjs` command comes from the eponymous package on Debian.
The `node` v10.15.2 command comes from the `nodejs` package on Debian-based
distributions. The `node-fetch` and `node-requirejs` packages are also
required.
It will display various informations about the working languages and possible
errors. More information can be displayed changing the default value of
arguments of the `test()` function in the `test_month_nb.js` file.
errors.
== Who uses it ?
......@@ -110,16 +113,27 @@ arguments of the `test()` function in the `test_month_nb.js` file.
The Wiktionary snapshot page of
https://en.wiktionary.org/wiki/Appendix:Months_of_the_year[Appendix:Months_of_the_year]
used is from 2013-11-22. 14 languages have been added since, and `month_nb.js`
could be updated.
used is from 2019-09-18. 14 languages were added since the 2013 version of the initial release of `month_nb`.
==== Create new definitions
To update the `Appendix:Months_of_the_year` :
To update the definitions, download a new copy of `Appendix:Months_of_the_year` and run the `phantomjs_gen_def.js` script :
```sh
$ cd month_definitions
$ wget https://en.wiktionary.org/wiki/Appendix:Months_of_the_year
$ phantomjs phantomjs_gen_def.js <1>
```
<1> `phantomjs` is from the eponymous Debian package.
Then clean the `.json` file from error logging of phantomjs, and add the
"numeric" first line (copied from the previous `.json` definition file.
==== Run tests and update `month_nb.json` accordingly
Running the `test_month_nb.mjs` file will point out the months and langs that
are not working properly and that need to be fixed.
Then, running the `month_nb` tests shows a lot of work.
=== Node packaging
......
{
"English":["January","February","March","April","May","June","July","August","September","October","November","December"],
"Abkhaz":["ажьырныҳәа (āž̍ərnəḥwā)","жәабран (ž°ābrān)","хәажәкыр (xwāž°ḳər)","мшаҧы (mšāpə)","лаҵара (lāc̣ārā)","рашәара (rāš°ārā)","ҧхынгәы (pxəngwə)","нанҳәа (nānḥwā)","цәыббра (c°əbbrā)","жьҭаара (ž̍tāārā)","абҵара (ābc̣ārā)","ҧхынҷкәын (pxənč̣̍ḳwən)"],
"Afrikaans":["januarie","februarie","maart","april","mei","junie","julie","augustus","september","oktober","november","desember"],
"Amharic":["ጃንዩዌሪ(jañuwări)","ፌብሩወሪ(februwări)","ማርች(marč)","ኤፕረል(epräl)","መይ(mey)","ጁን(jun)","ጁላይ(julay)","ኦገስት(ogäst)","ሰፕቴምበር(septembär)","ኦክተውበር(oktäwbär)","ኖቬምበር(novembär)","ዲሴምበር(disembär)"],
"Arabic":["يناير(yanaayir)","فبراير(fibraayir)","مارس(maaris)","أبريل('abriil)","مايو(maayu)","يونيو(yúnyu)","يوليو(yúlyu)","أغسطس('aghúsTus)","سبتمبر(sibtímbir, sibtámbir, sabtámbar)","أكتوبر('uktuubar, 'aktóbar)","نوفمبر(nufímbir, nufámbir, nufámbar)","ديسمبر(disímbir, disámbir)"],
"Armenian":["հունվար (hunvar)","փետրվար (pʿetrvar)","մարտ (mart)","ապրիլ (april)","մայիս (mayis)","հունիս (hunis)","հուլիս (hulis)","օգոստոս (ōgostos))","սեպտեմբեր (september)","հոկտեմբեր (hoktember)","նոյեմբեր (noyember)","դեկտեմբեր (dektember)"],
"Belarusian":["студзень(stúdzen’)","люты(ljúty)","сакавiк(sakávik)","красавiк(krasávik)","травень(tráven’)","чэрвень(čérven’)","лiпень(lípen’)","жнiвень(žníven’)","верасень(vérasen’)","кастрычнiк(kastrýčnik)","лiстапад(listapád)","снежань(snéžan’)"],
"Bengali":["জানুয়ারিJanuari","ফেব্রুয়ারিFebruari","মার্চMarch","এপ্রিলEpril","মেMe","জুনJun","জুলাইJulai","আগস্ট, অগাস্টAgost, Ôgast","সেপ্টেম্বরSeptembor","অক্টবরÔktobor","নভেম্বরNôbhembor","ডিসেম্বরDisembor"],
"Bosnian":["januar","februar","mart","april","maj","juni","juli","august, avgust","septembar","oktobar","novembar","decembar"],
"Bulgarian":["януари(januári)","февруари(fevruári)","март(mart)","април(apríl)","май(maj)","юни(júni)","юли(júli)","август(ávgust)","септември(septémvri)","октомври(októmvri)","ноември(noémvri)","декември(dekémvri)"],
"Burmese":["ဇန်နဝါရီ(zannăwari)","ဖေဖော်ဝါရီ(hpehpawwari)","မတ်(mat)","ဧပြီ(ebyi)","မေ(me)","ဇွန်(zun)","ဇူလိုင်(zulaing)","ဩဂုတ်(aw:gok)","စက်တင်ဘာ(settinba)","အောက်တိုဘာ(auktoba)","နိုဝင်ဘာ(nowinba)","ဒီဇင်ဘာ(dizinba)"],
"Chechen":["Дечкен-бутт (Diečkien-butt)","Чиллан-бутт (Čillan-butt)","Зазадоккху-бутт (Zazadokqu-butt)","Оханан-бутт (Oχanan-butt)","Стигалкъекъа-бутт (Stigalq̇ieq̇a-butt)","Мангалан-бутт (Mangalan-butt)","Товбецан-бутт (Towbiecan-butt)","Марсхьокху-бутт (Marsḥoqu-butt)","Гезгмашан-бутт (Giezgmašan-butt)","Гӏадужу-бутт (Ġadužu-butt)","Лахьанан-бутт (Laḥanan-butt)","Гӏуран-бутт (Ġuran-butt)"],
"Cherokee":["ᏚᏃᎸᏔᏂ(dunolvtani)","ᎧᎦᎵ(kagali)","ᎤᏄᎳᎯ(unulahi)","ᏥᎶᏂ(tsiloni)","ᎠᏅᎢᏍᎬᏘ(anvisgvti)","ᏓᏣᎷᏂ(datsaluni)","ᎫᏰᏉᏂ(guyequoni)","ᎦᎶᏂ(galoni)","ᏚᎵᏍᏗ(dulisdi)","ᏚᏂᏅᏗ(duninvdi)","ᏄᏓᏕᏆ(nudadequa)","ᎥᏍᎩᎦ(vsgiga)"],
"Chinese":["一月(yīyuè)","二月(éryuè)","三月(sānyuè)","四月(sìyuè)","五月(wǔyuè)","六月(liùyuè)","七月(qīyuè)","八月(bāyuè)","九月(jiǔyuè)","十月(shíyuè","十一月(shíyīyuè)","十二月(shí'èryuè)"],
"Crimean Tatar":["yanvar","fevral","mart","aprel","mayıs","iyun","iyul","avgustos","sentâbr","oktâbr","noyabr","dekabr"],
"Croatian":["siječanj","veljača","ožujak","travanj","svibanj","lipanj","srpanj","kolovoz","rujan","listopad","studeni","prosinac"],
"Czech":["leden","únor","březen","duben","květen","červen","červenec","srpen","září","říjen","listopad","prosinec"],
"Danish":["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"],
"Dutch":["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],
"Esperanto":["januaro","februaro","marto","aprilo","majo","junio","julio","aŭgusto","septembro","oktobro","novembro","decembro"],
"Estonian":["jaanuar","veebruar","märts","aprill","mai","juuni","juuli","august","september","oktoober","november","detsember"],
"Faroese":["januar","februar","mars","apríl","mai","juni","juli","august","september","oktober","november","desember"],
"Finnish":["tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kesäkuu","heinäkuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu"],
"French":["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],
"Galician":["xaneiro","febreiro","marzo","abril","maio","xuño","xullo","agosto","setembro","outubro","novembro","decembro"],
"Georgian":["იანვარი(ianuari)","თებერვალი(t'ebervali)","მარტი(marti)","აპრილი(aprili)","მაისი(maisi)","ივნისი(ivnisi)","ივლისი(ivlisi)","აგვისტო(agvisto)","სექტემბერი(sek'temberi)","ოქტომბერი(ok'tomberi)","ნოემბერი(noemberi)","დეკემბერი(dekemberi)"],
"German":["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
"Greek":["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"],
"Haitian Creole":["janvye","fevriye","mas","avril","me","jen","jiyè","out","septanm","oktòb","novanm","desanm"],
"Hawaiian":["Ianuali","Pepeluali","Malaki","ʻApelila","Mei","Iune","Iulai","ʻAukake","Kepakemapa","ʻOkakopa","Nowemapa","Kēkēmapa"],
"Hebrew":["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"],
"Hindi":["जनवरी(janvarī)","फरवरी(pharvarī)","मार्च(mārc)","अप्रैल(aprail)","मई(ma'ī)","जून(jūn)","जुलाई(julā'ī)","अगस्त(agast)","सितंबर(sitambar)","अक्टूबर(akṭūbar)","नवंबर(navambar)","दिसंबर(disambar)"],
"Hungarian":["január","február","március","április","május","június","július","augusztus","szeptember","október","november","december"],
"Icelandic":["janúar,janúarmánuður(confer þorri)","febrúar,febrúarmánuður(confer góa)","mars,marsmánuður(confer einmánuður)","apríl,aprílmánuður(confer harpa)","maí,maímánuður(confer skerpla)","júní,júnímánuður(confer sólmánuður)","júlí,júlímánuður(confer heyannir)","ágúst,ágústmánuður(confer tvímánuður)","september,septembermánuður(confer haustmánuður)","október,októbermánuður(confer gormánuður)","nóvember,nóvembermánuður(confer ýlir)","desember,desembermánuður(confer mörsugur)"],
"Indonesian":["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"],
"Irish":["Eanáir","Feabhra","Márta","Aibreán","Bealtaine","Meitheamh","Iúil","Lúnasa","Meán Fómhair","Deireadh Fómhair","Samhain","Mí na Nollag"],
"Italian":["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],
"Japanese":["一月(ichigatsu)","二月(nigatsu)","三月(sangatsu)","四月(shigatsu)","五月(gogatsu)","六月(rokugatsu)","七月(shichigatsu)","八月(hachigatsu)","九月(kugatsu)","十月(jūgatsu)","十一月(jūichigatsu)","十二月(jūnigatsu)"],
"Khmer":["មករា(meykgărā)","កុម្ភៈ(gŭmpeyă)","មីនា(mīnīă)","មេសា(meysā)","ឧសភា(ŭsăpīă)","មិថុនា(mitonā)","កក្កដា(gukgădā)","សីហា(seyhā)","កញ្ញា(kăññā)","តុលា(dtolā)","វិច្ឆិកា(weuchăgā)","ធ្នូ(tnū)"],
"Korean":["일월(il-weol)","이월(i-weol)","삼월(sam-weol)","사월(sa-weol)","오월(o-weol)","유월(yu-weol)","칠월(chil-weol)","팔월(pal-weol)","구월(gu-weol)","시월(si-weol)","십일월(sip-il-weol)","십이월(sip-i-weol)"],
"Latin":["ມັງກອນ(mang kǭn)","ກຸມພາ(kum phā)","ມີນາ(mī nā)","ເມສາ(mē sā)","ພຶດສະພາ(phưt sa phā)","ມີຖຸນາ(mī thu nā)","iūlius, quintīlis","augustus, sextīlis","september","octōber","november","december"],
"Lao":["iānuārius","februārius","mārtius","aprīlis","māius","iūnius","ກໍລະກົດ(kǭ la kot)","ສິງຫາ(sing hā)","ກັນຍາ(kan nyā)","ຕຸລາ(tu lā)","ພະຈິກ(pha chik)","ທັນວາ(than va)"],
"Latvian":["janvāris","februāris","marts","aprīlis","maijs","jūnijs","jūlijs","augusts","septembris","oktobris","novembris","decembris"],
"Lezgi":["гьер(her)","эхем(ėḫem)","ибне(ibne)","нава(nava)","тӏул(ṭul)","къамуг(q̄amug)","чиле(čile)","пахун(paḫun)","мара(mara)","баскӏум(basḳum)","цӏехуьл(c̣eḫül)","фандукӏ(fanduḳ)"],
"Luxembourgish":["Januar","Februar","Mäerz","Abrëll","Mee","Juni","Juli","August","September","Oktober","November","Dezember"],
"Macedonian":["јануари(januári)","февруари(fevruári)","март(mart)","април(ápril)","мај(maj)","јуни(júni)","јули(júli)","август(ávgust)","септември(septémvri)","октомври(októmvri)","ноември(noémvri)","декември(dekémvri)"],
"Malay":["Januariجانواري","Februariفيبرواري","Macمچ","Aprilاڤريل","Meiمي","Junجون","Julaiجولاي","Ogosاوݢوس","Septemberسيڤتيمبر","Oktoberاوکتوبر","Novemberنوۏيمبر","Disemberديسيمبر"],
"Malayalam":["ജനുവരി(januvari)","ഫെബ്രുവരി(pʰebruvari)","മാര്ച്ച്(mārčč)","ഏപ്രില്(ēpril)","മേയ്(mēy)","ജൂണ്(jūṇ)","ജൂലൈ(jūlai)","ആഗസ്റ്റ്(āgasṟṟ)","സെപ്റ്റംബര്(sepṟṟaṁbar)","ഒക്ടോബര്(okṭōbar)","നവംബര്(navaṁbar)","ഡിസംബര്(ḍisaṁbar)"],
"Navajo":["Yas Niłtʼees","Atsá Biyáázh","Wóózhchʼį́į́d","Tʼą́ą́chil","Tʼą́ą́tsoh","Yaʼiishjááshchilí","Yaʼiishjáástsoh","Biniʼantʼą́ą́tsʼózí","Biniʼantʼą́ą́tsoh","Ghąąjįʼ","Níłchʼitsʼósí","Níłchʼitsoh"],
"Norwegian (Bokmål and Nynorsk)":["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],
"Ojibwe":["gichi-manidoo-giizis","namebini-giizis","onaabani-giizis","iskigamizige-giizis","zaagibagaa-giizis","ode'imini-giizis","aabita-niibino-giizis","manoominike-giizis","waatebagaa-giizis","binaakwe-giizis","gashkadino-giizis","manidoo-giizisoons"],
"Old English":["se æfterra ġēola","solmōnaþ","hreþmōnaþ","ēastermōnaþ","þrimilce","se ǣrra līþa","se æfterra līþa","wēodmōnaþ","hærfestmōnaþ","winterfylleþ","blōtmōnaþ","se ǣrra ġēola"],
"Old High German":["hartimānōd","hornung","lenzinmānōd","ōstarmānōd","drīmilki, winnimānōd","brāhmānōd","hewimānōd, houmānōd","aranmānōd","witumānōd, herbistmānōd","windumemānōd","wintarmānōd",""],
"Old Norse":["morsugr or jól (first half of the month) and þorri (latter half)","þorri and gói; kyndilsmessa","gói and einmánuðr","einmánuðr","","sólmánuðr","sólmánuðr and heyannir","heyannir and tvímánuðr","tvímánuðr and haustmánuðr","haustmánuðr and gormánuðr","gormánuðr and frermánuðr","frermánuðr and morsugr or jól"],
"Old Prussian":["Janwārs / Rags","Februārs / Wassarins","Mārts / Pūlis","Aprīls / Sakkis","Maījs / Zallaws","Jūnijs / Sīmenis","Jūlijs / Līpa","August / Daggis","Septēmberis / Sillin","Uktōberijs / Spallins","Nuwēmberis / Lapkrūtis","Decēmberis / Sallaws"],
"Polish":["styczeń","luty","marzec","kwiecień","maj","czerwiec","lipiec","sierpień","wrzesień","październik","listopad","grudzień"],
"Portuguese":["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],
"Romanian":["ianuarie","februarie","martie","aprilie","mai","iunie","iulie","august","septembrie","octombrie","noiembrie","decembrie"],
"Russian":["январь(janvár’)","февраль(fevrál’)","март(mart)","апрель(aprél’)","май(maj)","июнь(ijún’)","июль(ijúl’)","август(ávgust)","сентябрь(sentjábr’)","октябрь(oktjábr’)","ноябрь(nojábr’)","декабрь(dekábr’)"],
"Serbian":["јануар, januar","фебруар, februar","март, mart","април, april","мај, maj","јун, jun; јуни, juni","јул, jul; јули, juli","август, avgust","септембар, septembar","октобар, oktobar","новембар, novembar","децембар, decembar"],
"Sinhalese":["ජනවාරි (janavāri)(janavāri)","පෙබරවාරි (pabaravāri)(pebaravāri)","මාර්‍තු (mār‍tu)(mārtu)","අප්‍රේල් (ap‍rēl)(aprēl)","මැයි (mæyi)(mæyi)","ජූනි (jūni)(jūni)","ජූලි (jūli)(jūli)","අගෝස්‍තු (agōs‍tu)(agōstu)","සැප්‍තැම්‍බර් (sæp‍tæm‍bar)(sæptæmbar)","ඔක්‍තෝබර් (ok‍tōbar)(oktōbar)","නොවැම්‍බර් (novæm‍bar)(novæmbar)","දෙසැම්‍බර් (dasæm‍bar)(desæmbar)"],
"Slovak":["január","február","marec","apríl","máj","jún","júl","august","september","október","november","december"],
"Slovenian":["prosinec","svečan","sušec","mali traven","veliki traven","rožnik","mali srpan","veliki srpan","kimovec","vinotok","listopad","gruden"],
"Spanish":["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],
"Swahili":["Januari","Februari","Machi","Aprili","Mei","Juni","Julai","Agosti","Septemba","Oktoba","Novemba","Desemba"],
"Swedish":["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"],
"Tagalog":["Enero","Pebrero","Marso","Abril","Mayo","Hunyo","Hulyo","Agosto","Setyembre","Oktubre","Nobyembre","Disyembre"],
"Tamil":["ஜனவரி","பெப்ரவரி","மார்ச்","ஏப்ரல்","மே","ஜூன்","ஜூலை","ஆகஸ்ட்","செப்டம்பர்","அக்டோபர்","நவம்பர்","டிசம்பர்"],
"Tatar":["ğínwar,гыйнвар","febräl,февраль","mart,март","äpril,апрель","may,май","yün,июнь","yül,июль","august,август","sentäber,сентябрь","öktäber,октябрь","nöyäber,ноябрь","dekäber,декабрь"],
"Telugu":["జనవరి(janavari)","ఫిబ్రవరి(fibravari)","మార్చి(maarchi)","ఏప్రిల్(aepril)","మే(mae)","జూన్(joon)","జూలై(joolai)","ఆగష్టు(aagashTu)","సెప్టెంబర్(sepTembar)","అక్టోబర్(akTObar)","నవంబర్(navambar)","డిసెంబర్(Disembar)"],
"Thai":["มกราคม(mókgàraakom)","กุมภาพันธ์(gumpaapan)","มีนาคม(minakom)","เมษายน(mays săayon)","พฤษภาคม(prêutsàpaakom)","มิถุนายน(mítùnaayon)","กรกฎาคม(gàrágàdaakom)","สิงหาคม(sĭnghăakom)","กันยายน(ganyaayon)","ตุลาคม(tùlaakom)","พฤศจิกายน(prêutsàjìkgaayon)","ธันวาคม(tanwaakom)"],
"Tibetan":["ཟླ་དང་པོ།(zla.daṅ.po)","ཟླ་གཉིས་པ།(zla.gñis.pa)","ཟླ་གསུམ་པ།(zla.gsum.pa)","ཟླ་བཞི་པ།(zla.bži.pa)","ཟླ་ལྔ་པ།(zla.lṅa.pa)","ཟླ་དྲུག་པ།(zla.drug.pa)","ཟླ་བདུན་པ།(zla.bdun.pa)","ཟླ་བརྒྱད་པ།(zla.brgyad.pa)","ཟླ་དགུ་པ།(zla.dgu.pa)","ཟླ་བཅུ་པ།(zla.bču.pa)","ཟླ་བཅུ་གཅིག་པ།(zla.bču.gčig.pa)","ཟླ་བཅུ་གཉིས་པ།(zla.bču.gñis.pa)"],
"Turkish":["ocak","şubat","mart","nisan","mayıs","haziran","temmuz","ağustos","eylül","ekim","kasım","aralık"],
"Ukrainian":["січень(síčen’)","лютий(ljútyj)","березень(bérezen’)","квітень(kvíten’)","травень(tráven’)","червень(čérven’)","липень(lýpen’)","серпень(sérpen’)","вересень(véresen’)","жовтень(žóvten’)","листопад(lystopád)","грудень(hrúden’)"],
"Vietnamese":["tháng mộttháng 1","tháng haitháng 2","tháng batháng 3","tháng tưtháng 4","tháng nămtháng 5","tháng sáutháng 6","tháng bảytháng 7","tháng támtháng 8","tháng chíntháng 9","tháng mườitháng 10","tháng mười mộttháng 11","tháng mười haitháng 12"],
"Võro":["vahtsõaastakuu","radokuu","urbõkuu","mahlakuu","lehekuu","piimäkuu","hainakuu","põimukuu","süküskuu","rehekuu","märtekuu","joulukuu"],
"Walloon":["djanvî","fevrî","måss","avri","may","djun","djulete","awousse","setimbe","octôbe","nôvimbe","decimbe"],
"Welsh":["Ionawr","Chwefror","Mawrth","Ebrill","Mai","Mehefin","Gorffennaf","Awst","Medi","Hydref","Tachwedd","Rhagfyr"],
"West Frisian":["jannewaris","febrewaris","maart","april","maaie","juny","july","augustus","septimber","oktober","novimber","desimber"],
"Yiddish":["יאנואר","פעברואר","מארץ","אפריל","מײַ","יוני","יולי","אויגוסט","סעפטעמבער","אקטאבער","נאוועמבער","דעצעמבער"],
"Yup'ik":["Kanruyauciq","Kep'nerciq","Tengmiirviguaq","Tengmiirvik","Qusiirvik","Kaugun","Ingun","Amirairun","Amiraayaaq","Nulirun","Cauyarvik","Uivik"]
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
var tbx = document.querySelectorAll ('#mw-content-text tr')
var mns = [], lgs = []
var cur_mns
for (let i = tbx.length; i--; ) {
// console.log (tbx[i].querySelector ('td').textContent)
mns.push ([])
cur_mns = tbx[i].querySelectorAll ('td')
lgs.push (cur_mns[0].textContent.replace(/\n/g, ''))
for (let j = cur_mns.length; j--; ) {
if (j != 0) mns[mns.length-1].unshift (cur_mns[j])
}
// console.log (lgs[lgs.length-1] + ' ' + mns[mns.length-1].length)
}
// console.log(`parsed langs : ${lgs.length/2}`)
for (let i = mns.length / 2; i--; )
for (let j = mns[i].length; j--; )
mns[i].unshift (mns [i + mns.length / 2][j])
var cur_mn_name, cur_lg_str
var lg_count = mns.length / 2
console.log('{')
for (let i = lg_count; i--; ) {
cur_lg_str = `"${lgs[i]}":[`
for (var j = 0; j < mns[i].length; j++) {
cur_mn_name = mns[i][j].textContent.replace(/\n/g, '')
cur_mn_name = cur_mn_name.replace (/\(bulan\) /, '')
cur_lg_str += `"${cur_mn_name}"`
if (j < 11)
cur_lg_str += ','
}
cur_lg_str += ']'
if (i > 0)
cur_lg_str += ','
console.log(cur_lg_str)
}
console.log('}')
console.log (new Date ().toLocaleString () + ' Starting');
var page = require('webpage').create();
var fs = require ('fs');
/* globals require, phantom */
// console.log (new Date ().toLocaleString () + ' Starting')
var page = require('webpage').create()
var fs = require ('fs')
page.settings.loadImages = false;
page.settings.webSecurityEnabled = false;
page.onConsoleMessage = function (msg) {
console.log (new Date ().toLocaleString () + ' ' + msg);
};
// page.onConsoleMessage = function(msg) { console.log (u_idx + ' ' + timestamp () + ' ' + msg + ' (nested)'); };
//page.onLoadFinished = function () { console.log (timestamp() + ' load finished '+page.url) };
//page.onUrlChanged = function () { console.log (timestamp () + ' URL Changed '+page.url) };
page.settings.loadImages = false
page.settings.webSecurityEnabled = false
page.onConsoleMessage = function (msg) { console.log (msg) }
//page.onLoadFinished = function () { console.log (timestamp() + ' load finished '+page.url) }
//page.onUrlChanged = function () { console.log (timestamp () + ' URL Changed '+page.url) }
//page.onNavigationRequested = function(url, type, willNavigate, main) { };*/
//page.onResourceReceived = function(response) { };*/
page.onError = function(msg, trace) { // return;
var msgStack = [new Date ().toLocaleString () + ' ERROR: ' + msg];
page.onError = function(msg, trace) { // return
var msgStack = [new Date ().toLocaleString () + ' ERROR: ' + msg]
if (trace && trace.length) {
msgStack.push('TRACE:');
msgStack.push('TRACE:')
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' +
t.function + '")' : ''));
});
t.function + '")' : ''))
})
}
console.error (msgStack.join('\n'));
page.onCallback = null;
// ends ('page.onError', u_idx, page);
};
console.error (msgStack.join('\n'))
page.onCallback = null
// ends ('page.onError', u_idx, page)
}
// Appendix:Months_of_the_Year
var the_page_content = fs.read ('Appendix:Months_of_the_year');
page.setContent(the_page_content, 'Testing month_nb against Appendix:Months_of_the_year');
page.injectJs('../month_nb.js');
const _json = fs.read('../month_nb.json');
var _test = fs.read ('test_month_nb.js');
_test = _test.replace("'month_nb_json_obj_replace_token';",
`const month_nb_json = JSON.parse('${_json.replace(/[\n\r]/g, "")}');`);
page.evaluateJavaScript (_test);
phantom.exit ();
var the_page_content = fs.read ('Appendix:Months_of_the_year')
page.setContent(the_page_content, 'Generating JSON definitions of month numbers')
page.injectJs('in_browser_gen_def.js')
phantom.exit ()
......@@ -3,51 +3,55 @@
// Author: Simon 'Siltaar' Descarpentries ; siltaar § acoeuro ' com
// Version: 4
// Licence: GPLv3
function month_nb (a, json_obj, check_keys=false) {
json_obj = json_obj ? json_obj : month_nb_json;
var keys = [Object.keys(json_obj)];
var objs = [json_obj];
var o_ks = keys[keys.length-1];
var o = objs[objs.length-1];
var r_range = '';
/* globals month_nb_json */
var month_nb = function (a, json_obj, check_keys=false) {
json_obj = json_obj ? json_obj : month_nb_json
var keys = [Object.keys(json_obj)]
var objs = [json_obj]
var o_ks = keys[keys.length-1]
var o = objs[objs.length-1]
var r_range = ''
while(o_ks.length) {
let k = o_ks.shift();
if (k == "comment") continue;
// console.log(a +' '+ k);
let k = o_ks.shift()
if (k == "comment") continue
// console.log(a +' '+ k)
if (check_keys) { // show chars out of lang range in keys
if (keys.length == 1) {
str_r_range = `${k.slice(1,k.length-1)}|[\\$\\.\\?\\^\\(\\)\\|\\[\\] ])`;
r_range = new RegExp(str_r_range, 'gi');
var str_r_range = `${k.slice(1,k.length-1)}|[\\$\\.\\?\\^\\(\\)\\|\\[\\] ])`
r_range = new RegExp(str_r_range, 'gi')
} else if (keys.length > 1) {
char_to_remove = k.replace(r_range, '');
var char_to_remove = k.replace(r_range, '')
if (char_to_remove.length > 1) {
console.log(str_r_range);
console.log(`You should remove ${char_to_remove} from ${k}`);
console.log(str_r_range)
console.log(`You should remove ${char_to_remove} from ${k}`)
}
}
}
let r = new RegExp(k, 'i');
let r = new RegExp(k, 'i')
if (r.test(a)) {
o = o[k];
o = o[k]
if (typeof(o) === 'number') {
return o;
return o
} else if (typeof(o) === 'object') {
objs.push(o);
o_ks = Object.keys(o);
keys.push(o_ks);
objs.push(o)
o_ks = Object.keys(o)
keys.push(o_ks)
} else {
throw 'The JSON language-regexp-tree structure should only contain string '+
'keys as nodes, sub-objects as branchs and number leafs';
'keys as nodes, sub-objects as branchs and number leafs'
}
} else if (o_ks.length == 0) {
objs.pop(); // backtrack
o = objs[objs.length-1];
keys.pop(); // console.log(`depth level ${keys.length}`);
objs.pop() // backtrack
o = objs[objs.length-1]
keys.pop() // console.log(`depth level ${keys.length}`)
if (keys.length) {
o_ks = keys[keys.length-1]; // console.log(`keys to explore ${o_ks.length}`);
} else { // console.error(`Did not found for ${a}.`);
return undefined;
o_ks = keys[keys.length-1] // console.log(`keys to explore ${o_ks.length}`)
} else { // console.error(`Did not found for ${a}.`)
return undefined
}
} else {
continue
}
}
}
......@@ -13,7 +13,7 @@
"Languages from : https://en.wiktionary.org/wiki/Appendix:Months_of_the_Year",
"UTF8 ranges from : http://www.regular-expressions.info/unicode.html#block"
],
"^[1-9]+$": {
"^[0-9]+$": {
"^1": {
"^1$": 1,
"^10$": 10,
......
// Name: month_nb.js
// Desc: returns month number from given litteral case-insensitive name or abbreviation
// Author: Simon 'Siltaar' Descarpentries ; siltaar § acoeuro ' com
// Version: 4
// Licence: GPLv3
/* globals month_nb_json */
exports.month_nb = (a, json_obj, check_keys=false) => {
json_obj = json_obj ? json_obj : month_nb_json
var keys = [Object.keys(json_obj)]
var objs = [json_obj]
var o_ks = keys[keys.length-1]
var o = objs[objs.length-1]
var r_range = ''
while(o_ks.length) {
let k = o_ks.shift()
if (k == "comment") continue
// console.log(a +' '+ k)
if (check_keys) { // show chars out of lang range in keys
if (keys.length == 1) {
var str_r_range = `${k.slice(1,k.length-1)}|[\\$\\.\\?\\^\\(\\)\\|\\[\\] ])`
r_range = new RegExp(str_r_range, 'gi')
} else if (keys.length > 1) {
var char_to_remove = k.replace(r_range, '')
if (char_to_remove.length > 1) {
console.log(str_r_range)
console.log(`You should remove ${char_to_remove} from ${k}`)
}
}
}
let r = new RegExp(k, 'i')
if (r.test(a)) {
o = o[k]
if (typeof(o) === 'number') {
return o
} else if (typeof(o) === 'object') {
objs.push(o)
o_ks = Object.keys(o)
keys.push(o_ks)
} else {
throw 'The JSON language-regexp-tree structure should only contain string '+
'keys as nodes, sub-objects as branchs and number leafs'
}
} else if (o_ks.length == 0) {
objs.pop() // backtrack
o = objs[objs.length-1]
keys.pop() // console.log(`depth level ${keys.length}`)
if (keys.length) {
o_ks = keys[keys.length-1] // console.log(`keys to explore ${o_ks.length}`)
} else { // console.error(`Did not found for ${a}.`)
return undefined
}
} else {
continue
}
}
}
import json, re
# read file
with open('../../month_nb.json', 'r') as myfile:
data = myfile.read()
# parse file
global_json_obj = json.loads(data)
def month_nb(month_name, json_obj=None):
json_obj = json_obj if json_obj else global_json_obj
month_name = str(month_name) if type(month_name) is int else month_name
keys = list(json_obj.keys())
objs = [json_obj]
o_ks = keys
o = objs[-1]
k = ''
while type(o_ks) is list and len(o_ks):
k = o_ks.pop(0)
if k == "comment":
objs.pop(0)
continue
if re.match(k, month_name, re.IGNORECASE):
o = o[k]
if type(o) is int:
return o
elif type(o) is dict:
objs.append(o)
o_ks = list(o.keys())
keys.append(o_ks)
else:
raise Exception('The JSON language-regexp-tree structure should only contain '
'string keys as nodes, sub-objects as branchs and number leafs')
elif len(o_ks) == 0:
if len(objs) > 1:
objs.pop()
o = objs[-1]
keys.pop()
if len(keys):
o_ks = keys[-1]
else:
return None
else:
print(objs)
return None
else:
pass
import json
from month_nb import month_nb
# read file
with open('../../month_definitions/2019_definitions.json', 'r') as myfile:
data = myfile.read()
# parse file
month_definitions = json.loads(data)
month_index = 0
month_name = ''
broken_lang = ['Abkhaz', 'Bashkir', 'Buryat', 'Cherokee', 'Chuvash', 'Erzya', 'Hawaiian',
'Kalmyk', 'Lezgi', 'Moksha', 'Navajo', 'Ojibwe', 'Old English', 'Old High German',
'Old Norse', 'Tibetan', 'Udmurt', 'Uyghur', 'Veps', 'Vietnamese', 'Welsh', 'Yakut',
'Yiddish', 'Zazaki']
working_lang_nb = 0
for lang, month_names in month_definitions.items():
if lang in broken_lang:
continue
print(lang, ':', ' '.join([a[:3].rjust(3) for a in month_names]))
print(' '*(len(lang)+2), end='')
month_index = 0
month_value = 0
while(month_index < 12):
month_name = month_names[month_index]
month_value = month_index + 1
month_nb_res = month_nb(month_name)
if not month_nb_res == month_value:
print(f"{month_name} gave {month_nb_res} instead of {month_value}")
broken_lang.append(lang)
break
print(f'{month_nb_res: 3}', end=' ')
month_index += 1
else:
print('')
working_lang_nb += 1
print('Total :', len(broken_lang) + working_lang_nb, 'over 96')
print('Working lang. :', working_lang_nb)
print('Broken lang. :', len(broken_lang))
print(', '.join(broken_lang))
Not working.
To be continued…
(executable
(name month_nb)
(libraries yojson)
)
// Name: month_nb.js
// Desc: returns month number from given litteral case-insensitive name or abbreviation
// Author: Simon 'Siltaar' Descarpentries ; siltaar § acoeuro ' com
// Version: 3
// Licence: GPLv3
/*
const month_nb = function(a, check_keys=false) {
var keys = [Object.keys(month_nb_json)];
var objs = [month_nb_json];
var o_ks = keys[keys.length-1];
var o = objs[objs.length-1];
var r_range = '';
while(o_ks.length) {
let k = o_ks.shift();
// console.log(a +' '+ k);
if (check_keys) { // show chars out of lang range in keys
if (keys.length == 1) {
str_r_range = `${k.slice(1,k.length-1)}|[\\$\\.\\?\\^\\(\\)\\|\\[\\] ])`;
r_range = new RegExp(str_r_range, 'gi');
} else if (keys.length > 1) {
char_to_remove = k.replace(r_range, '');
if (char_to_remove.length > 1) {
console.log(str_r_range);
console.log(`You should remove ${char_to_remove} from ${k}`);
}
}
}
let r = new RegExp(k, 'i');
if (r.test(a)) {
o = o[k];
if (typeof(o) === 'number') {
return o;
} else if (typeof(o) === 'object') {
objs.push(o);
o_ks = Object.keys(o);
keys.push(o_ks);
} else {
throw 'The JSON language-regexp-tree structure should only contain string '+
'keys as nodes, sub-objects as branchs and number leafs';
}
} else if (o_ks.length == 0) {
objs.pop(); // backtrack
o = objs[objs.length-1];