Wiktionary tpiwiktionary https://tpi.wiktionary.org/wiki/Fran_Pes MediaWiki 1.39.0-wmf.22 case-sensitive Media Sipesol Toktok Yusa Toktok bilong yusa Wiktionary Wiktionary toktok Fail Toktok bilong fail MediaWiki Toktok bilong mediawiki Templet Toktok bilong templet Halivim Toktok bilong halivim Grup Toktok bilong grup TimedText TimedText talk Module Module talk Gadget Gadget talk Gadget definition Gadget definition talk wara 0 2612 13231 11403 2022-07-26T19:13:51Z Asinis632 1829 wikitext text/x-wiki {{-tpi-}} === Naun === {{tpi-naun}} '''wara''' * Tok Inglis: [[water]] * Tok Jeman: [[Wasser]] * Tok Kotava: [[lava]] * Tok Sebian: [[voda]] , [[вода]] ky8vt5w0h7xt6r8dr4xkrnp616yeluq животиња 0 3561 13222 10901 2022-07-26T18:59:35Z Asinis632 1829 wikitext text/x-wiki {{-sr-}} {{sr-naun}} # [[životinja]] {{sr-naslov|животиња|životinja|1|sr}} === Именица === {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} {{Значење| # {{значење преко синонима| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}}|облик=пун}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" />}} {{syn|sr| # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} 3g5x99tjuzq975q6pnseadw0sblz7oy 13223 13222 2022-07-26T19:00:45Z Asinis632 1829 wikitext text/x-wiki {{-sr-}} {{sr-naun}} # [[životinja]] {{sr-naslov|животиња|životinja|1|sr}} === Именица === {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" />}} {{syn|sr| # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} r3x5l6esha1sjua04oourmyh095tw1k 13224 13223 2022-07-26T19:01:31Z Asinis632 1829 wikitext text/x-wiki {{-sr-}} {{sr-naun}} # [[životinja]] {{sr-naslov|животиња|životinja|1|sr}} === Именица === {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" />}} # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} hlaf00zfg64i4l1hqus2fvsl95ycw44 13225 13224 2022-07-26T19:01:54Z Asinis632 1829 wikitext text/x-wiki {{-sr-}} {{sr-naun}} # [[životinja]] {{sr-naslov|животиња|životinja|1|sr}} === Именица === {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> # [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} ii5t5qzmsgb0x0p7kyit4ji4fjj6mmo 13226 13225 2022-07-26T19:02:41Z Asinis632 1829 wikitext text/x-wiki {{-sr-}} {{sr-naun}} # [[životinja]] {{sr-naslov|животиња|životinja|1|sr}} === Именица === {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} bwt6vwzbajcloa7hj6m1d1fzv0xbxkg 13228 13226 2022-07-26T19:05:00Z Asinis632 1829 wikitext text/x-wiki {{sr-naslov|животиња|životinja|1|sr}} {{sr-naun}} # [[životinja]] {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} kwpzpnlnfqjnyfgbluglo0p2k4qj3wj 13229 13228 2022-07-26T19:08:19Z Asinis632 1829 wikitext text/x-wiki {{sr-naslov|животиња|životinja|1|sr}} {{sr-naun}} # [[životinja]] # [[animal]] # [[abus]] [[https://www.tok-pisin.com/search-results.php?q=ANIMAL&select=english&Submit=go]] {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} m0go7n5ox722nee8nimxqn3xi5f3jj0 13230 13229 2022-07-26T19:12:38Z Asinis632 1829 wikitext text/x-wiki {{sr-naslov|животиња|životinja|1|sr}} {{sr-naun}} # [[životinja]] # [[animal]] # [[abus]] <ref>[tok-pisin.com[https://www.tok-pisin.com/search-results.php?q=ANIMAL&select=english&Submit=go]]</ref> {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} 6oeu92xqoa58d9esd6xjd43hahhh43t 13232 13230 2022-07-26T19:14:44Z Asinis632 1829 wikitext text/x-wiki {{sr-naslov|животиња|životinja|1|sr}} {{sr-naun}} # [[životinja]] # Tok Inglis:[[animal]] # Tok Pisin :[[abus]] <ref>[tok-pisin.com[https://www.tok-pisin.com/search-results.php?q=ANIMAL&select=english&Submit=go]]</ref> {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} k5725in0664i06y9c67q0qm7oe8bdxu 13233 13232 2022-07-26T19:17:15Z Asinis632 1829 wikitext text/x-wiki {{sr-naslov|животиња|životinja|1|sr}} {{sr-naun}} # [[životinja]] # Tok Inglis:[[animal]] <ref>[tokpisin [https://www.tokpisin.info/?s=animal]]</ref> # Tok Pisin :[[abus]] <ref>[tok-pisin.com[https://www.tok-pisin.com/search-results.php?q=ANIMAL&select=english&Submit=go]]</ref> {{српски-именица|род=ж}} {{Аудио|Sr-животиња.flac}} # [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] {{R:Recnik Sinonima}} # набусит, неотесан човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # лош, покварен и зао човек <ref name="П. Ћосић и сарадници, Речник синонима" /> # {{syn|sr| [[звер]], [[бестија]], [[бештија]], [[четвороножац]] [[суж.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[хајван]] [[фам.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[насилник]], [[неотесанац]], [[неотесанко]], [[напасник]], [[напрасник]], [[манијак]], [[простак]], [[дивљак]], [[сировина]], [[силеџија]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[живина]] [[фам.]], ''[[Викиречник:Жаргонске речи|жарг.]]'' [[силос]] [[жарг.]], ''[[Викиречник:Екпресивно|експр.]]'' [[звер]] [[експр.]], ''[[Викиречник:Ретке речи|рет.]]'' [[несуздржљивац]] [[рет.]] <ref name="П. Ћосић и сарадници, Речник синонима" /> #: [[мамлаз]], [[свиња]], [[морална наказа]], [[пакосник]], [[изрод]], [[покварењак]], [[антихрист]], [[брука]], [[гњида]], [[безвредник]], [[хипокрит]], [[крпа (од човека)]], [[злобник]], ''[[Викиречник:Народске речи|нар.]]'' [[пизда]] [[нар.]], [[бескичмењак]], [[гуја]], [[бедник]], ''[[Викиречник:Ретке речи|рет.]]'' [[одљуд]] [[рет.]], ''[[Викиречник:Фамилијарне речи|фам.]]'' [[гнус]] [[фам.]], [[поганчина]], [[бестидник]], ''[[Викиречник:Архаичне речи|арх.]]'' [[угурсуз]] [[арх.]], [[безочник]], [[перфидник]], [[нечовек]], [[морални имбецил]], [[смеће]], [[балабандер]], [[шугавац]] [[нар.]], [[притворица]], [[крмак]], [[подлац]], [[фарисеј]] [[арх.]], ''[[Викиречник:Регионализми|рег.]]'' [[претворица]] [[рег.]], [[љигавац]] [[фам.]], [[прасац]], [[бесрамник]], [[хахар]] [[арх.]], [[неваљалац]], [[мекушац]], [[неваљалко]], [[говно]] [[нар.]], [[сплеткарош]], [[ванцага]] [[арх.]], [[смрдљивац]] [[фам.]], [[проклетник]], [[шуфт]] [[рег.]], [[џукац]], [[живина]], [[битанга]], [[уштва]], [[стодлака]] [[рет.]], [[рђа]] [[нар.]], [[ђаво]], [[пробисвет]], [[препредењак]], [[смутљивац]], [[мутивода]], [[нечасник]], [[подмуклица]], [[галијот]] [[арх.]], [[гад]], [[безобразник]], [[злоћа]], [[неотесанац]], [[дрзник]], [[хуља]], [[фукара]] [[нар.]], [[курвин син]] [[нар.]], [[преварант]], [[стока]], [[непоштењак]], [[ђубре (од човека)]], [[љига]] [[фам.]], [[превртљивац]], [[муфљуз]], [[дркаџија]] [[нар.]], [[псето]], [[лицемер]], [[протува]], [[претворник]], [[дволичњак]], [[морална нула]], [[смрад]] [[фам.]], [[морално смеће]], [[двоструки играч]], [[џукела]], [[пичка]] [[нар.]], [[препреденко]], [[ништарија]], [[палаворда]] [[рег.]], [[ништавац]], [[мутикаша]], [[бараба]] <ref name="П. Ћосић и сарадници, Речник синонима" /> }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} 0q3xdhf4iatq9vrdirvcxommy9fcs5m dogovor 0 3574 13221 13211 2022-07-26T18:56:09Z Asinis632 1829 wikitext text/x-wiki {{-sr-}} {{sr-naun}} # [[договор]] == dogovor ([[Викиречник:Српски|српски]], [[Викиречник:Ћирилица|ћир.]] [[договор]]) == === Именица === {{српски-именица|род=м}} # заједничка одлука склопљен између више особа{{R:Recnik Sinonima}} # окупљање веће или мање групе људи ради неког договора {{R:Recnik Sinonima}} # {{syn|sr|pristanak|sklad|sporazum|sloga|kongruencija|slaganje|razumevanje|pogodba|harmoničnost|saglasnost|usaglašenost|usaglašavanje|harmonija|dopuštenje|saradnja|nagodba|složnost|red i mir|namirenje|skladnost|akrord| ''[[Викиречник:Фигуративне речи|фиг.]]'' [[pakt]] [[фиг.]], ''[[Викиречник:Ретке речи|рет.]]'' [[konkordat]] [[рет.]], [[ugodba]] [[рет.]], [[aranžman]] [[рет.]], [[antanta]] [[суж.]] <ref name="П. Ћосић и сарадници, Речник синонима" />}} #: {{syn|sr|[[okupljanje]], ''[[Викиречник:Регионализми|рег.]]'' [[londžanje]] [[рег.]], [[skup]], [[sastanak]], [[pretres]], ''[[Викиречник:Ретке речи|рет.]]'' [[adet]] [[рег.]] [[рет.]], [[rasprava]], [[sesija]], [[simpozijum]], [[debata]], [[dogovor]], [[skupština]], [[forum]], [[okup]] [[рет.]], [[kongres]], [[sabir]] [[рет.]], [[razgovor]], ''[[Викиречник:Формализми|форм.]]'' [[konvencija]] [[форм.]], [[usaglašavanje]], [[plenum]], [[konferencija]], [[većanje]], [[seminar]], [[diskusija]], ''[[Викиречник:Речи из хрватског стандарда|хрв.]]'' [[domjenak]] [[хрв.]], ''[[Викиречник:Архаичне речи|арх.]]'' [[veće]] [[арх.]], [[zbor]] [[арх.]], [[dogovaranje]], [[sednica]] }} == Референце == {{reflist}} == Напомене == {{reflist|group="н"}} euoo0w0b0tpkys1xoshtyemae6x2tvk Templet:ru-noun-table 10 5223 13215 2022-07-26T12:13:08Z Asinis632 1829 Created page with "<includeonly>{{#invoke:ru-noun|show}}</includeonly><noinclude>{{documentation}}</noinclude>" wikitext text/x-wiki <includeonly>{{#invoke:ru-noun|show}}</includeonly><noinclude>{{documentation}}</noinclude> jk8o3go7sise77glwo2hdt9739pylgj Module:ru-noun 828 5224 13216 2022-07-26T12:14:43Z Asinis632 1829 Created page with "--[=[ This module contains functions for creating inflection tables for Russian nouns. Author: Benwing, rewritten from early version by Wikitiki89 Form of arguments: One of the following: 1. LEMMA|DECL|PLSTEM (all arguments optional) 2. ACCENT|LEMMA|DECL|PLSTEM (all arguments optional) 3. multiple sets of arguments separated by the literal word "or" Arguments: ACCENT: Accent pattern (a b c d e f b' d' f' f''). Multiple values can be specified, separa..." Scribunto text/plain --[=[ This module contains functions for creating inflection tables for Russian nouns. Author: Benwing, rewritten from early version by Wikitiki89 Form of arguments: One of the following: 1. LEMMA|DECL|PLSTEM (all arguments optional) 2. ACCENT|LEMMA|DECL|PLSTEM (all arguments optional) 3. multiple sets of arguments separated by the literal word "or" Arguments: ACCENT: Accent pattern (a b c d e f b' d' f' f''). Multiple values can be specified, separated by commas. If omitted, defaults to a or b depending on the position of stress on the lemma or explicitly-specified declension. LEMMA: Lemma form (i.e. nom sg or nom pl), with appropriately-placed stress; or the stem, if an explicit declension is specified (in this case, the declension usually looks like an ending, and the stem is the portion of the lemma minus the ending). In the first argument set (i.e. first set of arguments separated by "or"), defaults to page name; in later sets, defaults to lemma of previous set. A plural form can be given, and causes argument n= to default to n=p (plural only). Normally, an accent is required if multisyllabic, and unaccented monosyllables with automatically be stressed; prefix with * to override both behaviors. DECL: Declension field. Normally omitted to autodetect based on the lemma form; see below. PLSTEM: special plural stem (defaults to stem of lemma) Additional named arguments: a: animacy (a/an/anim = animate, i/in/inan = inanimate, b/bi/both/ai = both (listing animate first in the headword), ia = both (listing inanimate first in the headword), otherwise inanimate) n: number restriction (p = plural only, s = singular only, b = both; defaults to both unless the lemma is plural, in which case it defaults to plural only) CASE_NUM or acc_NUM_ANIM or par/loc/voc: override (or multiple values separated by commas) for case/number combination; forms auto-linked; can have raw links in it, can have an ending "note" (*, +, 1, 2, 3, etc.) pltail: Specify something (usually a * or similar) to attach to the end of the last plural form when there's more than one. Used in conjunction with notes= to indicate that alternative plural forms are obsolete, poetic, etc. pltailall: Similar pltail= but attaches to all plural forms. Typically used in conjunction with notes= to make a comment about the plural as a whole (e.g. it's mostly hypothetical, rare and awkward, etc.). sgtail, sgtailall: Same as pltail=, pltailall= but for the singular. obltail, obltailall: Same as pltail=, pltailall= but for oblique cases (not the nominative or accusative). CASE_NUM_tail: Attach the argument to the end of the last form (whether there's one or more than one) for the particular case/number combination. Note that this doesn't work quite like pltail= or sgtail= in that it doesn't skip adding the argument when there's only one form. CASE_NUM_tailall: Attach the argument to the end of all forms specified for the particular case/number combination. Similar to pltailall= or sgtailall=. suffix: Add a suffix such as ся to all forms. prefix: Add a prefix to all forms. plhyp, plhypall, CASE_NUM_hyp, etc.: Same as pltail, pltailall, CASE_NUM_tal, etc. but specify that the marked forms are mostly hypothetical or rare/awkard. Generally you will want plhypall=y to mark the plural as hypothetical. Per word named arguments: All of the above named arguments have per-word variants, e.g. a1, a2, ...; n1, n2, ...; CASE_NUM1, CASE_NUM2, ...; pltail1, pltail2, ...; etc. These apply to the individual words of a form. Case abbreviations: nom: nominative gen: genitive dat: dative acc: accusative ins: instrumental pre: prepositional par: partitive loc: locative voc: vocative Number abbreviations: sg: singular pl: plural Animacy abbreviations: an: animate in: inanimate Declension field: One of the following for regular nouns: (blank) GENDER -VARIANT GENDER-VARIANT $ DECLTYPE DECLTYPE/DECLTYPE (also, can append various special-case markers to any of the above) Or one of the following for adjectival nouns: + +ь $ +short, +mixed or +proper +DECLTYPE GENDER if present is m, f, n or 3f; for regular nouns, required if the lemma ends in -ь or is plural, ignored otherwise. 3f is the same as f but in the case of a plural lemma in -и, detects a third-declension feminine with singular in -ь rather than a first-declension feminine with singular in -а or -я. VARIANT is one way of requesting variant declensions (see also special case (1) for variant nom pls, and special case (2) for variant gen pls). The currently allowed values are -ья (will select a mixed declension that has some normal declension in its singular and the -ья plural declension); -ин (for animate masculine nouns in -ин with plural in -е -- note that this is autodetected in the majority of cases where the ending in -янин or -анин); -ишко (used for inanimate neuter-form diminutive masculine nouns in -ишко [also сараю́шко] with nom pl -и and colloquial feminine-ending alternants in some singular cases); -ище (similar to -ишко but used for *animate* augmentative masculine neuter-form nouns in -ище). Variants -ишко and -ище must be given with with special case (1). $ is indeclinable words. It is principally useful in multiword expressions where some of the words are indeclinable. DECLTYPE is an explicit declension type. Normally you shouldn't use this, and should instead let the declension type be autodetected based on the ending, supplying the appropriate hint if needed (gender for regular nouns, +ь for adjectives). If provided, the declension type is usually the same as the ending, and if present, the lemma field should be just the stem, without the ending. Possibilities for regular nouns are (blank) or # for hard-consonant declension, а, я, о, е or ё, е́, й, ья, ье or ьё, ь-m, ь-f, ин, ёнок or онок or енок, ёночек or оночек or еночек, мя, -а or #-а, ь-я, й-я, о-и or о-ы, -ья or #-ья, $ (indeclinable). Old-style (pre-reform) declensions use ъ instead of (blank), ъ-а instead of -а, ъ-ья instead of -ья, and инъ, ёнокъ/онокъ/енокъ, ёночекъ/оночекъ/еночекъ instead of the same without terminating ъ. The declensions can also be written with an accent on them; this chooses the same declension (except for е vs. е́), but causes ACCENT to default to pattern b instead of a. For adjectival nouns, you should normally supply just + and let the ending determine the declension; supply +ь in the case of a possessive adjectival noun in -ий, which have an extra -ь- in most endings compared with normal adjectival nouns in -ий, but which can't be distinguished based on the nominative singular. You can also supply +short, +mixed or +proper, which constrains the declension appropriately but still autodetects the gender-specific and stress-specific variant. If you do supply a specific declension type, as with regular nouns you need to omit the ending from the lemma field and supply just the stem. Possibilities are +ый, +ое, +ая, +ій, +ее, +яя, +ой, +о́е, +а́я, +ьій, +ье, +ья, +-short or +#-short (masc), +о-short, +о-stressed-short or +о́-short, +а-short, +а-stressed-short or +а́-short, and similar for -mixed and -proper (except there aren't any stressed mixed declensions). DECLTYPE/DECLTYPE is used for nouns with one declension in the singular and a different one in the plural, for cases that PLVARIANT and special case (1) below don't cover. Special-case markers: (1) for Zaliznyak-style alternate nominative plural ending: -а or -я for masculine, -и or -ы for neuter (2) for Zaliznyak-style alternate genitive plural ending: -ъ/none for masculine, -ей for feminine, -ов(ъ) for neuter, -ей for plural variant -ья * for reducibles (nom sg or gen pl has an extra vowel before the final consonant as compared with the stem found in other cases) ;ё for Zaliznyak-style alternation between last е in stem and ё TODO: 1. Multi-word issues: -- FIXME: Make sure internal_notes handled correctly; we may run into issues with multiple internal notes from different words, if we're not careful to use different footnote symbols for each type of footnote (which we don't do currently). [NOT DONE, MAY NOT DO] -- Handling default lemma: With multiple words, we should probably split the page name on spaces and default each word in turn [NOT DONE, MAY NOT DO] 2a. FIXME: For -ишко diminutives and -ище augmentatives, should add an appropriate category of some sort (currently marked by colloqfem= in category). 2b. FIXME: Adding a note to dat_sg also adds it to loc_sg when it exists; seems wrong. See луг. 2c. FIXME: When you have both d' and f in feminines and you use sgtail=*, you get two *'s. See User:Benwing2/test-ru-noun-debug. 3. ADJECTIVE FIXMES: 3a. FIXME: Change calls to ru-adj11 to use the new proper name support in ru-adjective. 3b. FIXME: Test that omitting a manual form in ru-adjective leaves the form as a big dash. 3c. FIXME: какой-либо and какой-то display genitives with translit -go instead of -vo. To fix this properly requires implementing real manual translit for adjectives. 3d. FIXME: Implement real manual translit for adjectives. 5. [FIXME: Consider adding an indicator in the header line when the ё/e alternation occurs. This is a bit tricky to calculate: If special case ;ё is given, but also if ё occurs in the stem and the accent pattern is as follows -- for sg-only, b' d' f' f'', also b d f if the noun is masc or 3rd-decl fem (i.e. nom-sg ending is non-syllabic); for pl-only, e f f' f'', also b b' c if the gen pl is non-syllabic; for sg/pl, any but a or b, also b if either nom sg or gen pl is non-syllabic. But it gets more complicated due to overrides. An alternative is to check all forms to see if ё is present in some but not all; but this is tricky also because e.g. reducibles frequently have ё/null alternation, which doesn't count, and some endings have е or ё in them, which also doesn't count. If we were to do it this way, we'd have to (a) count the number of е's in the form(s) with ё and verify that there's at least one form without ё and with one more е than in the form(s) with ё (and it gets trickier if different forms with ё have different numbers of е in them, although that is probably rare); and (b) ignore the appropriate endings (the best way to do this would probably be to look at the actual suffixes that were generated in args.suffixes and chop off any matching ending in the actual form(s), but also chop off final -е/ё, as well as -ев(ъ)/-ёв(ъ)/-ей/-ёй in the gen pl, which is frequently overridden, unless perhaps the stem ends in the same way). It'd probably not possible to do this in a 100% foolproof way but can be "good enough" for nearly all circumstances.] [MIGHT BE TOO MUCH WORK] 6. HEADWORD FIXMES: 6a. FIXME: In ru-headword, create a category for words whose gender doesn't match the form. (This is easy to do for ru-noun+ but harder for ru-noun. We would need to do limited autodetection of the ending: for singulars, -а/я should be feminine, -е/о/ё should be neuter, -ь should be masculine or feminine, anything else should be masculine; for plurals, -и/ы should be masculine or feminine, -а/я should be neuter except that -ія can be feminine or neuter due to old-style adjectival pluralia tantum nouns, anything else can be any gender.) 6b. FIXME: Recognize indeclinable nouns and indicate as indeclinable. Probably should work by checking the case forms to see if they're the same. 9. FIXME: Change stress-pattern detection and overriding to happen inside of looping over the two parts of a slash decl. Requires that the loop over the two parts happen outside of the loop over stress patterns. Requires that the category code get split into two parts, one to handle combined singular/plural categories that goes outside the two loops, and one to handle everything else that goes inside the two loops. 10. FIXME: override_matches_suffix() had a free variable reference to ARGS in it, which should have triggered an error whenever there was a nom_sg or nom_pl override but didn't. Is there an error causing this never to be called? Check. 11a. FIXME: In a multiword lemma, using loc2=+ causes only the second word to get linked instead of the whole expression. Same for par2=+, voc2=+. 11b. FIXME: Using loc=+ with a multiword lemma should do the right thing, same as if locN=+ is specified for each individual word. Instead it generates the locative as a whole from the dative, which fails e.g. if some of the words are adjectival. Same for par=+, voc=+. 13. Multi-word issues: -- Setting n=pl when auto-detecting a plural lemma. How does that interact with multi-word stuff? (DONE) -- compute_heading() -- what to do with multiple words? I assume we should display info on the first noun (non-indeclinable, non-adjectival), and on the first adjectival word otherwise, and finally on an indeclinable word (DONE) -- args.genders -- it should presumably come from the same word as is used in compute_heading(); but we should allow the overall gender to be overridden, at least in ru-noun+ (DONE) -- Bug in args.suffix: Gets added to every word in attach_with() and then again at the end, after pltail and such. Needs to be added to the last word only, before pltail. Need also suffixN for individual words. (DONE, NEEDS TESTING) -- Should have ..N versions of pltail and variants. (DONE, NEEDS TESTING) -- Need to handle overrides of acc_sg, acc_pl (DONE) -- Overrides of nom_sg/nom_pl should also override acc_sg/acc_pl if it was originally empty and the animacy is inanimate; similarly for gen_sg/gen_pl and animates; this needs to work both for per-word and overall overrides. (DONE) -- do_generate_forms(_multi) need to run part of make_table(), enough to combine all per_word_info into single lists of forms and store back into args[case]. (DONE, NEEDS TESTING) -- In generate_forms, should probably check if a=="i" and only return acc_sg_in as acc_sg=; or if a=="a" and only return acc_sg_an as acc_sg=; in old/new comparison code, do something similar, also when a=="b" check if acc_sg_in==acc_sg_an and make it acc_sg; when a=="b" and the _in and _an variants are different, might need to ignore them or check that acc_sg_in==nom_sg and acc_sg_an==gen_sg; similarly for _pl (DONE, NEEDS TESTING) -- Need to test with multiple words! [DONE] -- Current handling of <adj> won't work properly with multiple words; will need to translate word-by-word in that case (should be solved by manual-translit branch) [DONE] 14. In multiple-words branch, fix ru-decl-noun-multi so it recognizes things like *, (1), (2) and ; without the need for a separator. Consider using semicolon as a separator, since we already use it to separate ё from a previous declension. Maybe use $ or ~ for an indeclinable word; don't use semicolon. [IMPLEMENTED. NEED TO TEST.] 16. [Consider having ru-noun+ treat par= as a second genitive in the headword, as is done with край] [WON'T DO] 17. [FIXME: Consider removing slash patterns and instead handling them by allowing additional declension flags 'sg' and 'pl'. This simplifies the various special cases caused by slash declensions. It would also be possible to remove the special plural stem, which would get rid of more special cases. On the other hand, it makes it more complicated to support plural variant -ья with all singular types, and the category code that displays things like "Russian nouns with singular -X and plural -Y" also gets more complicated, and there's something convenient and intuitive about plural stems, and slash declensions are also convenient and at least somewhat intuitive. One possibility is to externally allow slash declensions and special plural stems and rewrite them internally to separate stems with 'sg' and 'pl' declension flags; but there are still the two coding issues mentioned above.] 18. [FIXME: Consider redoing slash patterns so they operate at the outer level, i.e. things like special cases apply separately in the singular and plural part of the slash pattern.] 19. In ru-noun, don't recognize -а with m as plural unless (1) or n=pl is also given, because there are masculine words with the feminine ending. Check using the test code whether this changes anything. Also check if there are other similar cases (neuter with -и isn't parallel because -и is always plural). [IMPLEMENTED. NEED TO TEST.] 19a. Internal notes weren't propagated properly from adjectives. [IMPLEMENTED. NEED TO TEST.] 19b. Add support for -ишко and -ище variants (p. 74 of Z), which conversationally and/or colloquially have feminine endings in certain cases. [IMPLEMENTED. NEED TO TEST. MAKE SURE THE INTERNAL NOTES APPEAR.] 19d. For masculine animate neuter-form nouns, the accusative singular ends in -а (-я soft) instead of -о. [IMPLEMENTED. NEED TO TEST. NOTE: Currently this variant only can be selected using new-style arguments where the gender can be given. Perhaps we should consider allowing gender to be specified with old-style explicit declensions.] 21. Put back gender hints for pl adjectival nouns; used by ru-noun+. [IMPLEMENTED. NEED TO TEST.] 23. Mixed and proper-noun adjectives have built-in notes. We need to handle those notes with an "internal_notes" section similar to what is used in the adjective module. [IMPLEMENTED. NEED TO TEST.] 24. Adjective detection code here needs to work the same as for the adjective module, in particular in the handling of short, stressed-short, mixed, proper, stressed-proper. [IMPLEMENTED. NEED TO TEST.] 25. Consider simplifying plural-variant code to only allow -ья as a plural variant [and maybe even change that to be something like (1')]. [IMPLEMENTED REDUCTION OF PLURAL VARIANTS TO -ья; PLURAL-VARIANT CODE STILL COMPLEX, THOUGH. NEED TO TEST.] 26. Automatically superscript *, numbers and similar things at the beginning of a note. Also do this in adjective module. [IMPLEMENTED. NEED TO TEST.] 28. Make the check for multiple stress patterns (categorizing/tracking) smarter, to keep a list of them and check at the end, so we handle multiple stress patterns specified through different arg sets. [IMPLEMENTED; NEED TO TEST.] 29. More sophisticated handling of user-requested plural variant vs. special case (1) vs. plural-detected variant. [IMPLEMENTED. NEED TO TEST FURTHER.] 30. Solution to ambiguous plural involving gender spec "3f". [IMPLEMENTED; NEED TO TEST. Use запчасти, новости.] 33. With pluralia tantum adjectival nouns, we don't know the gender. By default we assume masculine (or feminine for old-style -ія nouns) and currently this goes into the category, but shouldn't. [IMPLEMENTED.] 39. [Eventually: Even with decl type explicitly given, the full stem with ending should be included.] [MAY NEVER IMPLEMENT] 40. [Get error "Unable to dereduce" with strange noun ва́йя, what should happen?] [WILL NOT FIX; USE AN OVERRIDE] 41. In творог, module generates partitive творогу́ when it should copy the dative творогу́,тво́рогу. (DONE) 42. [[груз 200]] doesn't work. Interprets 200 as a footnote symbol. 43. When converting е -> ё not after cons and with translit, we should convert e -> o to avoid double j. (DONE) 44. FIXME: In ро́вня/ровня́, similarly with неровня, marks genitive plural ровня́ as irregular even though it isn't. (NOT OUR ERROR; THE DECLENSIONS OF THESE NOUNS MARKED THE ENDING-STRESSED VARIANTS WITH (2).) ]=]-- local m_utilities = require("Module:utilities") local m_table = require("Module:table") local m_links = require("Module:links") local com = require("Module:ru-common") local nom = require("Module:ru-nominal") local m_ru_adj = require("Module:ru-adjective") local m_ru_translit = require("Module:ru-translit") local strutils = require("Module:string utilities") local scriptutils = require("Module:script utilities") local m_table_tools = require("Module:table tools") local m_debug = require("Module:debug") local export = {} local lang = require("Module:languages").getByCode("ru") local Latn = require("Module:scripts").getByCode("Latn") local u = mw.ustring.char local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local rmatch = mw.ustring.match local rsplit = mw.text.split local ulower = mw.ustring.lower local usub = mw.ustring.sub local ulen = mw.ustring.len -- If enabled, compare this module with new version of module to make -- sure all declensions are the same. Eventually consider removing this; -- but useful as new code is created. local test_new_ru_noun_module = false local AC = u(0x0301) -- acute = ́ local CFLEX = u(0x0302) -- circumflex = ̂ local PSEUDOCONS = u(0xFFF2) -- pseudoconsonant placeholder, matching ru-common local IRREGMARKER = "△" local HYPMARKER = "⟐" local paucal_marker = "*" local paucal_internal_note = "* Used with the numbers 1.5, 2, 3, 4 and higher numbers after 20 ending in 2, 3, and 4." -- text class to check lowercase arg against to see if Latin text embedded in it local latin_text_class = "[a-zščžěáéíóúýàèìòùỳâêîôûŷạẹịọụỵȧėȯẏ]" -- Forward functions local generate_forms_1 local determine_decl local handle_forms_and_overrides local handle_overall_forms_and_overrides local concat_word_forms local make_table local detect_adj_type local detect_stress_pattern local override_stress_pattern local determine_stress_variant local determine_stem_variant local is_reducible local is_dereducible local add_bare_suffix local attach_stressed local do_stress_pattern local canonicalize_override -- version of rsubn() that discards all but the first return value local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end -- version of rsubn() that returns a 2nd argument boolean indicating whether -- a substitution was made. local function rsubb(term, foo, bar) local retval, nsubs = rsubn(term, foo, bar) return retval, nsubs > 0 end -- version of rfind() that lowercases its string first, for case-insensitive matching local function rlfind(term, foo) return rfind(ulower(term), foo) end local function track(page) m_debug.track("ru-noun/" .. page) return true end -- version of m_table.insertIfNot() that makes sure 'false' doesn't get inserted by mistake, and uses deep comparison. local function insert_if_not(foo, bar) assert(bar ~= false) m_table.insertIfNot(foo, bar, nil, "deep compare") end -- Fancy version of ine() (if-not-empty). Converts empty string to nil, -- but also strips leading/trailing space and then single or double quotes, -- to allow for embedded spaces. local function ine(arg) if not arg then return nil end arg = rsub(arg, "^%s*(.-)%s*$", "%1") if arg == "" then return nil end local inside_quotes = rmatch(arg, '^"(.*)"$') if inside_quotes then return inside_quotes end inside_quotes = rmatch(arg, "^'(.*)'$") if inside_quotes then return inside_quotes end return arg end -- FIXME: Move to utils -- Iterate over a chain of parameters, FIRST then PREF2, PREF3, ..., -- inserting into LIST (newly created if omitted). Return LIST. local function get_arg_chain(args, first, pref, list) if not list then list = {} end local val = args[first] local i = 2 while val do table.insert(list, val) val = args[pref .. i] i = i + 1 end return list end -- synthesize a frame so that exported functions meant to be called from -- templates can be called from the debug console. local function debug_frame(parargs, args) return {args = args, getParent = function() return {args = parargs} end} end local function rutr_pairs_equal(term1, term2) local ru1, tr1 = term1[1], term1[2] local ru2, tr2 = term2[1], term2[2] local ru1entry, ru1notes = m_table_tools.separate_notes(m_links.remove_links(ru1)) local ru2entry, ru2notes = m_table_tools.separate_notes(m_links.remove_links(ru2)) if ru1entry ~= ru2entry then return false end local tr1entry, tr1notes local tr2entry, tr2notes if tr1 then tr1entry, tr1notes = m_table_tools.separate_notes(tr1) end if tr2 then tr2entry, tr2notes = m_table_tools.separate_notes(tr2) end if tr1entry == tr2entry then return true elseif type(tr1entry) == type(tr2entry) then return false else tr1entry = tr1entry or com.translit_no_links(ru1entry) tr2entry = tr2entry or com.translit_no_links(ru2entry) return tr1entry == tr2entry end end local function contains_rutr_pair(list, pair) for _, item in ipairs(list) do if rutr_pairs_equal(item, pair) then return true end end return false end -- Clone parent's args while also assigning nil to empty strings. local function clone_args(frame) local args = {} for pname, param in pairs(frame:getParent().args) do args[pname] = ine(param) end return args end -- Old-style declensions. local declensions_old = {} -- New-style declensions; computed automatically from the old-style ones, -- for the most part. local declensions = {} -- Internal notes for old-style declensions. local internal_notes_table_old = {} -- Same for new-style declensions. local internal_notes_table = {} -- Category and type information corresponding to declensions: These may -- contain the following fields: 'singular', 'plural', 'decl', 'hard', 'g', -- 'suffix', 'gensg', 'irregpl', 'alt_nom_pl', 'cant_reduce', 'ignore_reduce', -- 'stem_suffix'. -- -- 'singular' is used to construct a category of the form -- "Russian nouns SINGULAR". If omitted, a category is constructed of the -- form "Russian nouns ending in -ENDING", where ENDING is the actual -- nom sg ending shorn of its acute accents; or "Russian nouns ending -- in suffix -ENDING", if 'suffix' is true. The value of SINGULAR can be -- one of the following: a single string, a list of strings, or a function, -- which is passed one argument (the value of ENDING that would be used to -- auto-initialize the category), and should return a single string or list -- of strings. Such a category is only constructed if 'gensg' is true. -- -- 'plural' is analogous but used to construct a category of the form -- "Russian nouns with PLURAL", and if omitted, a category is constructed -- of the form "Russian nouns with plural -ENDING", based on the actual -- nom pl ending shorn of its acute accents. Currently no plural category -- is actually constructed. -- -- In addition, a category may normally constructed from the combination of -- 'singular' and 'plural', appropriately defaulted; e.g. if both are present, -- the combined category will be "Russian nouns SINGULAR with PLURAL" and -- if both are missing, the combined category will be -- "Russian nouns ending in -SGENDING with plural -PLENDING" (or -- "Russian nouns ending in suffix -SGENDING with plural -PLENDING" if -- 'suffix' is true). Note that if either singular or plural or both -- specifies a list, looping will occur over all combinations. Such a -- category is constructed only if 'irregpl' or 'alt_nom_pl' or 'suffix' -- is true or if the declension class is a slash class. -- -- 'decl' is "1st", "2nd", "3rd" or "indeclinable"; 'hard' is "hard", "soft" -- or "none"; 'g' is "m", "f", "n" or "none"; these are all traditional -- declension categories. -- -- If 'suffix' is true, the declension type includes a long suffix -- added to the string that itself undergoes reducibility and such, and so -- reducibility cannot occur in the stem minus the suffix. Categories will -- be created for the suffix. -- -- 'alt_nom_pl' indicates that the declension has an alternative nominative -- plural (corresponding to Zaliznyak's special case 1; compare special case 2 -- for alternative genitive plural). 'irregpl' indicates that the entire -- plural is irregular. -- -- In addition to the above categories, additional more specific categories -- are constructed based on the final letter of the stem, e.g. -- "Russian velar-stem 1st-declension hard nouns". See calls to -- com.get_stem_trailing_letter_type(). 'stem_suffix', if present, is added to -- the end of the stem when get_stem_trailing_letter_type() is called. -- This is the only place that 'stem_suffix' is used. This is for use with -- the '-ья' and '-ье' declension types, so that the trailing letter is -- 'ь' and not whatever precedes it. -- -- 'enable_categories' is a special hack for testing, which disables all -- category insertion if false. Delete this as soon as we've verified the -- working of the category code and created all the necessary categories. local enable_categories = true -- Category/type info corresponding to old-style declensions; see above. local declensions_old_cat = {} -- Category/type info corresponding to new-style declensions. Computed -- automatically from the old-style ones, for the most part. Same format -- as the old-style ones. local declensions_cat = {} -- Table listing aliases of old-style declension classes. local declensions_old_aliases = {} -- Table listing aliases of new-style declension classes; computed -- automatically from the old-style ones. local declensions_aliases = {} local stress_patterns = {} -- Set of patterns with ending-stressed genitive plural. local ending_stressed_gen_pl_patterns = {} -- Set of patterns with ending-stressed prepositional singular. local ending_stressed_pre_sg_patterns = {} -- Set of patterns with ending-stressed dative singular. local ending_stressed_dat_sg_patterns = {} -- Set of patterns with all singular forms ending-stressed. local ending_stressed_sg_patterns = {} -- Set of patterns with all plural forms ending-stressed. local ending_stressed_pl_patterns = {} local declinable_cases_except_accusative = { "nom_sg", "gen_sg", "dat_sg", "ins_sg", "pre_sg", "nom_pl", "gen_pl", "dat_pl", "ins_pl", "pre_pl", } local accusative_cases_unsplit_animacy = { "acc_sg", "acc_pl", } local accusative_cases_split_animacy = { "acc_sg_an", "acc_sg_in", "acc_pl_an", "acc_pl_in", } local lemma_linked_cases = { "nom_sg_linked", "nom_pl_linked", } local overridable_only_cases = { "par", "loc", "voc", "par_pl", "loc_pl", "voc_pl", "count", "pauc", } local overridable_only_cases_set = m_table.listToSet(overridable_only_cases) -- List of all cases that are declined normally. local decl_cases = m_table.append(declinable_cases_except_accusative, accusative_cases_unsplit_animacy) -- List of all cases that can be overridden (includes all cases except the "linked" lemma case variants). Also -- currently the same as the cases returned by export.generate_forms(). local overridable_cases = m_table.append(decl_cases, accusative_cases_split_animacy, overridable_only_cases) -- List of all cases that can be displayed (includes all cases except plain accusatives). local displayable_cases = m_table.append(declinable_cases_except_accusative, lemma_linked_cases, accusative_cases_split_animacy, overridable_only_cases) -- List of all cases, including those that are declined normally (nom/gen/dat/acc/ins/pre sg and pl), plus -- animate/inanimate accusative variants (computed automatically as appropriate from the previous cases), plus -- additional overridable cases (loc/par/voc and plural), plus the "linked" lemma case variants used in ru-noun+ -- headwords (nom_sg_linked, nom_pl_linked, whose values come from nom_sg and nom_pl but may have additional embedded -- links if they were given in the lemma). local all_cases = m_table.append(overridable_cases, lemma_linked_cases) local function english_case_description(case) if case == "par" or case == "loc" or case == "voc" then -- For historical reasons, the singular of these cases doens't include "_sg" in their code. case = case .. "_sg" end local engcase = rsub(case, "^([a-z]*)", { nom="nominative", gen="genitive", dat="dative", acc="accusative", ins="instrumental", pre="prepositional", par="partitive", loc="locative", voc="vocative", count="count form", pauc="paucal form", }) engcase = rsub(engcase, "(_[a-z]*)", { _sg=" singular", _pl=" plural", _an="", _in="", --_an=" animate", _in=" inanimate" }) return engcase end -------------------------------------------------------------------------- -- Tracking and categorization -- -------------------------------------------------------------------------- -- FIXME! Move below the main code -- FIXME!! Consider deleting most of this tracking code once we've enabled -- all the categories. Note that some of the tracking categories aren't -- completely redundant; e.g. we have tracking pages that combine decl and -- stress classes, such as "а/a" or "о-и/d'", which are more or less -- equivalent to stem/gender/stress categories, but we also have the same -- prefixed by "reducible-stem/" for reducible stems. local function tracking_code(stress, orig_decl, decl, args, n, islast) assert(orig_decl) assert(decl) local hint_types = com.get_stem_trailing_letter_type(args.stem) if orig_decl == decl then orig_decl = nil end if args.notes then track("notes") end local function all_pl_irreg() track("irreg") for _, case in ipairs(overridable_cases) do if rfind(case, "_pl") then track("irreg/" .. case) end end end local function track_prefix(prefix) local function dotrack(suf) track(prefix .. suf) end dotrack(stress) dotrack(decl) dotrack(decl .. "/" .. stress) if orig_decl then dotrack(orig_decl) dotrack(orig_decl .. "/" .. stress) end for _, hint_type in ipairs(hint_types) do dotrack(hint_type) dotrack(decl .. "/" .. hint_type) if orig_decl then dotrack(orig_decl .. "/" .. hint_type) end end end track_prefix("") if args.reducible then track("reducible-stem") track_prefix("reducible-stem/") end if rlfind(args.stem, "и́?н$") and (decl == "" or decl == "#") then track("irregular-in") end if args.pltail then track("pltail") end if args.sgtail then track("sgtail") end if args.pltailall then track("pltailall") end if args.sgtailall then track("sgtailall") end if args.pl ~= args.stem then track("irreg-pl-stem") track("irreg") end if args.alt_gen_pl then track("alt-gen-pl") track("irreg") track("irreg/gen_pl") end if args.want_sc1 then track("want-sc1") track("irreg") track("irreg/nom_pl") end if rfind(decl, "-и$") or rfind(decl, "-а$") or rfind(decl, "-я$") then track("irreg") track("irreg/nom_pl") end if rfind(decl, "-ья$") then track("variant-ья") all_pl_irreg() end if rfind(decl, "%(ишк%)$") then track("variant-ишко") end if rfind(decl, "%(ищ%)$") then track("variant-ище") end if args.jo_special then track("jo-special") end if args.manual then track("manual") end if args.explicit_gender then track("explicit-gender") track("explicit-gender/" .. args.explicit_gender) end for _, case in ipairs(overridable_cases) do if args[case .. n] and not args.manual then track("override") track("override/" .. case .. n) track("irreg") track("irreg/" .. case .. n) -- questionable use: track_prefix("irreg/" .. case .. "/") -- questionable use: track_prefix("irreg/" .. case .. n .. "/") end if islast and args[case] and not args.manual then track("override") track("override/" .. case) track("irreg") track("irreg/" .. case) -- questionable use: track_prefix("irreg/" .. case .. "/") end if args[case .. "_tail"] then track("casenum-tail") track("casenum-tail/" .. case) end if args[case .. "_tailall"] then track("casenum-tailall") track("casenum-tailall/" .. case) end end end local gender_to_full = {m="masculine", f="feminine", n="neuter"} local gender_to_short = {m="masc", f="fem", n="neut"} -- Insert the category CAT (a string) into list CATEGORIES. String will -- have "Russian " prepended and ~ substituted for the plural part of speech. local function insert_category(categories, cat, pos, atbeg) if enable_categories then local fullcat = "Russian " .. rsub(cat, "~", pos .. "s") if atbeg then table.insert(categories, 1, fullcat) else table.insert(categories, fullcat) end end end -- Insert categories into ARGS.CATEGORIES corresponding to the specified -- stress and declension classes and to the form of the stem (e.g. velar, -- sibilant, etc.). Also initialize values used to compute the declension -- heading that describes similar information. N is the number of the -- word being processed; ISLAST is true if this is the last word. local function categorize_and_init_heading(stress, decl, args, n, islast) local function cat_to_list(cat) if not cat then return {} elseif type(cat) == "string" then return {cat} else assert(type(cat) == "table") return cat end end -- Insert category CAT into the list of categories in ARGS. -- CAT may be nil, a single string or a list of strings. We call -- insert_category() on each string. The strings will have "Russian " -- prepended and "~" replaced with the plural part of speech. local function insert_cat(cat) for _, c in ipairs(cat_to_list(cat)) do insert_category(args.categories, c, args.pos) end end -- "Resolve" the category spec CATSPEC into the sort of category spec -- accepted by insert_cat(), i.e. nil, a single string or a list of -- strings. CATSPEC may be any of these or a function, which takes one -- argument (SUFFIX) and returns another CATSPEC. local function resolve_cat(catspec, suffix) if type(catspec) == "function" then return resolve_cat(catspec(suffix), suffix) else return catspec end end -- Check whether an override for nom_sg or nom_pl still contains the -- normal suffix (which should already have accents removed) in at least -- one of its entries. If no override then of course we return true. local function override_matches_suffix(args, case, n, suffix) assert(suffix == com.remove_accents(suffix)) -- NOTE: It might not be completely correct to pass in args.forms -- here when n == ""; this is different behavior from -- handle_overall_forms_and_overrides(). But args.forms is only used -- to retrieve the dat_sg for handling loc/par, and we're never -- called with loc or par as the value of CASE, so it doesn't matter. -- We add an assert to make sure of this. assert(case ~= "loc" and case ~= "par") local override = canonicalize_override(args, case, args.forms, n) if not override then return true end for _, x in ipairs(override) do local ru, tr = x[1], x[2] local entry, notes = m_table_tools.separate_notes(ru) entry = com.remove_accents(m_links.remove_links(entry)) if rlfind(entry, suffix .. "$") then return true end end return false end if args.manual then return end local h = args.heading_info assert(decl) local decl_cats = args.old and declensions_old_cat or declensions_cat local sgdecl, pldecl local is_slash_decl = rfind(decl, "/") if is_slash_decl then local indiv_decls = rsplit(decl, "/") sgdecl, pldecl = indiv_decls[1], indiv_decls[2] else sgdecl, pldecl = decl, decl end local sgdc = decl_cats[sgdecl] local pldc = decl_cats[pldecl] assert(sgdc) assert(pldc) local sghint_types = com.get_stem_trailing_letter_type( args.stem .. (sgdc.stem_suffix or "")) -- insert English version of Zaliznyak stem type if sgdc.decl == "indeclinable" then insert_cat("indeclinable ~") insert_if_not(h.stemetc, "indecl") else local stem_type = sgdc.decl == "3rd" and "3rd-declension" or m_table.contains(sghint_types, "velar") and "velar-stem" or m_table.contains(sghint_types, "sibilant") and "sibilant-stem" or m_table.contains(sghint_types, "c") and "ц-stem" or m_table.contains(sghint_types, "i") and "i-stem" or m_table.contains(sghint_types, "vowel") and "vowel-stem" or m_table.contains(sghint_types, "soft-cons") and "vowel-stem" or m_table.contains(sghint_types, "palatal") and "vowel-stem" or sgdc.hard == "soft" and "soft-stem" or "hard-stem" local short_stem_type = stem_type == "3rd-declension" and "3rd-decl" or stem_type if sgdc.adj then -- Don't include gender for pluralia tantum because it's mostly -- indeterminate (certainly when specified using a plural lemma, -- which will be usually; technically it's partly or completely -- determinate in certain old-style adjectives that distinguish -- masculine from feminine/neuter, but this is too rare a case -- to worry about) local gendertext = args.thisn == "p" and "plural-only" or gender_to_full[sgdc.g] insert_if_not(h.adjectival, "yes") if args.thisn ~= "p" then insert_if_not(h.gender, gender_to_short[sgdc.g]) end if sgdc.possadj then insert_cat(sgdc.decl .. " possessive " .. gendertext .. " accent-" .. stress .. " adjectival ~") insert_if_not(h.stemetc, sgdc.decl .. " poss") insert_if_not(h.stress, stress) elseif stem_type == "soft-stem" or stem_type == "vowel-stem" then insert_cat(stem_type .. " " .. gendertext .. " adjectival ~") insert_if_not(h.stemetc, short_stem_type) else insert_cat(stem_type .. " " .. gendertext .. " accent-" .. stress .. " adjectival ~") insert_if_not(h.stemetc, short_stem_type) insert_if_not(h.stress, stress) end else -- NOTE: There are 8 Zaliznyak-style stem types and 3 genders, but -- we don't create a category for masculine-form 3rd-declension -- nouns (there is such a noun, путь, but it mostly behaves -- like a feminine noun), so there are 23. insert_cat(stem_type .. " " .. gender_to_full[sgdc.g] .. "-form ~") -- NOTE: Here we are creating categories for the combination of -- stem, gender and accent. There are 10 accent patterns and 23 -- combinations of stem and gender, which potentially makes for -- 10*23 = 230 such categories, which is a lot. Not all such -- categories should actually exist; there were maybe 75 former -- declension templates, each of which was essentially categorized -- by the same three variables, but some of which dealt with -- ancillary issues like irregular plurals; this amounts to 67 -- actual stem/gender/accent categories, although there are more -- of them in Zaliznyak (FIXME, how many? See generate_cats.py). insert_cat(stem_type .. " " .. gender_to_full[sgdc.g] .. "-form accent-" .. stress .. " ~") insert_if_not(h.adjectival, "no") insert_if_not(h.gender, gender_to_short[sgdc.g]) insert_if_not(h.stemetc, short_stem_type) insert_if_not(h.stress, stress) end insert_cat("~ with accent pattern " .. stress) end local sgsuffix = args.suffixes.nom_sg if sgsuffix then assert(#sgsuffix == 1) -- If this ever fails, then implement a loop sgsuffix = com.remove_accents(sgsuffix[1]) -- If we are plural only or if nom_sg is overridden and has -- an unusual suffix, then don't create category for sg suffix if args.thisn == "p" or not override_matches_suffix(args, "nom_sg", n, sgsuffix) or islast and not override_matches_suffix(args, "nom_sg", "", sgsuffix) then sgsuffix = nil end end local plsuffix = args.suffixes.nom_pl if plsuffix then assert(#plsuffix == 1) -- If this ever fails, then implement a loop plsuffix = com.remove_accents(plsuffix[1]) -- If we are a singulare tantum or if nom_pl is overridden and has -- an unusual suffix, then don't create category for pl suffix if args.thisn == "s" or not override_matches_suffix(args, "nom_pl", n, plsuffix) or islast and not override_matches_suffix(args, "nom_pl", "", plsuffix) then plsuffix = nil end end sgsuffix = sgsuffix and rsub(sgsuffix, "ъ$", "") plsuffix = plsuffix and rsub(plsuffix, "ъ$", "") local sgcat = sgsuffix and (resolve_cat(sgdc.singular, sgsuffix) or "ending in " .. (sgsuffix == "" and "a consonant" or (sgdc.suffix and "suffix " or "") .. "-" .. sgsuffix)) local plcat = plsuffix and (resolve_cat(pldc.plural, suffix) or "plural -" .. plsuffix) if sgcat and sgdc.gensg then for _, cat in ipairs(cat_to_list(sgcat)) do insert_cat("~ " .. cat) end end if sgcat and plcat and (sgdc.suffix or sgdc.alt_nom_pl or sgdc.irregpl or is_slash_decl and plsuffix == "-ья") then for _, scat in ipairs(cat_to_list(sgcat)) do for _, pcat in ipairs(cat_to_list(plcat)) do insert_cat("~ " .. scat .. " with " .. pcat) end end end if args.pl ~= args.stem then insert_cat("~ with irregular plural stem") end if args.reducible and not sgdc.ignore_reduce then insert_cat("~ with reducible stem") insert_if_not(h.reducible, "yes") else insert_if_not(h.reducible, "no") end if args.alt_gen_pl then insert_cat("~ with alternate genitive plural") end if sgdc.adj then insert_cat("adjectival ~") end end local function compute_heading(args) local headings = {} local h = args.heading_info table.insert(headings, args.a == "a" and "anim" or args.a == "i" and "inan" or "bian") table.insert(headings, args.nonumber and "uncountable" or args.n == "s" and "sg-only" or args.n == "p" and "pl-only" or nil) if #h.gender > 0 then table.insert(headings, table.concat(h.gender, "/") .. "-form") end if #h.stemetc > 0 then table.insert(headings, table.concat(h.stemetc, "/")) end if #h.stress > 0 then local stresses = {} for _, stress in ipairs(h.stress) do table.insert(stresses, rsub(stress, "'", "&#39;")) end table.insert(headings, "accent-" .. table.concat(stresses, "/")) end local function handle_bool(boolvals, text, into) into = into or headings if m_table.contains(boolvals, "yes") and m_table.contains(boolvals, "no") then table.insert(into, "[" .. text .. "]") elseif m_table.contains(boolvals, "yes") then table.insert(into, text) end end handle_bool(h.adjectival, "adj") handle_bool(h.reducible, "reduc") return headings end local function compute_overall_heading_categories_and_genders(args) local hinfo = args.per_word_heading_info local index = 0 -- First try for non-adjectival, non-indeclinable for i=1,#hinfo do if not m_table.contains(hinfo[i].stemetc, "indecl") and not m_table.contains(hinfo[i].adjectival, "yes") then index = i break end end if index == 0 then -- Then just non-indeclinable for i=1,#hinfo do if not m_table.contains(hinfo[i].stemetc, "indecl") then index = i break end end end -- Finally, do anything if index == 0 then index = 1 end -- Compute final heading local headings = args.per_word_headings[index] local categories = args.per_word_categories[index] if args.any_irreg then table.insert(headings, "irreg") insert_category(categories, "irregular ~", args.pos) end for _, case in ipairs(overridable_cases) do local is_pl = rfind(case, "_pl") if args.n == "s" and is_pl or args.n == "p" and not is_pl then -- Don't create singular categories when plural-only or vice-versa elseif overridable_only_cases_set[case] then if args.any_overridden[case] then insert_category(categories, "~ with " .. english_case_description(case), args.pos) end elseif args.any_irreg_case[case] then insert_category(categories, "~ with irregular " .. english_case_description(case), args.pos) end end local heading = args.manual and "" or "(<span style=\"font-size: smaller;\">[[Appendix:Russian nouns#Declension tables|" .. table.concat(headings, " ") .. "]]</span>)" args.heading = heading args.categories = categories args.genders = args.per_word_genders[index] end -------------------------------------------------------------------------- -- Main code -- -------------------------------------------------------------------------- -- Used by do_generate_forms(). local function arg1_is_stress(arg1) if not arg1 then return false end for _, arg in ipairs(rsplit(arg1, ",")) do if not rfind(arg, "^[a-f]'?'?$") then return false end end return true end -- Used by do_generate_forms(), handling a word joiner argument -- of the form 'join:JOINER'. local function extract_word_joiner(spec) word_joiner = rmatch(spec, "^join:(.*)$") assert(word_joiner) return com.split_russian_tr(word_joiner, "dopair") end local function determine_headword_gender(args, sgdc, gender) -- If gender unspecified, use normal gender of declension, except when -- adjectival nouns that are pluralia tantum, where the gender is -- mostly indeterminate (FIXME, not completely with old-style declensions -- but we don't handle that currently). if not gender then if sgdc.adj and args.thisn == "p" then gender = nil else gender = sgdc.g end end -- Determine headword genders gender = gender and gender ~= "none" and gender .. "-" or "" local plsuffix = args.n == "p" and "-p" or "" local hgens if args.a == "a" then hgens = {gender .. "an" .. plsuffix} elseif args.a == "i" then hgens = {gender .. "in" .. plsuffix} elseif args.a == "ai" then hgens = {gender .. "an" .. plsuffix, gender .. "in" .. plsuffix} else hgens = {gender .. "in" .. plsuffix, gender .. "an" .. plsuffix} end -- Insert into list of genders for _, hgen in ipairs(hgens) do insert_if_not(args.genders, hgen) end end function export.do_generate_forms(args, old) old = old or args.old args.old = old args.pos = args.pos or "noun" -- This is a list with each element corresponding to a word and -- consisting of a two-element list, ARG_SETS and JOINER, where ARG_SETS -- is a list of ARG_SET objects, one per alternative stem, and JOINER -- is a string indicating how to join the word to the next one. local per_word_info = {} -- Gather arguments into a list of ARG_SET objects, containing (potentially) -- elements 1, 2, 3, 4, corresponding to accent pattern, stem, declension -- type, pl stem and coming from consecutive numbered parameters. Sets of -- declension parameters are separated by the word "or". local arg_sets = {} -- Find maximum-numbered arg, allowing for holes local max_arg = 0 for k, v in pairs(args) do if type(k) == "number" and k > max_arg then max_arg = k end end -- Now gather the arguments. local offset = 0 local arg_set = {} for i=1,(max_arg + 1) do local end_arg_set = false local end_word = false -- FIXME, is this correct? local word_joiner if i == max_arg + 1 then end_arg_set = true end_word = true word_joiner = {""} elseif args[i] == "_" then end_arg_set = true end_word = true word_joiner = {" "} elseif args[i] == "-" then end_arg_set = true end_word = true word_joiner = {"-"} elseif args[i] and rfind(args[i], "^join:") then end_arg_set = true end_word = true word_joiner = extract_word_joiner(args[i]) elseif args[i] == "or" then end_arg_set = true end if end_arg_set then table.insert(arg_sets, arg_set) arg_set = {} offset = i if end_word then table.insert(per_word_info, {arg_sets, word_joiner}) arg_sets = {} end else -- If the first argument isn't stress, that means all arguments -- have been shifted to the left one. We want to shift them -- back to the right one, so we change the offset so that we -- get the same effect of skipping a slot in the arg set. if i - offset == 1 and not arg1_is_stress(args[i]) then offset = offset - 1 end if i - offset > 4 then error("Too many arguments for argument set: arg " .. i .. " = " .. (args[i] or "(blank)")) end arg_set[i - offset] = args[i] end end return generate_forms_1(args, per_word_info) end function export.do_generate_forms_multi(args, old) old = old or args.old args.old = old args.pos = args.pos or "noun" -- This is a list with each element corresponding to a word and -- consisting of a two-element list, ARG_SET and JOINER, where ARG_SET -- is a list of ARG_SET objects, one per alternative stem, and JOINER -- is a string indicating how to join the word to the next one. local per_word_info = {} -- Find maximum-numbered arg, allowing for holes (FIXME: Is this needed -- here? Will there be holes?) local max_arg = 0 for k, v in pairs(args) do if type(k) == "number" and k > max_arg then max_arg = k end end -- Gather arguments into a list of ARG_SET objects, containing -- (potentially) elements 1, 2, 3, corresponding to accent pattern, -- lemma+declension spec, pl stem, exactly as with do_generate_forms() -- and {{ru-noun-table}} except that the values come from a single argument -- of the form ACCENTPATTERN:LEMMADECL:PL where all but LEMMADECL may (and -- probably will be) omitted and LEMMADECL may be of the following forms: -- LEMMA (for a noun with empty decl spec), -- LEMMADECL (for a noun with non-empty decl spec beginning with a -- *, left paren or semicolon), -- LEMMA^DECL (for a noun with non-empty decl spec), -- LEMMA$ (for an indeclinable word) -- LEMMA+ (for an adjective with auto-detected decl class) -- LEMMA+DECL (for an adjective with explicit decl class) -- Sets of parameters for the same word are separated by the word "or". local arg_sets = {} local continue_arg_sets = true for i=1,(max_arg + 1) do local end_word = false local word_joiner local process_arg = false if i == max_arg + 1 then end_word = true word_joiner = {""} elseif args[i] == "-" then end_word = true word_joiner = {"-"} continue_arg_sets = true elseif rfind(args[i], "^join:") then end_word = true word_joiner = extract_word_joiner(args[i]) continue_arg_sets = true elseif args[i] == "or" then continue_arg_sets = true else if continue_arg_sets then continue_arg_sets = false else end_word = true word_joiner = {" "} end process_arg = true end if end_word then table.insert(per_word_info, {arg_sets, word_joiner}) arg_sets = {} end if process_arg then local vals = rsplit(args[i], ":") if #vals > 3 then error("Can't specify more than 3 colon-separated params of param set: " .. args[i]) end local arg_set = {} if arg1_is_stress(vals[1]) then arg_set[1] = vals[1] arg_set[2] = vals[2] arg_set[4] = vals[3] else arg_set[2] = vals[1] arg_set[4] = vals[2] end -- recognize indeclinable local indecl_stem = rmatch(arg_set[2], "^(.-)%$$") if indecl_stem then arg_set[2] = indecl_stem arg_set[3] = "$" else -- recognize adjective local adj_stem, adj_type = rmatch(arg_set[2], "^(.*)(%+.*)$") if adj_stem then arg_set[2] = adj_stem arg_set[3] = adj_type else -- recognize noun with ^ local noun_stem, noun_type = rmatch(arg_set[2], "^(.*)%^(.*)$") if noun_stem then arg_set[2] = noun_stem arg_set[3] = noun_type else -- recognize noun without ^ but with decl spec noun_stem, noun_type = rmatch(arg_set[2], "^(..-)([;*(].*)$") if noun_stem then arg_set[2] = noun_stem arg_set[3] = noun_type else -- noun without ^ or decl spec; nothing to do end end end end table.insert(arg_sets, arg_set) end end return generate_forms_1(args, per_word_info) end -- Implementation of do_generate_forms() and do_generate_forms_multi(), -- which have equivalent functionality but different calling sequence. -- Implementation of do_generate_forms() and do_generate_forms_multi(), -- which have equivalent functionality but different calling sequence, -- as well as show_z() for template {{ru-decl-noun-z}}, which has a -- subset of the functionality of the other two. generate_forms_1 = function(args, per_word_info) local orig_args if test_new_ru_noun_module then orig_args = mw.clone(args) end local SUBPAGENAME = mw.title.getCurrentTitle().subpageText local old = args.old local function verify_animacy_value(val) if not val then return nil end if val == "a" or val == "an" or val == "anim" then return "a" elseif val == "i" or val == "in" or val == "inan" then return "i" elseif val == "b" or val == "bi" or val == "both" or val == "ai" then return "ai" elseif val == "ia" then return "ia" end error("Animacy value " .. val .. " should be empty or a/an/anim (animate), i/in/inan (inanimate), b/bi/both/ai (bianimate, listing animate first), or ia (bianimate, listing inanimate first)") return nil end local function verify_number_value(val, allow_none) if not val then return nil end local short = usub(val, 1, 1) if short == "s" or short == "p" or short == "b" or (allow_none and short == "n" or false) then return short end if allow_none then error("Number value " .. val .. " should be empty or start with 's' (singular), 'p' (plural), 'b' (both) or 'n' (none)") else error("Number value " .. val .. " should be empty or start with 's' (singular), 'p' (plural), or 'b' (both)") end return nil end -- Verify and canonicalize animacy, number, prefix, suffix assert(#per_word_info >= 1) for i=1,#per_word_info do args["a" .. i] = verify_animacy_value(args["a" .. i]) args["n" .. i] = verify_number_value(args["n" .. i]) args["prefix" .. i] = com.split_russian_tr(args["prefix" .. i] or "", "dopair") args["suffix" .. i] = com.split_russian_tr(args["suffix" .. i] or "", "dopair") end args.a = verify_animacy_value(args.a) or "i" -- args.ndef, if set, is the default value for args.n; if unset, it defaults -- to "both". It is set to "singular" in ru-proper noun+. We store the value -- of args.n in args.orign before defaulting to args.ndef because we may -- change it to plural-only later on if it was unspecified (this happens if -- an individual word's lemma is plural), and to determine whether it was -- unspecified, we need the original value before defaulting. args.n = verify_number_value(args.n, "allow none") -- treat n=none like n=sg but set a flag so "singular" isn't displayed if args.n == "n" then args.n = "s" args.nonumber = true end args.ndef = verify_number_value(args.ndef) args.orign = args.n args.n = args.n or args.ndef args.prefix = com.split_russian_tr(args.prefix or "", "dopair") args.suffix = com.split_russian_tr(args.suffix or "", "dopair") -- Attach overall prefix to first per-word prefix, similarly for suffix args.prefix1 = com.concat_paired_russian_tr(args.prefix, args.prefix1) args["suffix" .. #per_word_info] = com.concat_paired_russian_tr( args["suffix" .. #per_word_info], args.suffix) -- Initialize non-word-specific arguments. -- -- The following is a list of WORD_INFO items, one per word, each of -- which is a two element list of WORD_FORMS (a table listing the forms for -- each case) and JOINER (a string, indicating how to join the word with -- the next one). args.per_word_info = {} -- List of HEADING_INFO items, one per word, containing the raw material -- used to generate the header. Initialized from 'args.heading_info', -- which is initialized in categorize_and_init_heading(). args.per_word_heading_info = {} -- List of CATEGORIES items, one per word, containing the categories -- used to initialize the page categories. Initialized from -- 'args.categories', which is initialized in categorize_and_init_heading(). args.per_word_categories = {} -- List of HEADINGS items, one per word, containing the actual words that -- go into the header if we were to use that word to construct the header. -- Comes from compute_heading(). We use this to generate the actual header -- string, which goes into 'args.heading' at the end (done in -- compute_overall_heading_categories_and_genders()). args.per_word_headings = {} -- List of GENDERS items, one per word, containing the headword genders -- for each word (where "headword gender" is in the format used in -- headwords and actually includes animacy and number as well, e.g. -- 'm-in' or 'f-an-p'). We end up selecting one such item and putting -- it into 'args.genders' at the end -- (in compute_overall_heading_categories_and_genders()). args.per_word_genders = {} args.any_overridden = {} args.any_non_nil = {} args.any_irreg = false args.any_irreg_case = {} local function insert_cat(cat) insert_category(args.categories, cat, args.pos) end args.internal_notes = {} local decl_sufs = old and declensions_old or declensions local decl_cats = old and declensions_old_cat or declensions_cat local intable = old and internal_notes_table_old or internal_notes_table -- Default lemma defaults to previous lemma, first one to page name. -- FIXME: With multiple words, we should probably split the page name -- on spaces and default each word in turn local default_lemma local all_stresses_seen -- Made into a function to avoid having to indent a lot of code. -- Process a single arg set of a single word. This inserts the forms -- for the word into args.forms and sets categories and tracking pages. local function do_arg_set(arg_set, n, islast) local stress_arg = arg_set[1] local decl = arg_set[3] or "" local pl, pltr if arg_set[4] then pl, pltr = com.split_russian_tr(arg_set[4]) end -- Extract special markers from declension class. if decl == "manual" then decl = "$" args.manual = true if #per_word_info > 1 or #per_word_info[1][1] > 1 then error("Can't specify multiple words or argument sets when manual") end if pl then error("Can't specify optional stem parameters when manual") end end decl, args.jo_special = rsubb(decl, "([^/%a])ё$", "%1") if not args.jo_special then decl, args.jo_special = rsubb(decl, "([^/%a])ё([^/%a])", "%1%2") end decl, args.want_sc1 = rsubb(decl, "%(1%)", "") decl, args.alt_gen_pl = rsubb(decl, "%(2%)", "") decl, args.reducible = rsubb(decl, "%*", "") decl = rsub(decl, ";", "") -- Get the lemma. local lemma = args.manual and "-" or arg_set[2] or default_lemma if not lemma then error("Lemma in first argument set must be specified") end default_lemma = lemma local lemmatr lemma, lemmatr = com.split_russian_tr(lemma) -- If we're conjugating a suffix, insert a pseudoconsonant at the beginning -- of all forms, so they get conjugated as if ending in a consonant. -- We remove the pseudoconsonant later. local is_suffix = lemma ~= "-" and rfind(lemma, "^%-") args.any_suffix = args.any_suffix or is_suffix local asif_prefix = args["asif_prefix" .. n] or args.asif_prefix or is_suffix and PSEUDOCONS if asif_prefix then lemma = rsub(lemma, "^%-", "-" .. asif_prefix) if lemmatr then lemmatr = rsub(lemmatr, "^%-", "-" .. com.translit(asif_prefix)) end end args.thisa = args["a" .. n] or args.a args.thisn = args["n" .. n] or args.n -- Check for explicit allow-unaccented indication. local allow_unaccented lemma, allow_unaccented = rsubb(lemma, "^%*", "") args.allow_unaccented = args.allow_unaccented or allow_unaccented if args.allow_unaccented then track("allow-unaccented") end args.orig_lemma = lemma lemma = m_links.remove_links(lemma) args.lemma_no_links = lemma args.lemmatr = lemmatr if args.lemma then -- Explicit lemma given. args.explicit_lemma, args.explicit_lemmatr = com.split_russian_tr(args.lemma) end -- Treat suffixes without an accent, and suffixes with an accent on the -- initial hyphen, as if they were preceded with a *, which overrides -- all the logic that normally (a) normalizes the accent, and (b) -- complains about multisyllabic words without an accent. Don't do this -- if lemma is just -, which is used specially in manual declension -- tables (e.g. сто, три). if lemma ~= "-" and (rfind(lemma, "^%-́") or (com.is_unstressed(lemma) and rfind(lemma, "^%-"))) then args.allow_unaccented = true end -- Convert lemma and decl arg into stem and canonicalized decl. -- This will autodetect the declension from the lemma if an explicit -- decl isn't given. local stem, tr, gender, was_accented, was_plural, was_autodetected if rfind(decl, "^%+") then stem, tr, decl, gender, was_accented, was_plural, was_autodetected = detect_adj_type(lemma, lemmatr, decl, old) else stem, tr, decl, gender, was_accented, was_plural, was_autodetected = determine_decl(lemma, lemmatr, decl, args) end if was_plural then args.n = args.orign or "p" args.thisn = args["n" .. n] or args.n elseif decl ~= "$" then args.thisn = args.thisn or "b" end args.explicit_gender = gender -- If allow-unaccented not given, maybe check for missing accents. if not args.allow_unaccented and not stress_arg and was_autodetected and com.needs_accents(lemma) then -- If user gave the full word and expects us to determine the -- declension and stress, the word should have an accent on the -- stem or ending. We have a separate check farther below for -- an accent on a multisyllabic stem, after stripping off any -- ending; but this way we get an error if the user e.g. writes -- "гора" without an accent rather than assuming it's stem -- stressed, as would otherwise happen. error("Lemma must have an accent in it: " .. lemma) end -- If stress not given, auto-determine; else validate/canonicalize -- stress arg, override in certain cases and convert to list. if not stress_arg then stress_arg = {detect_stress_pattern(stem, decl, decl_cats, args.reducible, was_plural, was_accented)} else stress_arg = rsplit(stress_arg, ",") for i=1,#stress_arg do local stress = stress_arg[i] stress = override_stress_pattern(decl, stress) if not stress_patterns[stress] then error("Unrecognized accent pattern " .. stress) end stress_arg[i] = stress end end -- parse slash decl to list local sub_decls if rfind(decl, "/") then track("mixed-decl") insert_cat("~ with mixed declension") local indiv_decls = rsplit(decl, "/") -- Should have been caught in canonicalize_decl() assert(#indiv_decls == 2) sub_decls = {{indiv_decls[1], "sg"}, {indiv_decls[2], "pl"}} else sub_decls = {{decl}} end -- Get singular declension and corresponding category. local sgdecl = sub_decls[1][1] local sgdc = decl_cats[sgdecl] assert(sgdc) -- Compute headword gender(s). We base it off the singular declension -- if we have a slash declension -- it's the best we can do. determine_headword_gender(args, sgdc, gender) local original_stem, original_tr = stem, tr local original_pl, original_pltr = pl, pltr -- Loop over accent patterns in case more than one given. for _, stress in ipairs(stress_arg) do args.suffixes = {} stem, tr = original_stem, original_tr local bare, baretr local stem_for_bare, tr_for_bare pl, pltr = original_pl, original_pltr insert_if_not(all_stresses_seen, stress) local stem_was_unstressed = com.is_unstressed(stem) -- If special case ;ё was given and stem is unstressed, -- add ё to the stem now; but don't let this interfere with -- restressing, to handle cases like железа́ with gen pl желёз -- but nom pl же́лезы. if stem_was_unstressed and args.jo_special then -- Beware, Cyrillic еЕ in first rsub, Latin eE in second local new_stem = rsub(stem, "([еЕ])([^еЕ]*)$", function(e, rest) return (e == "Е" and "Ё" or "ё") .. rest end ) if stem == new_stem then error("No е in stem to replace with ё") end stem = new_stem if tr then local subbed -- e after j -> o, e not after j -> jo; don't just convert e -> jo -- and then map jjo -> jo because we want to preserve double j tr, subbed = rsubb(tr, "([jJ])([eE])([^eE]*)$", function(j, e, rest) return j .. (e == "E" and "O" or "o") .. AC .. rest end ) if not subbed then tr = rsub(tr, "([eE])([^eE]*)$", function(e, rest) return (e == "E" and "Jo" or "jo") .. AC .. rest end ) end tr = com.j_correction(tr) end -- This is used to handle железа́ with gen pl желёз and nom pl -- же́лезы. We have two stressed stems, one for the gen pl and -- one for the remaining pl cases, and the variable 'stem' can -- handle only one, so we put the second (gen pl) stem in -- stem_for_bare, which goes into the value of 'bare' (used -- only for gen pl here). stem_for_bare, tr_for_bare = stem, tr end -- Maybe add stress to the stem, depending on whether the -- stem was unstressed and the stress pattern. Stem pattern f -- and variants call for initial stress (голова́ -> го́ловы); -- stem pattern d and variants call for stem-final stress -- (сапожо́к -> сапо́жки). Stem patterns b and b' apparently -- call for stem-final stress as well but it's unlikely to -- make much of a difference (pattern b' only occurs in 3rd-decl -- feminines, which should already have stress in the stem, -- and the only place pattern b gets stem stress is in bare -- forms, i.e. nom sg and/or gen pl depending on the decl type, -- and nom sg stress should already be in the lemma while -- gen pl stress is handled by a different ending-stressing -- mechanism in attach_unstressed(); however, the user is -- free to leave a masc or 3rd-decl fem lemma completely -- unstressed with pattern b, and then the stem-final stress -- *will* make a difference). local function restress_stem(stem, tr, stress, stem_unstressed) -- If the user has indicated they purposely are leaving the -- word unstressed by putting a * at the beginning of the main -- stem, leave it unstressed. This might indicate lack of -- knowledge of the stress or a truly unaccented word -- (e.g. an unaccented suffix). if args.allow_unaccented then return stem, tr end if tr and com.is_unstressed(stem) ~= com.is_unstressed(tr) then error("Stem " .. stem .. " and translit " .. tr .. " must have same accent pattern") end -- it's safe to accent monosyllabic stems if com.is_monosyllabic(stem) then stem, tr = com.make_ending_stressed(stem, tr) -- For those patterns that are ending-stressed in the singular -- nominative (and hence are likely to be expressed without an -- accent on the stem) it's safe to put a particular accent on -- the stem depending on the stress type. Otherwise, give an -- error if no accent. elseif stem_unstressed then if rfind(stress, "^f") then stem, tr = com.make_beginning_stressed(stem, tr) elseif (rfind(stress, "^[bd]") or args.thisn == "p" and ending_stressed_pl_patterns[stress]) then stem, tr = com.make_ending_stressed(stem, tr) elseif com.needs_accents(stem) then error("Stem " .. stem .. " requires an accent") end end return stem, tr end stem, tr = restress_stem(stem, tr, stress, stem_was_unstressed) -- Leave pl unaccented if user wants this; see restress_stem(). if pl and not args.allow_unaccented then if pltr and com.is_unstressed(pl) ~= com.is_unstressed(pltr) then error("Plural stem " .. pl .. " and translit " .. pltr .. " must have same accent pattern") end if com.is_monosyllabic(pl) then pl, pltr = com.make_ending_stressed(pl, pltr) end -- I think this is safe. if com.needs_accents(pl) then if ending_stressed_pl_patterns[stress] then pl, pltr = com.make_ending_stressed(pl, pltr) elseif not args.allow_unaccented then error("Plural stem " .. pl .. " requires an accent") end end end local resolved_bare, resolved_baretr -- Handle (de)reducibles -- FIXME! We are dereducing based on the singular declension. -- In a slash declension things can get weird and we don't -- handle that. We are also computing the bare value from the -- singular stem, and again things can get weird with a plural -- stem. Note that we don't compute a bare value unless we have -- to (either (de)reducible or stress pattern f/f'/f'' combined -- with ё special case); the remaining times we generate the bare -- value directly from the plural stem. if args.reducible and not sgdc.ignore_reduce then -- Zaliznyak treats all nouns in -ье and -ья as being -- reducible. We handle this automatically and don't require -- the user to specify this, but ignore it if so for -- compatibility. if is_reducible(sgdc) then -- If we derived the stem from a nom pl form, then -- it's already reduced, and we need to dereduce it to -- get a bare form; otherwise the stem comes from the -- nom sg and we need to reduce it to get the real stem. if was_plural then resolved_bare, resolved_baretr = export.dereduce_nom_sg_stem(stem, tr, sgdc, stress, old, "error") else resolved_bare, resolved_baretr = stem, tr stem, tr = export.reduce_nom_sg_stem(stem, tr, sgdecl, "error") -- Stem will be unstressed if stress was on elided -- vowel; restress stem the way we did above. (This is -- needed in at least one word, сапожо́к 3*d(2), with -- plural stem probably сапо́жк- and gen pl probably -- сапо́жек.) stem, tr = restress_stem(stem, tr, stress, com.is_unstressed(stem)) if stress ~= "a" and stress ~= "b" and args.alt_gen_pl and not pl then -- Nouns like рожо́к, глазо́к of type 3*d(2) have -- gen pl's ро́жек, гла́зок; to handle this, -- dereduce the reduced stem and store in a -- special place. args.gen_pl_bare, args.gen_pl_baretr = export.dereduce_nom_sg_stem(stem, tr, sgdc, stress, old, "error") end end elseif is_dereducible(sgdc) then resolved_bare, resolved_baretr = export.dereduce_nom_sg_stem(stem, tr, sgdc, stress, old, "error") else error("Declension class " .. sgdecl .. " not (de)reducible") end elseif stem_for_bare and stem ~= stem_for_bare then resolved_bare, resolved_baretr = add_bare_suffix(stem_for_bare, tr_for_bare, old, sgdc, false) end -- Leave unaccented if user wants this; see restress_stem(). -- FIXME, we no longer allow the user to specify the bare value -- so it's unclear if this is needed any more. if resolved_bare and not args.allow_unaccented then if resolved_baretr and com.is_unstressed(resolved_bare) ~= com.is_unstressed(resolved_baretr) then error("Resolved bare stem " .. resolved_bare .. " and translit " .. resolved_baretr .. " must have same accent pattern") end if com.is_monosyllabic(resolved_bare) then resolved_bare, resolved_baretr = com.make_ending_stressed(resolved_bare, resolved_baretr) else if com.needs_accents(resolved_bare) then error("Resolved bare stem " .. resolved_bare .. " requires an accent") end end end args.stem, args.stemtr = stem, tr args.bare, args.baretr = resolved_bare, resolved_baretr args.ustem, args.ustemtr = com.make_unstressed_once(stem, tr) if pl then args.pl, args.pltr = pl, pltr else args.pl, args.pltr = stem, tr end args.upl, args.upltr = com.make_unstressed_once(args.pl, args.pltr) -- Special hack for любо́вь and other reducible 3rd-fem nouns, -- which have the full stem in the ins sg args.ins_sg_stem = sgdecl == "ь-f" and args.reducible and resolved_bare args.ins_sg_tr = sgdecl == "ь-f" and args.reducible and resolved_baretr -- Loop over declension classes (we may have two of them, one for -- singular and one for plural, in the case of a mixed declension -- class of the form SGDECL/PLDECL). for _,decl_spec in ipairs(sub_decls) do local orig_decl = decl_spec[1] local number = decl_spec[2] local real_decl = determine_stress_variant(orig_decl, stress) real_decl = determine_stem_variant(real_decl, number == "pl" and args.pl or args.stem) -- sanity checking; errors should have been caught in -- canonicalize_decl() assert(decl_cats[real_decl], "real_decl " .. real_decl .. " nonexistent") assert(decl_sufs[real_decl], "real_decl " .. real_decl .. " nonexistent") tracking_code(stress, orig_decl, real_decl, args, n, islast) do_stress_pattern(stress, args, real_decl, number, n, islast) -- handle internal notes local internal_note = intable[real_decl] if internal_note then insert_if_not(args.internal_notes, internal_note) end end categorize_and_init_heading(stress, decl, args, n, islast) end end local n = 0 for _, word_info in ipairs(per_word_info) do n = n + 1 local islast = n == #per_word_info local arg_sets, joiner = word_info[1], word_info[2] args.forms = {} args.heading_info = {animacy={}, number={}, gender={}, stress={}, stemetc={}, adjectival={}, reducible={}} args.categories = {} args.genders = {} args.this_any_non_nil = {} args.any_suffix = false if #arg_sets > 1 then track("multiple-arg-sets") insert_cat("~ with multiple argument sets") track("multiple-declensions") insert_cat("~ with multiple declensions") end default_lemma = SUBPAGENAME all_stresses_seen = {} -- Loop over all arg sets. for _, arg_set in ipairs(arg_sets) do do_arg_set(arg_set, n, islast) end if #all_stresses_seen > 1 then track("multiple-accent-patterns") insert_cat("~ with multiple accent patterns") track("multiple-declensions") insert_cat("~ with multiple declensions") end table.insert(args.per_word_heading_info, args.heading_info) table.insert(args.per_word_categories, args.categories) local headings = compute_heading(args) table.insert(args.per_word_headings, headings) table.insert(args.per_word_genders, args.genders) handle_forms_and_overrides(args, n, islast) if args.any_suffix then -- If we're conjugating a suffix, remove the pseudoconsonant or asif_prefix -- that we previously inserted at the beginning. local asif_prefix = args["asif_prefix" .. n] or args.asif_prefix or PSEUDOCONS local asif_prefix_tr = com.translit(asif_prefix) for _, case in ipairs(all_cases) do if args.forms[case] then local newforms = {} for _, form in ipairs(args.forms[case]) do local formru = form[1] local formtr = form[2] formru = rsub(formru, "^%-" .. asif_prefix, "-") if formtr then formtr = rsub(formtr, "^%-" .. asif_prefix_tr, "-") end if formru == "-" then -- if no ending, insert "(no suffix)". table.insert(newforms, {"(no suffix)"}) else table.insert(newforms, {formru, formtr}) end end args.forms[case] = newforms end end end table.insert(args.per_word_info, {args.forms, joiner}) end handle_overall_forms_and_overrides(args) compute_overall_heading_categories_and_genders(args) for _, case in ipairs(all_cases) do if args[case] then for _, form in ipairs(args[case]) do local ru, tr = form[1], form[2] local ruentry, runotes = m_table_tools.separate_notes(ru) ruentry = m_links.remove_links(ruentry) if rfind(ulower(ruentry), latin_text_class) then --error("Found Latin text " .. ruentry .. " in case " .. case) track("latin-text") track("latin-text/" .. case) end end end end -- Test code to compare existing module to new one. if test_new_ru_noun_module then local m_new_ru_noun = require("Module:User:Benwing2/ru-noun") local newargs = m_new_ru_noun.do_generate_forms(orig_args, old) local difdecl = false for _, case in ipairs(all_cases) do local arg = args[case] local newarg = newargs[case] local is_pl = rfind(case, "_pl") if args.thisn == "s" and is_pl or args.thisn == "p" and not is_pl then -- Don't need to check cases that won't be displayed. elseif not m_table.deepEquals(arg, newarg) then local monosyl_accent_diff = false -- Differences only in monosyllabic accents. Enable if we -- change the algorithm for these. --if arg and newarg and #arg == 1 and #newarg == 1 then -- local ru1, tr1 = arg[1][1], arg[1][2] -- local ru2, tr2 = newarg[1][1], newarg[1][2] -- if com.is_monosyllabic(ru1) and com.is_monosyllabic(ru2) then -- ru1, tr1 = com.remove_accents(ru1, tr1) -- ru2, tr2 = com.remove_accents(ru2, tr2) -- if ru1 == ru2 and tr1 == tr2 then -- monosyl_accent_diff = true -- end -- end --end if monosyl_accent_diff then track("monosyl-accent-diff") difdecl = true else -- Uncomment this to display the particular case and -- differing forms. --error(case .. " " .. (arg and com.concat_forms(arg) or "nil") .. " || " .. (newarg and com.concat_forms(newarg) or "nil")) track("different-decl") difdecl = true end break end end if not difdecl then track("same-decl") end end return args end -- Implementation of main entry point local function do_show(frame, old) local args = clone_args(frame) local args = export.do_generate_forms(args, old) return make_table(args) .. m_utilities.format_categories(args.categories, lang) end -- The main entry point for modern declension tables. function export.show(frame) return do_show(frame, false) end -- The main entry point for old declension tables. function export.show_old(frame) return do_show(frame, true) end -- Implementation of new entry point, esp. for multiple words local function do_show_multi(frame) local args = clone_args(frame) local args = export.do_generate_forms_multi(args) return make_table(args) .. m_utilities.format_categories(args.categories, lang) end -- The new entry point, esp. for multiple words (but works fine for -- single words). function export.show_multi(frame) return do_show_multi(frame) end local function get_form(forms, preserve_links, raw) local canon_forms = {} for _, form in ipairs(forms) do if raw then local ru, tr = form[1], form[2] ru = rsub(ru, "|", "<!>") if tr then tr = rsub(tr, "|", "<!>") end insert_if_not(canon_forms, {ru, tr}) else local ru, tr = form[1], form[2] local ruentry, runotes = m_table_tools.separate_notes(ru) -- Skip hypothetical forms (but include in the raw versions) if not rfind(runotes, HYPMARKER) then local trentry, trnotes if tr then trentry, trnotes = m_table_tools.separate_notes(tr) end if not preserve_links then ruentry = m_links.remove_links(ruentry) end ruentry = rsub(ruentry, "|", "<!>") if trentry then trentry = rsub(trentry, "|", "<!>") end insert_if_not(canon_forms, {ruentry, trentry}) end end end return com.concat_forms(canon_forms) end local function case_will_be_displayed(args, case) local ispl = rfind(case, "_pl") local caseok = true if args.n == "p" then caseok = ispl elseif args.n == "s" then caseok = not ispl end for _, override_case in ipairs(overridable_only_cases) do if case == override_case and not args.any_overridden[override_case] then caseok = false break end end if args.a == "a" or args.a == "i" then if rfind(case, "_[ai]n") then caseok = false end else -- bianimate -- don't include inanimate/animate variants if combined variant exists -- (typically because inanimate/animate variants are the same); -- FIXME: This could conceivably be different from how the display -- code works, which just checks that the inanimate/animate variants -- are the same when deciding whether to display them, in particular -- if there is an override. Here we are following the algorithm of -- handle_overall_forms_and_overrides(). if (case == "acc_sg_in" or case == "acc_sg_an") and args.acc_sg or (case == "acc_pl_in" or case == "acc_pl_an") and args.acc_pl then caseok = false end end if not args[case] then caseok = false end return caseok end local function concat_case_args(args, do_all, raw) local ins_text = {} for _, case in ipairs(do_all and all_cases or overridable_cases) do if case_will_be_displayed(args, case) then local forms = get_form(args[case], rfind(case, "_linked"), raw) if forms ~= "" then table.insert(ins_text, case .. (raw and "_raw" or "") .. "=" .. forms) end end end return table.concat(ins_text, "|") end -- The entry point for 'ru-noun-forms' to generate all noun forms. -- This returns a single string, with | separating arguments and named -- arguments of the form NAME=VALUE. function export.generate_forms(frame) local args = clone_args(frame) args = export.do_generate_forms(args, false) return concat_case_args(args) end -- The entry point to generate multiple sets of noun forms. This is a hack -- to speed up calling from a bot, where we often want to compare old and new -- argument results to make sure they're the same. Each set of arguments is -- jammed together into a single argument with individual values separated by -- <!>; named arguments are of the form NAME<->VALUE. The return value for -- each set of arguments is as in export.generate_forms(), and the return -- values are concatenated with <!> separating them. NOTE: This will fail if -- the exact sequences <!> or <-> happen to occur in values (which is unlikely, -- esp. as we don't even use the characters <, ! or > for anything) and aren't -- HTML-escaped. function export.generate_multi_forms(frame) local retvals = {} for _, argset in ipairs(frame.args) do local args = {} local i = 0 local argvals = rsplit(argset, "<!>") for _, argval in ipairs(argvals) do local split_arg = rsplit(argval, "<%->") if #split_arg == 1 then i = i + 1 args[i] = ine(split_arg[1]) else assert(#split_arg == 2) args[split_arg[1]] = ine(split_arg[2]) end end args = export.do_generate_forms(args, false) table.insert(retvals, concat_case_args(args)) end return table.concat(retvals, "<!>") end -- The entry point for 'ru-noun-form' to generate a particular noun form. function export.generate_form(frame) local args = clone_args(frame) if not args.form then error("Must specify desired form using form=") end local form = args.form if not m_table.contains(all_cases, form) then error("Unrecognized form " .. form) end local args = export.do_generate_forms(args, false) if not args[form] then return "" else return get_form(args[form]) end end -- The entry point for generating arguments of various sorts, including -- the case forms, gender, number and animacy. function export.generate_args(frame) local args = clone_args(frame) args = export.do_generate_forms(args, false) local retargs = {} table.insert(retargs, concat_case_args(args, "doall")) table.insert(retargs, concat_case_args(args, "doall", "raw")) table.insert(retargs, "g=" .. table.concat(args.genders, ",")) -- The following is correct even with ndef because if ndef is -- set we will set it in args.n. table.insert(retargs, "n=" .. (args.n or "b")) table.insert(retargs, "a=" .. (args.a or "i")) return table.concat(retargs, "|") end -- The entry point for compatibility with {{ru-decl-noun-z}}. function export.show_z(frame) local args = clone_args(frame) local stem = args[1] local stress = args[2] local specific = args[4] or "" -- Parse gender/animacy spec local gender, anim = rmatch(args[3], "^([mfn])-([a-z]+)") if not gender then error("Unrecognized gender/anim spec " .. args[3]) end if anim ~= "an" and anim ~= "in" then anim = "both" end args.a = anim -- Handle specific specific = rsub(specific, "ё", ";ё") -- Compute decl; special case for семьянин (perhaps not necessary) local decl = com.make_unstressed_once(stem) == "семьянин" and "#" .. specific or gender .. specific -- Handle overrides args.pre_sg = args.prp_sg args.pre_pl = args.prp_pl args.notes = args.note if args.par then args.par = "+" end if args.loc then if args.loc == "в" then args.loc = "в +" elseif args.loc == "на" then args.loc = "на +" else args.loc = "в +,на +" end end local arg_set = {} table.insert(arg_set, stress) table.insert(arg_set, stem) table.insert(arg_set, decl) local per_word_info = {{{arg_set}, ""}} return generate_forms_1(args, per_word_info) end -------------------------------------------------------------------------- -- Autodetection and lemma munging -- -------------------------------------------------------------------------- -- Attempt to detect the type of the lemma based on its ending, separating -- off the stem and the ending. GENDER must be present with -ь and plural -- stems, and is otherwise ignored. Return up to three values: The stem -- (lemma minus ending), the singular lemma ending, and if the lemma was -- plural, the plural lemma ending. If the lemma was singular, the singular -- lemma ending will contain any user-given accents; likewise, if the -- lemma was plural, the plural ending will contain such accents. -- VARIANT comes from the declension spec and controls certain declension -- variants. local function detect_lemma_type(lemma, tr, gender, args, variant) local base, ending = rmatch(lemma, "^(.*)([еЕ]́)$") -- accented if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*[" .. com.sib_c .. "])([еЕ])$") -- unaccented if base then if variant == "-ище" and not rfind(lemma, "[щЩ][еЕ]$") then error("With declension variant -ище, lemma should end in -ще: " .. lemma) end return base, com.strip_tr_ending(tr, ending), variant == "-ище" and "(ищ)е-и" or "о" end if variant == "-ишко" then base, ending = rmatch(lemma, "^(.*[шШ][кК])([оО])$") -- unaccented if not base then error("With declension variant -ишко, lemma should end in -шко: " .. lemma) end return base, com.strip_tr_ending(tr, ending), "(ишк)о-и" end if variant == "-ин" then base, ending = rmatch(lemma, "^(.*)([иИ]́?[нН][ъЪ]?)$") -- maybe accented if not base then error("With declension variant -ин, lemma should end in -ин(ъ): " .. lemma) end return base, com.strip_tr_ending(tr, ending), ulower(ending) end -- Now autodetect -ин; only animate and in -анин/-янин base, ending = rmatch(lemma, "^(.*[аяАЯ]́?[нН])([иИ]́?[нН][ъЪ]?)$") -- Need to check the animacy to avoid nouns like маиганин, цианин, -- меланин, соланин, etc. if base and args.thisa == "a" then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*)([ёЁ]́?[нН][оО][кК][ъЪ]?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*[" .. com.sib_c .. "])([оО]́[нН][оО][кК][ъЪ]?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*)([ёЁ]́?[нН][оО][чЧ][еЕ][кК][ъЪ]?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*[" .. com.sib_c .. "])([оО]́[нН][оО][чЧ][еЕ][кК][ъЪ]?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*)([мМ][яЯ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end --recognize plural endings if gender == "n" then base, ending = rmatch(lemma, "^(.*)([ьЬ][яЯ]́?)$") if base then -- Don't do this; о/-ья is too rare -- error("Ambiguous plural lemma " .. lemma .. " in -ья, singular could be -о or -ье/-ьё; specify the singular") return base, com.strip_tr_ending(tr, ending), "ье", ending end base, ending = rmatch(lemma, "^(.*)([аяАЯ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), rfind(ending, "[аА]") and "о" or "е", ending end base, ending = rmatch(lemma, "^(.*)([ыиЫИ]́?)$") if base then if rfind(ending, "[ыЫ]") or rfind(base, "[" .. com.sib .. com.velar .. "]$") then return base, com.strip_tr_ending(tr, ending), "о-и", ending else -- FIXME, should we return a slash declension? error("No neuter declension е-и available; use a slash declension") end end end if gender == "f" then base, ending = rmatch(lemma, "^(.*)([ьЬ][иИ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), "ья", ending end end -- Recognize masculines with irregular plurals, but only if the user -- either explicitly specified that this noun is plural (n=p) or -- specifically requested the irregular plural. This is necessary -- because some masculine nouns have feminine endings, which look -- like irregular plurals. if gender == "m" then if args.thisn == "p" or variant == "-ья" then base, ending = rmatch(lemma, "^(.*)([ьЬ][яЯ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), (args.old and "ъ-ья" or "-ья"), ending end end if args.thisn == "p" or args.want_sc1 then base, ending = rmatch(lemma, "^(.*)([аА]́?)$") if base then return base, com.strip_tr_ending(tr, ending), (args.old and "ъ-а" or "-а"), ending end base, ending = rmatch(lemma, "^(.*)([яЯ]́?)$") if base then if rfind(base, "[" .. com.vowel .. "]́?$") then return base, com.strip_tr_ending(tr, ending), "й-я", ending else return base, com.strip_tr_ending(tr, ending), "ь-я", ending end end end end if gender == "m" or gender == "f" then base, ending = rmatch(lemma, "^(.*[" .. com.sib .. com.velar .. "])([иИ]́?)$") if not base then base, ending = rmatch(lemma, "^(.*)([ыЫ]́?)$") end if base then return base, com.strip_tr_ending(tr, ending), gender == "m" and (args.old and "ъ" or "") or "а", ending end base, ending = rmatch(lemma, "^(.*[" .. com.vowel .. "й]́?)([иИ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), gender == "m" and "й" or "я", ending end base, ending = rmatch(lemma, "^(.*)([иИ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), gender == "m" and "ь-m" or "я", ending end end if gender == "3f" then base, ending = rmatch(lemma, "^(.*)([иИ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), "ь-f", ending end end -- end of recognize-plurals code base, ending = rmatch(lemma, "^(.*)([ьЬ][яеёЯЕЁ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*)([йаяеоёъЙАЯЕОЁЪ]́?)$") if base then return base, com.strip_tr_ending(tr, ending), ulower(ending) end base, ending = rmatch(lemma, "^(.*)([ьЬ])$") if base then if gender == "m" or gender == "f" then return base, com.strip_tr_ending(tr, ending), "ь-" .. gender elseif gender == "3f" then return base, com.strip_tr_ending(tr, ending), "ь-f" else error("Need to specify gender m or f with lemma in -ь: ".. lemma) end end if rfind(lemma, "[ыиЫИ]́?$") then error("If this is a plural lemma, gender must be specified: " .. lemma) elseif rfind(lemma, "[уыэюиіѣѵУЫЭЮИІѢѴ]́?$") then error("Don't know how to decline lemma ending in this type of vowel: " .. lemma) end return lemma, tr, "" end local plural_variant_detection_map = { [""] = {["-ья"]="-ья"}, ["ъ"] = {["-ья"]="ъ-ья"}, } local special_case_1_to_plural_variant = { [""] = "-а", ["ъ"] = "ъ-а", ["й"] = "й-я", ["ь-m"] = "ь-я", ["о"] = "о-и", -- these last two are here to avoid getting errors in that checks for -- compatibility with special case 1; the basic variants of these decls -- don't actually exist ["(ишк)о"] = "(ишк)о-и", ["(ищ)е"] = "(ищ)е-и", } local function map_decl(decl, fun) if rfind(decl, "/") then local split_decl = rsplit(decl, "/") if #split_decl ~= 2 then error("Mixed declensional class " .. decl .. "needs exactly two classes, singular and plural") end return fun(split_decl[1]) .. "/" .. fun(split_decl[2]) else return fun(decl) end end -- Canonicalize decl class into non-accented and alias-resolved form; -- but note that some canonical decl class names with an accent in them -- (e.g. е́, not the same as е, whose accented version is ё; and various -- adjective declensions). local function canonicalize_decl(decl, old) local function do_canon(decl) -- remove accents, but not from е́ (for adj decls, accent matters -- as well but we handle that by mapping the accent to a stress pattern -- and then to the accented version in determine_stress_variant()) if decl ~= "е́" then decl = com.remove_accents(decl) end local decl_aliases = old and declensions_old_aliases or declensions_aliases local decl_cats = old and declensions_old_cat or declensions_cat if decl_aliases[decl] then -- If we find an alias, map it. decl = decl_aliases[decl] elseif not decl_cats[decl] then error("Unrecognized declension class " .. decl) end return decl end return map_decl(decl, do_canon) end -- Attempt to determine the actual declension (including plural variants) -- based on a combination of the declension the user specified, what can be -- detected from the lemma, and special case (1), if given in the declension. -- DECL is the value the user passed for the declension field, after -- extraneous annotations (special cases (1) and (2), * for reducible, -- ё for ё/ё alternation and a ; that may precede ё) have been stripped off. -- What's left is one of the following: -- -- 1. Blank, meaning to autodetect the declension from the lemma -- 2. A hyphen followed by a declension variant (-ья, -ин, -ишко, -ище; see -- long comment at top of file) -- 3. A gender (m, f, n, 3f) -- 4. A gender plus declension variant (e.g. f-ья) -- 5. An actual declension, possibly including a plural variant (e.g. о-и) or -- a slash declension (e.g. я/-ья, used for the noun дядя). -- -- Return seven args: stem (lemma minus ending), translit, canonicalized -- declension, explicitly specified gender if any (m, f, n or nil), whether -- the specified declension or detected ending was accented, whether the -- detected ending was pl, and whether the declension was autodetected -- (corresponds to cases where a full word with ending attached is required -- in the lemma field). "Canonicalized" means after autodetection, with -- accents removed, with any aliases mapped to their canonical versions -- and with any requested declension variants applied. The result is either a -- declension that will have a categorization entry (in declensions_cat[] or -- declensions_old_cat[]) or a slash declension where each part similarly has -- a categorization entry. -- -- Note that gender is never required when an explicit declension is given, -- and in connection with stem autodetection is required only when the lemma -- either ends in -ь or is plural. determine_decl = function(lemma, tr, decl, args) -- Assume we're passed a value for DECL of types 1-4 above, and -- fetch gender and requested declension variant. local stem local want_ya_plural, orig_pl_ending, variant local was_autodetected local gender = rmatch(decl, "^(3?[mfn]?)$") if not gender then gender, variant = rmatch(decl, "^(3?[mfn]?)(%-[^%-]+)$") -- But be careful with explicit declensions like -а that look like -- variants without gender (FIXME, eventually we should maybe do -- something about the potential ambiguity). if gender == "" and not m_table.contains({"-ья", "-ин", "-ишко", "-ище"}, variant) then gender, variant = nil, nil end end -- If DECL is of type 1-4, handle declension variants and detect -- the actual declension from the lemma. if gender then -- Check for declension variants if variant then if variant == "-ья" then want_ya_plural = "-ья" else -- Sanity-check remaining declension variants, which need -- specific values of animacy, gender and special-case (1) local sc1_needed local animate_needed if variant == "-ишко" then animate_needed = false sc1_needed = true elseif variant == "-ище" then animate_needed = true sc1_needed = true elseif variant == "-ин" then animate_needed = true sc1_needed = false else -- WARNING: If adding another variant, you need to also -- add to the list farther above. error("Unrecognized declension variant " .. variant .. ", should be -ья, -ин, -ишко or -ище") end if sc1_needed and not args.want_sc1 then error("Declension variant " .. variant .. " must be used with special case (1)") elseif sc1_needed == false and args.want_sc1 then error("Declension variant " .. variant .. " must not be used with special case (1)") end if animate_needed and args.thisa ~= "a" then error("Declension variant " .. variant .. " must be specified as animate") elseif animate_needed == false and args.thisa == "a" then error("Declension variant " .. variant .. " must not be specified as animate") end if gender ~= "" and gender ~= "m" then error("Declension variant " .. variant .. " should be used with the masculine gender") end end end stem, tr, decl, orig_pl_ending = detect_lemma_type(lemma, tr, gender, args, variant) was_autodetected = true else stem, tr = lemma, tr end -- Now canonicalize gender if gender == "3f" then gender = "f" elseif gender == "" then gender = nil end -- The ending should be treated as accented if either the original singular -- or plural ending was accented, or if the stem is non-syllabic. local was_accented = com.is_stressed(decl) or orig_pl_ending and com.is_stressed(orig_pl_ending) or com.is_nonsyllabic(stem) local was_plural = not not orig_pl_ending decl = canonicalize_decl(decl, args.old) -- The rest of this code concerns plural variants. It's somewhat -- complicated because there are potentially four sources of plural -- variants (not to mention plural variants constructed using slash -- notation): -- -- 1. A user-requested plural variant in declension types 2 or 4 above -- (currently only -ья) -- 2. An explicit plural variant encoded in an explicit declension of -- type 5 above -- 3. An autodetected plural variant (which will happen in some cases -- when autodetection is performed on a nominative plural) -- 4. A plural variant derived using special case (1). -- -- Up to three actual plural variants might exist (e.g. if the user -- specifies a DECL value or 'm-ья(1)' and a STEM ending in -а, -- although not all three can ever be compatible because -ья and (1) -- are never compatible). We can't have all four because if there's -- an explicit plural variant, there won't be a user-requested or -- autodetected plural variant. -- -- The goal below is to do two things: Check that all available plural -- variants are the same, and generate the actual declension. -- If we have a type-2 or type-3 variant, we already have the actual -- declension; else we need to use a table to map the basic declension -- to the one with the plural variant encoded in it. -- -- NOTE: The code below was written with a more general plural-variant -- system. It probably can be simplified a lot now. -- 1: Handle explicit decl with slash variant if rfind(decl, "/") then if want_ya_plural then -- Don't think this can happen error("Plural variant " .. want_ya_plural .. " not compatible with slash declension " .. decl) end if args.want_sc1 then error("Special case (1) not compatible with slash declension" .. decl) end return stem, tr, decl, gender, was_accented, was_plural, was_autodetected end -- 2: Retrieve explicitly specified or autodetected decl and pl. variant local basic_decl, detected_or_explicit_plural = rmatch(decl, "^(.*)(%-[^mf]+)$") if basic_decl == "ь" then basic_decl = "ь-m" end basic_decl = basic_decl or decl -- 3: Any user-requested plural variant must agree with explicit or -- autodetected variant. if want_ya_plural and detected_or_explicit_plural and want_ya_plural ~= detected_or_explicit_plural then error("Plural variant " .. want_ya_plural .. " requested but plural variant " .. detected_or_explicit_plural .. " detected from plural stem") end -- 4: Handle special case (1). Derive the full declension, make sure its -- plural variant matches any other available plural variants, and -- return the declension. if args.want_sc1 then local sc1_decl = special_case_1_to_plural_variant[basic_decl] or error("Special case (1) not compatible with declension " .. basic_decl) local sc1_plural = rsub(sc1_decl, "^.*%-", "-") local other_plural = want_ya_plural or detected_or_explicit_plural if other_plural and sc1_plural ~= other_plural then error("Plural variant " .. other_plural .. " specified or detected, but special case (1) calls for plural variant " .. sc1_plural) end return stem, tr, sc1_decl, gender, was_accented, was_plural, was_autodetected end -- 5: Handle user-requested plural variant without explicit or detected -- one. (If an explicit or detected one exists, we've already checked -- that it agrees with the user-requested one, and so we already have -- our full declension.) if want_ya_plural and not detected_or_explicit_plural then local variant_decl if plural_variant_detection_map[decl] then variant_decl = plural_variant_detection_map[decl][want_ya_plural] end if variant_decl then return stem, tr, variant_decl, gender, was_accented, was_plural, was_autodetected else return stem, tr, decl .. (args.old and "/ъ-ья" or "/-ья"), gender, was_accented, was_plural, was_autodetected end end -- 6: Just return the full declension, which will include any available -- plural variant in it. return stem, tr, decl, gender, was_accented, was_plural, was_autodetected end -- Convert soft adjectival declensions into hard ones following certain -- stem-final consonants. FIXME: We call this in two places, once -- to handle auto-detection and once to handle explicit declensions; but -- in the former case we end up calling it twice. function determine_adj_stem_variant(decl, stem) local iend = rmatch(decl, "^%+[іи]([йея]?)$") -- Convert ій/ий to ый after velar or sibilant. This is important for -- velars; doesn't really matter one way or the other for sibilants as -- the sibilant rules will convert both sets of endings to the same -- thing (whereas there will be a difference with о vs. е for velars). if iend and rfind(stem, "[" .. com.velar .. com.sib .. "]$") then decl = "+ы" .. iend -- The following is necessary for -ц, unclear if makes sense for -- sibilants. (Would be necessary -- I think -- if we were -- inferring short adjective forms, but we're not.) elseif decl == "+ее" and rfind(stem, "[" .. com.sib_c .. "]$") then decl = "+ое" end return decl end -- Attempt to determine the actual adjective declension based on a -- combination of the declension the user specified and what can be detected -- from the stem. DECL is the value the user passed for the declension field, -- after extraneous annotations have been removed (although none are probably -- relevant here). What's left is one of the following, which always begins -- with +: -- -- 1. +, meaning to autodetect the declension from the stem -- 2. +ь, same as + but selects +ьий instead of +ий if lemma ends in -ий -- 3. +short, +mixed or +proper, with the declension partly specified but -- the particular gender/number-specific short/mixed variant to be -- autodetected -- 4. A gender (+m, +f or +n), used only for detecting the singular of -- plural-form lemmas (this is primarily used in conjunction with template -- ru-noun+, to explicitly specify the gender; for the actual declension, -- it doesn't much matter what singular gender we pick since we're a -- plural only) -- 5. A gender plus short/mixed/proper/ь (e.g. +f-mixed), again with the gender -- used only for detecting the singular of plural-form short/mixed lemmas -- 6. An actual declension, possibly including a slash declension -- (WARNING: Unclear if slash declensions will work, especially those -- that are adjective/noun combinations) -- -- Returns the same seven args as for determine_decl(). The returned -- declension will always begin with +. detect_adj_type = function(lemma, tr, decl, old) local was_autodetected local base, ending local basedecl, g = rmatch(decl, "^(%+)([mfn])$") if not basedecl then g, basedecl = rmatch(decl, "^%+([mfn])%-([a-zь]+)$") if basedecl then basedecl = "+" .. basedecl end end decl = basedecl or decl if decl == "+" or decl == "+ь" then base, ending = rmatch(lemma, "^(.*)([ыиіьаяое]́?[йея])$") if ending == "ий" and decl == "+ь" then decl = "+ьий" elseif ending == "ій" and decl == "+ь" then decl = "+ьій" elseif ending then decl = "+" .. ending else base, ending = rmatch(lemma, "^(.-)([оаыъ]?́?)$") assert(base) local shortmixed = rfind(base, "^[" .. com.uppercase .. "].*[иы]́н$") and "stressed-proper" or -- accented rfind(base, "^[" .. com.uppercase .. "].*[иы]н$") and "proper" or --not accented rlfind(base, "[ёео]́?в$") and "short" or rlfind(base, "[ыи]́н$") and "stressed-short" or -- accented rlfind(base, "[ыи]н$") and "mixed" --not accented if not shortmixed then error("Cannot determine stem type of adjective: " .. lemma) end decl = "+" .. ending .. "-" .. shortmixed end was_autodetected = true elseif m_table.contains({"+short", "+mixed", "+proper"}, decl) then base, ending = rmatch(lemma, "^(.-)([оаыъ]?́?)$") assert(base) local shortmixed = usub(decl, 2) if rlfind(base, "[ыи]́н$") then -- accented if shortmixed == "short" then shortmixed = "stressed-short" elseif shortmixed == "proper" then shortmixed = "stressed-proper" end end decl = "+" .. ending .. "-" .. shortmixed was_autodetected = true else base = lemma end if ending and ending ~= "" then tr = com.strip_tr_ending(tr, ending) end -- Remove any accents from the declension, but not their presence. -- We will convert was_accented into stress pattern b, and convert that -- back to an accented version in determine_stress_variant(). This way -- we end up with the stressed version whether the user placed an accent -- in the ending or decl or specified stress pattern b. -- FIXME, might not work in the presence of slash declensions local was_accented = com.is_stressed(decl) decl = com.remove_accents(decl) decl = map_decl(decl, function(decl) return determine_adj_stem_variant(decl, base) end) local singdecl if decl == "+ые" then singdecl = (g == "m" or not g) and (was_accented and "+ой" or "+ый") or not old and g == "f" and "+ая" or not old and g == "n" and "+ое" elseif decl == "+ыя" and old then singdecl = (g == "f" or not g) and "+ая" or g == "n" and "+ое" elseif decl == "+ие" and not old then singdecl = (g == "m" or not g) and "+ий" or g == "f" and "+яя" or g == "n" and "+ее" elseif decl == "+іе" and old and (g == "m" or not g) then singdecl = "+ій" elseif decl == "+ія" and old then singdecl = (g == "f" or not g) and "+яя" or g == "n" and "+ее" elseif decl == "+ьи" then singdecl = (g == "m" or not g) and (old and "+ьій" or "+ьий") or g == "f" and "+ья" or g == "n" and "+ье" elseif rfind(decl, "^%+ы%-") then -- decl +ы-mixed or similar local beg = (g == "m" or not g) and (old and "ъ" or "") or g == "f" and "а" or g == "n" and "о" singdecl = beg and "+" .. beg .. usub(decl, 3) end if singdecl then was_plural = true decl = singdecl end return base, tr, canonicalize_decl(decl, old), g, was_accented, was_plural, was_autodetected end -- If stress pattern omitted, detect it based on whether ending is stressed -- or the decl class or stem accent calls for inherent stress, defaulting to -- pattern a. This is run after alias resolution and accent removal of DECL; -- WAS_ACCENTED indicates whether the ending was originally stressed. -- FIXME: This is run before splitting slash patterns but should be run after. detect_stress_pattern = function(stem, decl, decl_cats, reducible, was_plural, was_accented) -- ёнок and ёночек always bear stress if rfind(decl, "ёнокъ?") or rfind(decl, "ёночекъ?") then return "b" -- stressed suffix и́н; missing in plural and true endings don't bear stress -- (except for exceptional господи́н) elseif rfind(decl, "инъ?") and was_accented then return "d" -- Adjectival -ой always bears the stress elseif rfind(decl, "%+ой") then return "b" -- Adjectival stressed-short, stressed-proper bears the stress elseif rfind(decl, "^%+.*%-stressed") then return "b" -- Pattern b if ending was accented by user elseif was_accented then return "b" -- Nonsyllabic stem means pattern b elseif com.is_nonsyllabic(stem) then return "b" -- Accent on reducible vowel in masc nom sg (not plural) means pattern b. -- Think about whether we want to enable this. -- elseif reducible and not was_plural then -- -- FIXME hack. Eliminate plural part of slash declension. -- decl = rsub(decl, "/.*", "") -- if decl_cats[decl] and decl_cats[decl].g == "m" then -- if com.is_ending_stressed(stem) or com.is_monosyllabic(stem) then -- return "b" -- end -- end end return "a" end -- In certain special cases, depending on the declension, we override the -- user-specified stress pattern and convert it to something else. -- NOTE: This function is run after alias resolution and accent removal. -- FIXME: It's also run before splitting slash patterns but should be run after. override_stress_pattern = function(decl, stress) -- ёнок and ёночек always bear stress; if user specified a, -- convert to b. Don't do this with slash patterns (see FIXME above). if stress == "a" and (rfind(decl, "^ёнокъ?$") or rfind(decl, "^ёночекъ?$")) then return "b" end return stress end -- Canonicalize an adjectival declension to either the stressed or unstressed -- variant depending on the stress. Ultimately this is what ensures that -- the user's stress mark on an adjectival ending is respected. determine_stress_variant = function(decl, stress) if stress == "b" then if decl == "+ая" then return "+а́я" elseif decl == "+ое" then return "+о́е" else -- Convert +...-short to +...-stressed-short and same for -proper local b, e = rmatch(decl, "^%+(.*)%-(short)$") if not b then b, e = rmatch(decl, "^%+(.*)%-(proper)$") end if b and not rfind(b, "%-stressed") then return "+" .. b .. "-stressed-" .. e end end end return decl end -- Canonicalize a declension based on the final stem consonant, in -- particular converting soft declensions to hard ones after velars and/or -- sibilants. FIXME: We also do this canonicalization earlier on during -- auto-detection (determine_adj_stem_variant() is called by -- detect_adj_type(), and code in detect_lemma_type() does the equivalent -- of the first clause below). Doing it here ensures that explicitly -- specified declensions get handled as well, but it would be nice to not -- do the same thing twice in the auto-detection case. determine_stem_variant = function(decl, stem) if decl == "е" and rfind(stem, "[" .. com.sib_c .. "]$") then return "о" end return determine_adj_stem_variant(decl, stem) end is_reducible = function(decl_cat) if decl_cat.suffix or decl_cat.cant_reduce or decl_cat.adj then return false elseif decl_cat.decl == "3rd" and decl_cat.g == "f" or decl_cat.g == "m" then return true else return false end end -- Reduce nom sg to stem by eliminating the "epenthetic" vowel. Applies to -- masculine 2nd-declension hard and soft, and 3rd-declension feminine in -- -ь. STEM and DECL are after determine_decl(), before converting -- outward-facing declensions to inward ones. function export.reduce_nom_sg_stem(stem, tr, decl, can_err) local full_stem = stem .. (decl == "й" and decl or "") local full_tr = tr and tr .. (decl == "й" and "j" or "") local ret, rettr = com.reduce_stem(full_stem, full_tr) if not ret and can_err then error("Unable to reduce stem " .. stem) end return ret, rettr end is_dereducible = function(decl_cat) if decl_cat.suffix or decl_cat.cant_reduce or decl_cat.adj then return false elseif decl_cat.decl == "1st" or decl_cat.decl == "2nd" and decl_cat.g == "n" then return true else return false end end -- Add a possible suffix to the bare stem, according to the declension and -- value of OLD. This may be -ь, -ъ, -й or nothing. We need to do this here -- because we don't actually attach such a suffix in attach_unstressed() due -- to situations where we don't want the suffix added, e.g. dereducible nouns -- in -ня. add_bare_suffix = function(bare, baretr, old, sgdc, dereduced) if old and sgdc.hard == "hard" then -- Final -ъ isn't transliterated return bare .. "ъ", baretr elseif sgdc.hard == "soft" or sgdc.hard == "palatal" then -- This next clause corresponds to a special case in Vitalik's module. -- It says that nouns in -ня (accent class a) have gen pl without -- trailing -ь. It appears to apply to most nouns in -ня (possibly -- all in -льня), but ку́хня (gen pl ку́хонь) and дерéвня (gen pl -- дереве́нь) is an exception. (Vitalik's module has an extra -- condition here 'stress == "a"' that would exclude дере́вня but I -- don't think this condition is in Zaliznyak, as he indicates -- дере́вня as having an exceptional genitive plural.) if dereduced and rfind(bare, "[нН]$") and sgdc.decl == "1st" then -- FIXME: What happens in this case old-style? I assume that -- -ъ is added, but this is a guess. -- Final -ъ isn't transliterated return bare .. (old and "ъ" or ""), baretr elseif rfind(bare, "[" .. com.vowel .. "]́?$") then return bare .. "й", baretr and (baretr .. "j") else return bare .. "ь", baretr and (baretr .. "ʹ") end else return bare, baretr end end -- Dereduce stem to the form found in the gen pl (and maybe nom sg) by -- inserting an epenthetic vowel. Applies to 1st declension and 2nd -- declension neuter, and to 2nd declension masculine when the stem was -- specified as a plural form (in which case we're deriving the nom sg, -- and also the gen pl in the alt-gen-pl scenario). STEM and DECL are -- after determine_decl(), before converting outward-facing declensions -- to inward ones. STRESS is the stess pattern. function export.dereduce_nom_sg_stem(stem, tr, sgdc, stress, old, can_err) local epenthetic_stress = ending_stressed_gen_pl_patterns[stress] local ret, rettr = com.dereduce_stem(stem, tr, epenthetic_stress) if not ret then if can_err then error("Unable to dereduce stem " .. stem) else return nil, nil end end return add_bare_suffix(ret, rettr, old, sgdc, true) end -------------------------------------------------------------------------- -- Second-declension masculine -- -------------------------------------------------------------------------- ----------------- Masculine hard ------------------- -- Hard-masculine declension, ending in a hard consonant -- (ending in -ъ, old-style). declensions_old["ъ"] = { ["nom_sg"] = "ъ", ["gen_sg"] = "а́", ["dat_sg"] = "у́", ["acc_sg"] = nil, ["ins_sg"] = "о́мъ", ["pre_sg"] = "ѣ́", ["nom_pl"] = "ы́", ["gen_pl"] = function(stem, stress) return nom.sibilant_suffixes[ulower(usub(stem, -1))] and "е́й" or "о́въ" end, ["alt_gen_pl"] = "ъ", ["dat_pl"] = "а́мъ", ["acc_pl"] = nil, ["ins_pl"] = "а́ми", ["pre_pl"] = "а́хъ", } declensions_old_cat["ъ"] = { decl="2nd", hard="hard", g="m" } -- Normal mapping of old ъ would be "" (blank), but we set up "#" as an alias -- so we have a way of referring to it without defaulting if need be and -- distinct from auto-detection (e.g. in the second stem of a word, or to -- override autodetection of -ёнок or -ин -- the latter is necessary in the -- case of семьянин). declensions_aliases["#"] = "" ----------------- Masculine hard, irregular plural ------------------- -- Hard-masculine declension, ending in a hard consonant -- (ending in -ъ, old-style), with irreg nom pl -а. declensions_old["ъ-а"] = mw.clone(declensions_old["ъ"]) declensions_old["ъ-а"]["nom_pl"] = "а́" declensions_old_cat["ъ-а"] = { decl="2nd", hard="hard", g="m", alt_nom_pl=true } declensions_aliases["#-a"] = "-a" -- Hard-masculine declension, ending in a hard consonant -- (ending in -ъ, old-style), with irreg soft pl -ья. -- Differs from the normal declension throughout the plural. declensions_old["ъ-ья"] = { ["nom_sg"] = "ъ", ["gen_sg"] = "а́", ["dat_sg"] = "у́", ["acc_sg"] = nil, ["ins_sg"] = "о́мъ", ["pre_sg"] = "ѣ́", ["nom_pl"] = "ья́", ["gen_pl"] = "ьёвъ", ["alt_gen_pl"] = "е́й", ["dat_pl"] = "ья́мъ", ["acc_pl"] = nil, ["ins_pl"] = "ья́ми", ["pre_pl"] = "ья́хъ", } declensions_old_cat["ъ-ья"] = { decl="2nd", hard="hard", g="m", irregpl=true } declensions_aliases["#-ья"] = "-ья" ----------------- Masculine hard, suffixed, irregular plural ------------------- declensions_old["инъ"] = { ["nom_sg"] = "и́нъ", ["gen_sg"] = "и́на", ["dat_sg"] = "и́ну", ["acc_sg"] = nil, ["ins_sg"] = "и́номъ", ["pre_sg"] = "и́нѣ", ["nom_pl"] = "е́", ["gen_pl"] = "ъ", ["dat_pl"] = "а́мъ", ["acc_pl"] = nil, ["ins_pl"] = "а́ми", ["pre_pl"] = "а́хъ", } declensions_old_cat["инъ"] = { decl="2nd", hard="hard", g="m", suffix=true } declensions_old["ёнокъ"] = { ["nom_sg"] = "ёнокъ", ["gen_sg"] = "ёнка", ["dat_sg"] = "ёнку", ["acc_sg"] = nil, ["ins_sg"] = "ёнкомъ", ["pre_sg"] = "ёнкѣ", ["nom_pl"] = "я́та", ["gen_pl"] = "я́тъ", ["dat_pl"] = "я́тамъ", ["acc_pl"] = nil, ["ins_pl"] = "я́тами", ["pre_pl"] = "я́тахъ", } declensions_old_cat["ёнокъ"] = { decl="2nd", hard="hard", g="m", suffix=true } declensions_old_aliases["онокъ"] = "ёнокъ" declensions_old_aliases["енокъ"] = "ёнокъ" declensions_old["ёночекъ"] = { ["nom_sg"] = "ёночекъ", ["gen_sg"] = "ёночка", ["dat_sg"] = "ёночку", ["acc_sg"] = nil, ["ins_sg"] = "ёночкомъ", ["pre_sg"] = "ёночкѣ", ["nom_pl"] = "я́тки", ["gen_pl"] = "я́токъ", ["dat_pl"] = "я́ткамъ", ["acc_pl"] = nil, ["ins_pl"] = "я́тками", ["pre_pl"] = "я́ткахъ", } declensions_old_cat["ёночекъ"] = { decl="2nd", hard="hard", g="m", suffix=true } declensions_old_aliases["оночекъ"] = "ёночекъ" declensions_old_aliases["еночекъ"] = "ёночекъ" ----------------- Masculine soft ------------------- -- Normal soft-masculine declension in -ь declensions_old["ь-m"] = { ["nom_sg"] = "ь", ["gen_sg"] = "я́", ["dat_sg"] = "ю́", ["acc_sg"] = nil, ["ins_sg"] = "ёмъ", ["pre_sg"] = "ѣ́", ["nom_pl"] = "и́", ["gen_pl"] = "е́й", ["alt_gen_pl"] = "ь", ["dat_pl"] = "я́мъ", ["acc_pl"] = nil, ["ins_pl"] = "я́ми", ["pre_pl"] = "я́хъ", } declensions_old_cat["ь-m"] = { decl="2nd", hard="soft", g="m" } -- Soft-masculine declension in -ь with irreg nom pl -я declensions_old["ь-я"] = mw.clone(declensions_old["ь-m"]) declensions_old["ь-я"]["nom_pl"] = "я́" declensions_old_cat["ь-я"] = { decl="2nd", hard="soft", g="m", alt_nom_pl=true } ----------------- Masculine palatal ------------------- -- Masculine declension in palatal -й declensions_old["й"] = { ["nom_sg"] = "й", ["gen_sg"] = "я́", ["dat_sg"] = "ю́", ["acc_sg"] = nil, ["ins_sg"] = "ёмъ", ["pre_sg"] = function(stem, stress) return rlfind(stem, "[іи]́?$") and not ending_stressed_pre_sg_patterns[stress] and "и" or "ѣ́" end, ["nom_pl"] = "и́", ["gen_pl"] = "ёвъ", ["alt_gen_pl"] = "й", ["dat_pl"] = "я́мъ", ["acc_pl"] = nil, ["ins_pl"] = "я́ми", ["pre_pl"] = "я́хъ", } declensions_old_cat["й"] = { decl="2nd", hard="palatal", g="m" } declensions_old["й-я"] = mw.clone(declensions_old["й"]) declensions_old["й-я"]["nom_pl"] = "я́" declensions_old_cat["й-я"] = { decl="2nd", hard="palatal", g="m", alt_nom_pl=true } -------------------------------------------------------------------------- -- First-declension feminine -- -------------------------------------------------------------------------- ----------------- Feminine hard ------------------- -- Hard-feminine declension in -а declensions_old["а"] = { ["nom_sg"] = "а́", ["gen_sg"] = "ы́", ["dat_sg"] = "ѣ́", ["acc_sg"] = "у́", ["ins_sg"] = {"о́й<insa>", "о́ю<insb>"}, -- see concat_word_forms_1() ["pre_sg"] = "ѣ́", ["nom_pl"] = "ы́", ["gen_pl"] = function(stem, stress) return nom.sibilant_suffixes[ulower(usub(stem, -1))] and ending_stressed_gen_pl_patterns[stress] and "е́й" or "ъ" end, ["alt_gen_pl"] = "е́й", ["dat_pl"] = "а́мъ", ["acc_pl"] = nil, ["ins_pl"] = "а́ми", ["pre_pl"] = "а́хъ", } declensions_old_cat["а"] = { decl="1st", hard="hard", g="f" } ----------------- Feminine soft ------------------- -- Soft-feminine declension in -я declensions_old["я"] = { ["nom_sg"] = "я́", ["gen_sg"] = "и́", ["dat_sg"] = function(stem, stress) return rlfind(stem, "[іи]́?$") and not ending_stressed_dat_sg_patterns[stress] and "и" or "ѣ́" end, ["acc_sg"] = "ю́", ["ins_sg"] = {"ёй<insa>", "ёю<insb>"}, -- see concat_word_forms_1() ["pre_sg"] = function(stem, stress) return rlfind(stem, "[іи]́?$") and not ending_stressed_pre_sg_patterns[stress] and "и" or "ѣ́" end, ["nom_pl"] = "и́", ["gen_pl"] = function(stem, stress) return ending_stressed_gen_pl_patterns[stress] and not rlfind(stem, "[" .. com.vowel .. "]́?$") and "е́й" or "й" end, ["alt_gen_pl"] = "е́й", ["dat_pl"] = "я́мъ", ["acc_pl"] = nil, ["ins_pl"] = "я́ми", ["pre_pl"] = "я́хъ", } declensions_old_cat["я"] = { decl="1st", hard="soft", g="f" } -- Soft-feminine declension in -ья. -- Almost like ь + -я endings except for genitive plural. declensions_old["ья"] = { ["nom_sg"] = "ья́", ["gen_sg"] = "ьи́", ["dat_sg"] = "ьѣ́", ["acc_sg"] = "ью́", ["ins_sg"] = {"ьёй<insa>", "ьёю<insb>"}, -- see concat_word_forms_1() ["pre_sg"] = "ьѣ́", ["nom_pl"] = "ьи́", ["gen_pl"] = function(stem, stress) -- circumflex accent is a signal that forces stress, particularly -- in accent pattern d/d'. return (ending_stressed_gen_pl_patterns[stress] or stress == "d" or stress == "d'") and "е̂й" or "ий" end, ["dat_pl"] = "ья́мъ", ["acc_pl"] = nil, ["ins_pl"] = "ья́ми", ["pre_pl"] = "ья́хъ", } declensions_old_cat["ья"] = { decl="1st", hard="soft", g="f", stem_suffix="ь", gensg=true, ignore_reduce=true -- already has dereduced gen pl } -------------------------------------------------------------------------- -- Second-declension neuter -- -------------------------------------------------------------------------- ----------------- Neuter hard ------------------- -- Normal hard-neuter declension in -о declensions_old["о"] = { ["nom_sg"] = "о́", ["gen_sg"] = "а́", ["dat_sg"] = "у́", ["acc_sg"] = function(stem, stress, args) return not (args.explicit_gender == "m" and args.thisa == "a") and "о́" or nil end, ["ins_sg"] = "о́мъ", ["pre_sg"] = "ѣ́", ["nom_pl"] = "а́", ["gen_pl"] = function(stem, stress) return nom.sibilant_suffixes[ulower(usub(stem, -1))] and ending_stressed_gen_pl_patterns[stress] and "е́й" or "ъ" end, ["alt_gen_pl"] = "о́въ", ["dat_pl"] = "а́мъ", ["acc_pl"] = nil, ["ins_pl"] = "а́ми", ["pre_pl"] = "а́хъ", } declensions_old_cat["о"] = { decl="2nd", hard="hard", g="n" } -- Hard-neuter declension in -о with irreg nom pl -и declensions_old["о-и"] = mw.clone(declensions_old["о"]) declensions_old["о-и"]["nom_pl"] = "ы́" declensions_old_cat["о-и"] = { decl="2nd", hard="hard", g="n", alt_nom_pl=true } declensions_old_aliases["о-ы"] = "о-и" -- Masculine-gender neuter-form declension in -(ишк)о with irreg nom pl -и, -- with colloquial feminine endings in some of the singular cases -- (§5 p. 74 of Zaliznyak) declensions_old["(ишк)о-и"] = mw.clone(declensions_old["о-и"]) declensions_old["(ишк)о-и"]["gen_sg"] = {"а́", "ы́1"} declensions_old["(ишк)о-и"]["dat_sg"] = {"у́", "ѣ́1"} declensions_old["(ишк)о-и"]["ins_sg"] = {"о́мъ", "о́й1"} declensions_old_cat["(ишк)о-и"] = { decl="2nd", hard="hard", g="n", colloqfem=true, alt_nom_pl=true } internal_notes_table_old["(ишк)о-и"] = "<sup>1</sup> Colloquial." -- Masculine-gender animate neuter-form declension in -(ищ)е with irreg -- nom pl -и, with colloquial feminine endings in some of the singular cases -- (§4 p. 74 of Zaliznyak) declensions_old["(ищ)е-и"] = mw.clone(declensions_old["о-и"]) declensions_old["(ищ)е-и"]["acc_sg"] = {"а́", "у́1"} declensions_old["(ищ)е-и"]["gen_sg"] = {"а́", "ы́2"} declensions_old["(ищ)е-и"]["dat_sg"] = {"у́", "ѣ́2"} declensions_old["(ищ)е-и"]["ins_sg"] = {"о́мъ", "о́й2"} declensions_old_cat["(ищ)е-и"] = { decl="2nd", hard="hard", g="n", colloqfem=true, alt_nom_pl=true } internal_notes_table_old["(ищ)е-и"] = "<sup>1</sup> Colloquial.<br /><sup>2</sup> Less common, more colloquial." ----------------- Neuter soft ------------------- -- Soft-neuter declension in -е (stressed -ё) declensions_old["е"] = { ["nom_sg"] = "ё", ["gen_sg"] = "я́", ["dat_sg"] = "ю́", ["acc_sg"] = function(stem, stress, args) return not (args.explicit_gender == "m" and args.thisa == "a") and "ё" or nil end, ["ins_sg"] = "ёмъ", ["pre_sg"] = function(stem, stress) return rlfind(stem, "[іи]́?$") and not ending_stressed_pre_sg_patterns[stress] and "и" or "ѣ́" end, ["nom_pl"] = "я́", ["gen_pl"] = function(stem, stress) return ending_stressed_gen_pl_patterns[stress] and not rlfind(stem, "[" .. com.vowel .. "]́?$") and "е́й" or "й" end, ["alt_gen_pl"] = "ёвъ", ["dat_pl"] = "я́мъ", ["acc_pl"] = nil, ["ins_pl"] = "я́ми", ["pre_pl"] = "я́хъ", } declensions_old_cat["е"] = { singular = function(suffix) if suffix == "ё" then return "ending in -ё" else return {} end end, decl="2nd", hard="soft", g="n", gensg=true } -- User-facing declension type "ё" = "е" declensions_old_aliases["ё"] = "е" -- Rare soft-neuter declension in stressed -е́ (e.g. муде́, бытие́) declensions_old["е́"] = { ["nom_sg"] = "е́", ["gen_sg"] = "я́", ["dat_sg"] = "ю́", ["acc_sg"] = function(stem, stress, args) return not (args.explicit_gender == "m" and args.thisa == "a") and "е́" or nil end, ["ins_sg"] = "е́мъ", ["pre_sg"] = function(stem, stress) -- FIXME!!! Are we sure about this condition? This is what was -- found in the old template, but the related -е declension has -- -ие prep sg ending -(и)и only when *not* stressed. return rlfind(stem, "[іи]́?$") and "и́" or "ѣ́" end, ["nom_pl"] = "я́", ["gen_pl"] = function(stem, stress) return rlfind(stem, "[" .. com.vowel .. "]́?$") and "й" or "е́й" end, ["alt_gen_pl"] = "ёвъ", ["dat_pl"] = "я́мъ", ["acc_pl"] = nil, ["ins_pl"] = "я́ми", ["pre_pl"] = "я́хъ", } declensions_old_cat["е́"] = { singular = "ending in stressed -е", decl="2nd", hard="soft", g="n", gensg=true } -- Soft-neuter declension in unstressed -ье (stressed -ьё). declensions_old["ье"] = { ["nom_sg"] = "ьё", ["gen_sg"] = "ья́", ["dat_sg"] = "ью́", ["acc_sg"] = function(stem, stress, args) return not (args.explicit_gender == "m" and args.thisa == "a") and "ьё" or nil end, ["ins_sg"] = "ьёмъ", ["pre_sg"] = "ьѣ́", ["nom_pl"] = "ья́", ["gen_pl"] = function(stem, stress) return ending_stressed_gen_pl_patterns[stress] and "е́й" or "ий" end, ["alt_gen_pl"] = "ьёвъ", ["dat_pl"] = "ья́мъ", ["acc_pl"] = nil, ["ins_pl"] = "ья́ми", ["pre_pl"] = "ья́хъ", } declensions_old_cat["ье"] = { decl="2nd", hard="soft", g="n", stem_suffix="ь", gensg=true, ignore_reduce=true -- already has dereduced gen pl } declensions_old_aliases["ьё"] = "ье" -------------------------------------------------------------------------- -- Third declension -- -------------------------------------------------------------------------- declensions_old["ь-f"] = { ["nom_sg"] = "ь", ["gen_sg"] = "и́", ["dat_sg"] = "и́", ["acc_sg"] = "ь", ["ins_sg"] = "ью́", ["pre_sg"] = "и́", ["nom_pl"] = "и́", ["gen_pl"] = "е́й", ["dat_pl"] = "я́мъ", ["acc_pl"] = nil, ["ins_pl"] = "я́ми", ["pre_pl"] = "я́хъ", } declensions_old_cat["ь-f"] = { decl="3rd", hard="soft", g="f" } declensions_old["мя"] = { ["nom_sg"] = "мя", ["gen_sg"] = "мени", ["dat_sg"] = "мени", ["acc_sg"] = nil, ["ins_sg"] = "менемъ", ["pre_sg"] = "мени", ["nom_pl"] = "мена́", ["gen_pl"] = "мёнъ", ["dat_pl"] = "мена́мъ", ["acc_pl"] = nil, ["ins_pl"] = "мена́ми", ["pre_pl"] = "мена́хъ", } declensions_old_cat["мя"] = { decl="3rd", hard="soft", g="n", cant_reduce=true } -------------------------------------------------------------------------- -- Indeclinable -- -------------------------------------------------------------------------- -- Indeclinable declension; no endings. declensions_old["$"] = { ["nom_sg"] = "", ["gen_sg"] = "", ["dat_sg"] = "", ["acc_sg"] = nil, ["ins_sg"] = "", ["pre_sg"] = "", ["nom_pl"] = "", ["gen_pl"] = "", ["dat_pl"] = "", ["acc_pl"] = nil, ["ins_pl"] = "", ["pre_pl"] = "", } declensions_old_cat["$"] = { decl="indeclinable", hard="none", g="none" } -------------------------------------------------------------------------- -- Adjectival -- -------------------------------------------------------------------------- -- This needs to be up here because it is called just below. local function old_to_new(v) v = rsub(v, "ъ$", "") v = rsub(v, "^ъ", "") v = rsub(v, "(%A)ъ", "%1") v = rsub(v, "ъ(%A)", "%1") v = rsub(v, "і", "и") v = rsub(v, "ѣ", "е") return v end -- Meaning of entry is: -- 1. The declension name in module ru-adjective -- 2. The masculine declension name in this module -- 3. The neuter declension name in this module -- 4. The feminine declension name in this module -- 5. The value of hard= for the declensions_cat entry -- 6. The value of decl= for the declensions_cat entry -- 7. The value of possadj= for the declensions_cat entry (true if possessive -- or similar type of adjective) local adj_decl_map = { {"ый", "ый", "ое", "ая", "hard", "long", false}, {"ій", "ій", "ее", "яя", "soft", "long", false}, {"ой", "ой", "о́е", "а́я", "hard", "long", false}, {"ьій", "ьій", "ье", "ья", "palatal", "long", true}, {"short", "ъ-short", "о-short", "а-short", "hard", "short", true}, {"mixed", "ъ-mixed", "о-mixed", "а-mixed", "hard", "mixed", true}, {"proper", "ъ-proper", "о-proper", "а-proper", "hard", "proper", true}, {"stressed-short", "ъ-stressed-short", "о-stressed-short", "а-stressed-short", "hard", "short", true}, {"stressed-proper", "ъ-stressed-proper", "о-stressed-proper", "а-stressed-proper", "hard", "proper", true}, } local function get_adjectival_decl(adjtype, gender, old) local decl, intnotes = m_ru_adj.get_nominal_decl(adjtype, gender, old) -- hack fem ins_sg to insert <insa>, <insb>; see concat_word_forms_1() if gender == "f" and type(decl["ins_sg"]) == "table" and #decl["ins_sg"] == 2 then decl["ins_sg"][1] = decl["ins_sg"][1] .. "<insa>" decl["ins_sg"][2] = decl["ins_sg"][2] .. "<insb>" end return decl, intnotes end for _, declspec in ipairs(adj_decl_map) do local oadjdecl = declspec[1] local nadjdecl = old_to_new(oadjdecl) local odecl_by_gender = {m="+" .. declspec[2], n="+" .. declspec[3], f="+" .. declspec[4]} local hard = declspec[5] local decltype = declspec[6] local possadj = declspec[7] for _, g in ipairs({"m", "n", "f"}) do local odecl = odecl_by_gender[g] local ndecl = old_to_new(odecl) declensions_old[odecl], internal_notes_table_old[odecl] = get_adjectival_decl(oadjdecl, g, true) declensions[ndecl], internal_notes_table[ndecl] = get_adjectival_decl(nadjdecl, g, false) declensions_old_cat[odecl] = { decl=decltype, hard=hard, g=g, adj=true, possadj=possadj } declensions_cat[ndecl] = { decl=decltype, hard=hard, g=g, adj=true, possadj=possadj } end end -- Set up some aliases. declensions_old_aliases["+о́-short"] = "+о-stressed-short" declensions_old_aliases["+а́-short"] = "+а-stressed-short" declensions_old_aliases["+о́-proper"] = "+о-stressed-proper" declensions_old_aliases["+а́-proper"] = "+а-stressed-proper" declensions_aliases["+#-short"] = "+-short" declensions_aliases["+#-mixed"] = "+-mixed" declensions_aliases["+#-proper"] = "+-proper" declensions_aliases["+#-stressed-short"] = "+-stressed-short" declensions_aliases["+#-stressed-proper"] = "+-stressed-proper" -------------------------------------------------------------------------- -- Populate new from old -- -------------------------------------------------------------------------- -- Function to convert an entry in an old declensions table to new. local function old_decl_entry_to_new(v) if not v then return nil elseif type(v) == "table" then local new_entry = {} for _, i in ipairs(v) do table.insert(new_entry, old_decl_entry_to_new(i)) end return new_entry elseif type(v) == "function" then return function(stem, suffix, args) return old_decl_entry_to_new(v(stem, suffix, args)) end else return old_to_new(v) end end -- Function to convert an old declensions table to new. local function old_decl_to_new(odecl) local ndecl = {} for k, v in pairs(odecl) do ndecl[k] = old_decl_entry_to_new(v) end return ndecl end -- Function to convert an entry in an old declensions_cat table to new. local function old_decl_cat_entry_to_new(odecl_cat_entry) if not odecl_cat_entry then return nil elseif type(odecl_cat_entry) == "function" then return function(suffix) return old_decl_cat_entry_to_new(odecl_cat_entry(suffix)) end elseif type(odecl_cat_entry) == "table" then local ndecl_cat_entry = {} for k, v in pairs(odecl_cat_entry) do ndecl_cat_entry[k] = old_decl_cat_entry_to_new(v) end return ndecl_cat_entry elseif type(odecl_cat_entry) == "boolean" then return odecl_cat_entry else assert(type(odecl_cat_entry) == "string") return old_to_new(odecl_cat_entry) end end -- Function to convert an old declensions_cat table to new. local function old_decl_cat_to_new(odeclcat) local ndeclcat = {} for k, v in pairs(odeclcat) do ndeclcat[k] = old_decl_cat_entry_to_new(v) end return ndeclcat end -- populate declensions[] from declensions_old[] for odecltype, odecl in pairs(declensions_old) do local ndecltype = old_to_new(odecltype) if not declensions[ndecltype] then declensions[ndecltype] = old_decl_to_new(odecl) end end -- populate declensions_cat[] from declensions_old_cat[] for odecltype, odeclcat in pairs(declensions_old_cat) do local ndecltype = old_to_new(odecltype) if not declensions_cat[ndecltype] then declensions_cat[ndecltype] = old_decl_cat_to_new(odeclcat) end end -- populate declensions_aliases[] from declensions_old_aliases[] for ofrom, oto in pairs(declensions_old_aliases) do local from = old_to_new(ofrom) if not declensions_aliases[from] then declensions_aliases[from] = old_to_new(oto) end end -- populate internal_notes_table[] from internal_notes_table_old[] for odecl, note in pairs(internal_notes_table_old) do local ndecl = old_to_new(odecl) if not internal_notes_table[ndecl] then -- FIXME, should we be calling old_to_new() here? internal_notes_table[ndecl] = note end end -------------------------------------------------------------------------- -- Inflection functions -- -------------------------------------------------------------------------- -- Attach the stressed stem (or plural stem, or barestem) out of ARGS -- to the unstressed suffix SUF, modifying the suffix as necessary for the -- last letter of the stem (e.g. if it is velar, sibilant or ц). CASE is -- the case form being created and is used to select the plural stem if -- needed. Returns two values, the combined form and the modified suffix. local function attach_unstressed(args, case, suf, was_stressed) if suf == nil then return nil, nil elseif rfind(suf, CFLEX) then -- if suf has circumflex accent, it forces stressed return attach_stressed(args, case, suf) end local stem, tr if rfind(case, "_pl") then stem, tr = args.pl, args.pltr end if not stem and case == "ins_sg" then stem, tr = args.ins_sg_stem, args.ins_sg_tr end if not stem then stem, tr = args.stem, args.stemtr end if nom.nonsyllabic_suffixes[suf] then -- If gen_pl, use special args.gen_pl_bare if given, else regular -- args.bare if there isn't a plural stem. If nom_sg, always use -- regular args.bare. local barearg, bareargtr if case == "gen_pl" then barearg, bareargtr = args.gen_pl_bare, args.gen_pl_baretr if not barearg and args.pl == args.stem then barearg, bareargtr = args.bare, args.baretr end else barearg, bareargtr = args.bare, args.baretr end local barestem = barearg or stem local barestem, baretr if barearg then barestem, baretr = barearg, bareargtr else barestem, baretr = stem, tr end if was_stressed and case == "gen_pl" then if not barearg then local gen_pl_stem, gen_pl_tr = com.make_ending_stressed(stem, tr) barestem, baretr = gen_pl_stem, gen_pl_tr end end if rlfind(barestem, "[йьъ]$") then suf = "" else if suf == "ъ" then -- OK elseif suf == "й" or suf == "ь" then if barearg and case == "gen_pl" then -- explicit bare or reducible, don't add -ь suf = "" elseif rfind(barestem, "[" .. com.vowel .. "]́?$") then -- not reducible, do add -ь and correct to -й if necessary suf = "й" else suf = "ь" end end end return com.concat_russian_tr(barestem, baretr, suf, nil, "dopair"), suf end suf = com.make_unstressed(suf) local rules = nom.unstressed_rules[ulower(usub(stem, -1))] return nom.combine_stem_and_suffix(stem, tr, suf, rules, args.old) end -- Analogous to attach_unstressed() but for the unstressed stem and a -- stressed suffix. attach_stressed = function(args, case, suf) if suf == nil then return nil, nil end -- circumflex forces stress even when the accent pattern calls for no stress suf = rsub(suf, "̂", "́") if not rfind(suf, "[ё́]") then -- if suf has no "ё" or accent marks return attach_unstressed(args, case, suf, "was stressed") end local stem, tr if rfind(case, "_pl") then stem, tr = args.upl, args.upltr end if not stem then stem, tr = args.ustem, args.ustemtr end local rules = nom.stressed_rules[ulower(usub(stem, -1))] return nom.combine_stem_and_suffix(stem, tr, suf, rules, args.old) end -- Attach the appropriate stressed or unstressed stem (or plural stem as -- determined by CASE, or barestem) out of ARGS to the suffix SUF, which may -- be a list of alternative suffixes (e.g. in the inst sg of feminine nouns). -- Calls FUN (either attach_stressed() or attach_unstressed()) to do the work -- for an individual suffix. Returns two values, a list of combined forms -- and a list of the real suffixes used (which may be modified from the -- passed-in suffixes, e.g. by removing stress marks or modifying vowels in -- various ways after a stem-final velar, sibilant or ц). Each combined form -- is a two-element list {stem, tr} (or a one-element list if tr is nil). -- IRREG is true if this is an irregular form. We are handling the Nth word; -- ISLAST is true if this is the last one. local function attach_with(args, case, suf, fun, irreg, n, islast) if type(suf) == "table" then local all_combineds = {} local all_realsufs = {} for _, x in ipairs(suf) do local combineds, realsufs = attach_with(args, case, x, fun, irreg, n, islast) for _, combined in ipairs(combineds) do table.insert(all_combineds, combined) end for _, realsuf in ipairs(realsufs) do table.insert(all_realsufs, realsuf) end end return all_combineds, all_realsufs else local combined, realsuf = fun(args, case, suf) local irregsuf = irreg and {IRREGMARKER} or {""} return {combined and com.concat_paired_russian_tr( com.concat_paired_russian_tr(args["prefix" .. n], combined), com.concat_paired_russian_tr(args["suffix" .. n], irregsuf)) or nil}, {realsuf and realsuf .. args["suffix" .. n][1] or nil} end end -- Generate the form(s) and suffix(es) for CASE according to the declension -- table DECL, using the attachment function FUN (one of attach_stressed() -- or attach_unstressed()). IS_SLASH is true if this is a slash declension -- (different declensions for singular and plural). We are handling the Nth -- word; ISLAST is true if this is the last one. local function gen_form(args, decl, case, stress, fun, is_slash, n, islast) local irreg = false if not args.suffixes[case] then args.suffixes[case] = {} end local decl_sufs = args.old and declensions_old or declensions decl_sufs = decl_sufs[decl] local suf = decl_sufs[case] local decl_cats = args.old and declensions_old_cat or declensions_cat local ispl = rfind(case, "_pl") if ispl and (decl_cats[decl].irregpl or args.pl and args.pl ~= args.stem or is_slash) then irreg = true end if case == "nom_pl" and decl_cats[decl].alt_nom_pl then irreg = true end if type(suf) == "function" then suf = suf(ispl and args.pl or args.stem, stress, args) end if case == "gen_pl" and args.alt_gen_pl then suf = decl_sufs.alt_gen_pl irreg = true if not suf then error("No alternate genitive plural available for this declension class") end end local combineds, realsufs = attach_with(args, case, suf, fun, irreg, n, islast) for _, realsuf in ipairs(realsufs) do args.any_non_nil[case] = true args.this_any_non_nil[case] = true insert_if_not(args.suffixes[case], realsuf) end return combineds end local attachers = { ["+"] = attach_stressed, ["-"] = attach_unstressed, } do_stress_pattern = function(stress, args, decl, number, n, islast) local f = {} for _, case in ipairs(decl_cases) do if not number or (number == "sg" and rfind(case, "_sg")) or (number == "pl" and rfind(case, "_pl")) then f[case] = gen_form(args, decl, case, stress, attachers[stress_patterns[stress][case]], not not number, n, islast) -- Turn empty form lists into nil to facilitate computation of -- animate/inanimate accusatives below if f[case] and #f[case] == 0 then f[case] = nil end -- Compute linked versions of potential lemma cases, for use -- in the ru-noun+ headword. We substitute the original lemma -- (before removing links) for forms that are the same as the -- lemma, if the original lemma has links. if f[case] and (case == "nom_sg" or case == "nom_pl") then local linked_forms = {} for _, form in ipairs(f[case]) do -- Return true if FORM is "close enough" to LEMMA that we can substitute the -- linked form of the lemma. Currently this means exactly the same except that -- we ignore acute and grave accent differences in monosyllables, and ignore -- notes that may have been appended (e.g. the triangle marking irregularity). local entry, notes = m_table_tools.separate_notes(form[1]) local lemma = args.lemma_no_links local close_enough_to_lemma = entry == lemma or (com.is_monosyllabic(entry) and com.is_monosyllabic(lemma) and com.remove_accents(entry) == com.remove_accents(lemma)) if close_enough_to_lemma and rfind(args.orig_lemma, "%[%[") then table.insert(linked_forms, {args.orig_lemma .. notes, args.lemmatr and args.lemmatr .. notes}) else table.insert(linked_forms, form) end end f[case .. "_linked"] = linked_forms end end end -- Set acc an/in variants now as appropriate. We used to do this in -- handle_forms_and_overrides(), which simplified the handling of -- nom/gen/acc overrides but caused problems for words like мазло and -- трепло that had a mixture of nil and non-nil accusative forms. local an = args.thisa if not number or number == "sg" then f.acc_sg_an = f.acc_sg_an or f.acc_sg or an == "i" and f.nom_sg or f.gen_sg f.acc_sg_in = f.acc_sg_in or f.acc_sg or an == "a" and f.gen_sg or f.nom_sg end if not number or number == "pl" then f.acc_pl_an = f.acc_pl_an or f.acc_pl or an == "i" and f.nom_pl or f.gen_pl f.acc_pl_in = f.acc_pl_in or f.acc_pl or an == "a" and f.gen_pl or f.nom_pl end for case, forms in pairs(f) do if not args.forms[case] then args.forms[case] = {} end for _, form in ipairs(forms) do insert_if_not(args.forms[case], form) end end end stress_patterns["a"] = { nom_sg="-", gen_sg="-", dat_sg="-", acc_sg="-", ins_sg="-", pre_sg="-", nom_pl="-", gen_pl="-", dat_pl="-", acc_pl="-", ins_pl="-", pre_pl="-", } stress_patterns["b"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="+", ins_sg="+", pre_sg="+", nom_pl="+", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } stress_patterns["b'"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="+", ins_sg="-", pre_sg="+", nom_pl="+", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } stress_patterns["c"] = { nom_sg="-", gen_sg="-", dat_sg="-", acc_sg="-", ins_sg="-", pre_sg="-", nom_pl="+", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } stress_patterns["d"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="+", ins_sg="+", pre_sg="+", nom_pl="-", gen_pl="-", dat_pl="-", acc_pl="-", ins_pl="-", pre_pl="-", } stress_patterns["d'"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="-", ins_sg="+", pre_sg="+", nom_pl="-", gen_pl="-", dat_pl="-", acc_pl="-", ins_pl="-", pre_pl="-", } stress_patterns["e"] = { nom_sg="-", gen_sg="-", dat_sg="-", acc_sg="-", ins_sg="-", pre_sg="-", nom_pl="-", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } stress_patterns["f"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="+", ins_sg="+", pre_sg="+", nom_pl="-", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } stress_patterns["f'"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="-", ins_sg="+", pre_sg="+", nom_pl="-", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } stress_patterns["f''"] = { nom_sg="+", gen_sg="+", dat_sg="+", acc_sg="+", ins_sg="-", pre_sg="+", nom_pl="-", gen_pl="+", dat_pl="+", acc_pl="+", ins_pl="+", pre_pl="+", } ending_stressed_gen_pl_patterns = m_table.listToSet({"b", "b'", "c", "e", "f", "f'", "f''"}) ending_stressed_pre_sg_patterns = m_table.listToSet({"b", "b'", "d", "d'", "f", "f'", "f''"}) ending_stressed_dat_sg_patterns = ending_stressed_pre_sg_patterns ending_stressed_sg_patterns = ending_stressed_pre_sg_patterns ending_stressed_pl_patterns = m_table.listToSet({"b", "b'", "c"}) local numbers = { ["s"] = "singular", ["p"] = "plural", } local old_title_temp = [=[Pre-reform declension of <b lang="ru" class="Cyrl">{lemma}</b>]=] local title_temp = [=[Declension of <b lang="ru" class="Cyrl">{lemma}</b>]=] local extra_case_template, extra_case_template_with_plural local internal_notes_template local notes_template local templates = {} -- Convert a raw override into a canonicalized list of individual overrides. -- If input is nil, so is output. Certain junk (e.g. <br/>) is removed, -- and ~ and ~~ are substituted appropriately; ARGS and CASE are required for -- this purpose. FORMS is the list of existing case forms and is currently -- used only to retrieve the dat_sg for handling + in loc/par (this means -- that any overrides of the dat_sg have to be handled before handling -- overrides of loc/par). N is the suffix used to retrieve the override -- -- either a number for word-specific overrides, or an empty string for -- overall overrides. -- -- It will still be necessary to call m_table_tools.separate_notes() to separate -- off any trailing "notes" (asterisks, superscript numbers, etc.), and -- m_links.remove_links() to remove any links to get the raw override form. canonicalize_override = function(args, case, forms, n) local val = args[case .. n] if not val then return nil end -- clean <br /> that's in many multi-form entries and messes up linking val = rsub(val, "<br%s*/>", "") -- substitute ~ and ~~ and split by commas local stem, tr if rfind(case, "_pl") then stem, tr = args.pl, args.pltr end if not stem then stem, tr = args.stem, args.stemtr end local ustem, utr = com.make_unstressed_once(stem, tr) local vals = rsplit(val, "%s*,%s*") local retvals = {} for _, val in ipairs(vals) do local valru, valtr = com.split_russian_tr(val) valru = rsub(valru, "~~", ustem) valru = rsub(valru, "~", com.is_stressed(val) and ustem or stem) if rfind(valru, "^%*") then valru = rsub(valru, "^%*", "") .. HYPMARKER end if valtr then tr = tr or com.translit_no_links(stem) utr = utr or com.translit_no_links(ustem) valtr = rsub(valtr, "~~", utr) valtr = rsub(valtr, "~", com.is_stressed(val) and utr or tr) if rfind(valtr, "^%*") then valtr = rsub(valtr, "^%*", "") .. HYPMARKER end end table.insert(retvals, {valru, valtr}) end vals = retvals -- handle + in loc/par meaning "the expected form"; NOTE: This requires -- that dat_sg has already been processed! if case == "loc" or case == "par" then local new_vals = {} for _, rutr in ipairs(vals) do -- don't just handle + by itself in case the arg has в or на -- or whatever attached to it if rfind(rutr[1], "^%+") or rfind(rutr[1], "[%s%[|]%+") then for _, dat in ipairs(forms["dat_sg"]) do local ru, tr = rutr[1], rutr[2] local datru, dattr = dat[1], dat[2] local valru, valtr -- separate off any footnote symbols (which may have been -- introduced by a *tail or *tailall argument, which we need -- to process before this stage so overrides don't get -- automatically marked with footnote symbols); if par, -- try to preserve them, but with loc this can cause -- problems in case there are multiple dative forms -- (stress variants) and the last one is marked with a -- footnote symbol (occurs in грудь) local datru_entry, datru_notes = m_table_tools.separate_notes(datru) local dattr_entry, dattr_notes if dattr then dattr_entry, dattr_notes = m_table_tools.separate_notes(dattr) end if case == "par" then valru, valtr = datru_entry, dattr_entry else valru, valtr = com.make_ending_stressed(datru_entry, dattr_entry) datru_notes = "" dattr_notes = "" end -- wrap the word in brackets so it's linked; but not if it -- appears to already be linked ru = rsub(ru, "^%+", "[[" .. valru .. "]]") ru = rsub(ru, "([%[|])%+", "%1" .. valru) ru = rsub(ru, "(%s)%+", "%1[[" .. valru .. "]]") ru = ru .. datru_notes -- do the translit; but it shouldn't have brackets in it if tr or valtr then tr = tr or com.translit_no_links(rutr[1]) valtr = valtr or com.translit_no_links(valru) tr = rsub(tr, "^%+", valtr) tr = rsub(tr, "(%s)%+", "%1" .. valtr) tr = tr .. dattr_notes end table.insert(new_vals, {ru, tr}) end else table.insert(new_vals, rutr) end end vals = new_vals end -- auto-accent/check for necessary accents local newvals = {} for _, v in ipairs(vals) do local ru, tr = v[1], v[2] if not args.allow_unaccented then if tr and com.is_unstressed(ru) ~= com.is_unstressed(tr) then error("Override " .. ru .. " and translit " .. tr .. " must have same accent pattern") end -- it's safe to accent monosyllabic stems if com.is_monosyllabic(ru) then ru, tr = com.make_ending_stressed(ru, tr) elseif com.needs_accents(ru) then error("Override " .. ru .. " for case " .. case .. n .. " requires an accent") end end table.insert(newvals, {ru, tr}) end vals = newvals return vals end local function process_overrides(args, f, n) local function process_override(case) if args[case .. n] then local overrides = canonicalize_override(args, case, f, n) if not f[case] then f[case] = {} end local new_overrides = {} for _, form in ipairs(overrides) do -- Don't consider overrides of loc/par/voc irregular since -- they're only specified through overrides; FIXME: Theoretically -- we could consider loc/par irregular if they don't follow the -- expected forms; but we'd have to figure out how to eliminate -- the preposition that may be specified if not overridable_only_cases_set[case] and not args.manual and not contains_rutr_pair(f[case], form) then local formru, formnotes = m_table_tools.separate_notes(form[1]) if formru ~= "-" then -- don't mark an override of - as irregular, even if -- it has an attached footnote symbol form = com.concat_paired_russian_tr(form, {IRREGMARKER}) end end if case == "pauc" then -- Internal note indicating that the form is for numbers 2, 3 and 4. form = com.concat_paired_russian_tr(form, {paucal_marker}) end table.insert(new_overrides, form) end f[case] = new_overrides args.any_overridden[case] = true end end -- do dative singular first because it will be used by loc/par process_override("dat_sg") -- now do the rest for _, case in ipairs(overridable_cases) do if case ~= "dat_sg" then process_override(case) end end -- if the nominative is overridden, use it to set the linked version unless -- that is also specifically overridden if args["nom_sg" .. n] and not args["nom_sg_linked" .. n] then f.nom_sg_linked = f.nom_sg end if args["nom_pl" .. n] and not args["nom_pl_linked" .. n] then f.nom_pl_linked = f.nom_pl end -- convert empty lists to nil to facilitate computation of accusative -- case variants below. for _, case in ipairs(all_cases) do if f[case] then if type(f[case]) ~= "table" then error("Logic error, args[case] should be nil or table") end if #f[case] == 0 then f[case] = nil end end end end local function process_tail_args(args, f, n) local function append_note_all(case, value) value = com.split_russian_tr(value, "dopair") local function append1(case) if f[case] then for i=1,#f[case] do f[case][i] = com.concat_paired_russian_tr(f[case][i], value) end end end append1(case) if case == "acc_sg" then append1("acc_sg_in") append1("acc_sg_an") elseif case == "acc_pl" then append1("acc_pl_in") append1("acc_pl_an") end end local function append_note_last(case, value, gt_one) value = com.split_russian_tr(value, "dopair") local function append1(case) if f[case] then local lastarg = #f[case] if lastarg > (gt_one and 1 or 0) then f[case][lastarg] = com.concat_paired_russian_tr(f[case][lastarg], value) end end end append1(case) if case == "acc_sg" then append1("acc_sg_in") append1("acc_sg_an") elseif case == "acc_pl" then append1("acc_pl_in") append1("acc_pl_an") end end local function handle_tail_hyp(suf) local arg, val for _, case in ipairs(all_cases) do arg = args[case .. "_" .. suf .. n] if arg then append_note_last(case, suf == "hyp" and HYPMARKER or arg) end arg = args[case .. "_" .. suf .. "all" .. n] if arg then append_note_all(case, suf == "hyp" and HYPMARKER or arg) end if not rfind(case, "_pl") then arg = args["sg" .. suf .. "all" .. n] if arg then append_note_all(case, suf == "hyp" and HYPMARKER or arg) end arg = args["sg" .. suf .. n] if arg then append_note_last(case, suf == "hyp" and HYPMARKER or arg, ">1") end else arg = args["pl" .. suf .. "all" .. n] if arg then append_note_all(case, suf == "hyp" and HYPMARKER or arg) end arg = args["pl" .. suf .. n] if arg then append_note_last(case, suf == "hyp" and HYPMARKER or arg, ">1") end end if not rfind(case, "nom_") and not rfind(case, "acc_") then arg = args["obl" .. suf .. "all" .. n] if arg then append_note_all(case, suf == "hyp" and HYPMARKER or arg) end arg = args["obl" .. suf .. n] if arg then append_note_last(case, suf == "hyp" and HYPMARKER or arg, ">1") end end end end handle_tail_hyp("tail") handle_tail_hyp("hyp") end handle_forms_and_overrides = function(args, n, islast) local f = args.forms process_tail_args(args, f, n) process_overrides(args, f, n) local an = args.thisa -- Maybe set the value of the animate/inanimate accusative variants based -- on nom/acc/gen overrides. Don't do this if there was a specific override -- of this form. Otherwise, always propagate an accusative singular -- override, and propagate the nom/gen sg if there wasn't a specific -- accusative suffix anywhere (occurs in the fem sg and sometimes the neut -- sg). This logic duplicates logic in handle_overall_forms_and_overrides(); -- see long comment there. We need to duplicate the whole logic here to -- handle words like мать-одиночка, which has an override of acc_sg1. if not args["acc_sg_an" .. n] then if args["acc_sg" .. n] then f.acc_sg_an = f.acc_sg elseif not args.this_any_non_nil.acc_sg then f.acc_sg_an = f.acc_sg or an == "i" and f.nom_sg or f.gen_sg or f.acc_sg_an end end if not args["acc_sg_in" .. n] then if args["acc_sg" .. n] then f.acc_sg_in = f.acc_sg elseif not args.this_any_non_nil.acc_sg then f.acc_sg_in = f.acc_sg or an == "a" and f.gen_sg or f.nom_sg or f.acc_sg_in end end if not args["acc_pl_an" .. n] then if args["acc_pl" .. n] then f.acc_pl_an = f.acc_pl elseif not args.this_any_non_nil.acc_pl then f.acc_pl_an = f.acc_pl or an== "i" and f.nom_pl or f.gen_pl or f.acc_pl_an end end if not args["acc_pl_in" .. n] then if args["acc_pl" .. n] then f.acc_pl_in = f.acc_pl elseif not args.this_any_non_nil.acc_pl then f.acc_pl_in = f.acc_pl or an == "a" and f.gen_pl or f.nom_pl or f.acc_pl_in end end f.loc = f.loc or f.pre_sg f.par = f.par or f.gen_sg f.voc = f.voc or f.nom_sg -- Set these in case we have plural only, in which case the -- singular will also get set to these same values in case we are -- a plural-only word in a singular-only expression. f.loc_pl = f.loc_pl or f.pre_pl f.par_pl = f.par_pl or f.gen_pl f.voc_pl = f.voc_pl or f.nom_pl f.count = f.count or f.gen_pl f.pauc = f.pauc or f.gen_sg local nu = args.thisn -- If we have a singular-only, set the plural forms to the singular forms, -- and vice-versa. This is important so that things work in multi-word -- expressions that combine different number restrictions (e.g. -- singular-only with singular/plural or singular-only with plural-only, -- compare "St. Vincent and the Grenadines" [Сент-Винсент и Гренадины]). if nu == "s" then f.nom_pl_linked = f.nom_sg_linked f.nom_pl = f.nom_sg f.gen_pl = f.gen_sg f.dat_pl = f.dat_sg f.acc_pl = f.acc_sg f.acc_pl_an = f.acc_sg_an f.acc_pl_in = f.acc_sg_in f.ins_pl = f.ins_sg f.pre_pl = f.pre_sg f.nom_pl = f.nom_sg f.loc_pl = f.loc f.par_pl = f.par f.voc_pl = f.voc elseif nu == "p" then f.nom_sg_linked = f.nom_pl_linked f.nom_sg = f.nom_pl f.gen_sg = f.gen_pl f.dat_sg = f.dat_pl f.acc_sg = f.acc_pl f.acc_sg_an = f.acc_pl_an f.acc_sg_in = f.acc_pl_in f.ins_sg = f.ins_pl f.pre_sg = f.pre_pl f.nom_sg = f.nom_pl f.loc = f.loc_pl f.par = f.par_pl f.voc = f.voc_pl end end handle_overall_forms_and_overrides = function(args) local overall_forms = {} for _, case in ipairs(displayable_cases) do overall_forms[case] = concat_word_forms(args.per_word_info, case) end local acc_sg_overridden = args.acc_sg local acc_pl_overridden = args.acc_pl process_tail_args(args, overall_forms, "") process_overrides(args, overall_forms, "") if case_will_be_displayed(args, "pauc") then insert_if_not(args.internal_notes, paucal_internal_note) end -- if IRREGMARKER is anywhere in text, remove all instances and put -- at the end before any notes. local function clean_irreg_marker(case, text) if rfind(text, IRREGMARKER) then text = rsub(text, IRREGMARKER, "") local entry, notes = m_table_tools.separate_notes(text) if case_will_be_displayed(args, case) then insert_if_not(args.internal_notes, IRREGMARKER .. " Irregular.") args.any_irreg = true args.any_irreg_case[case] = true end return entry .. IRREGMARKER .. notes else return text end end -- set final args[case] and clean up IRREGMARKER. for _, case in ipairs(all_cases) do args[case] = overall_forms[case] if args[case] then local cleaned_forms = {} for _, form in ipairs(args[case]) do local ru, tr = form[1], form[2] ru = clean_irreg_marker(case, ru) if tr then tr = clean_irreg_marker(case, tr) end table.insert(cleaned_forms, {ru, tr}) end args[case] = cleaned_forms end end -- Maybe set the value of the animate/inanimate accusative variants based -- on nom/acc/gen overrides. Don't do this if there was a specific override -- of this form. Otherwise, always propagate an accusative singular -- override, and propagate the nom/gen sg if there wasn't a specific -- accusative suffix anywhere (occurs in the fem sg and sometimes the neut -- sg). We need to do this somewhat complicated procedure to get overrides -- to work correctly, e.g. acc_sg overrides of feminine and neuter nouns -- (such as мать and полслова) and gen_sg/gen_pl overrides of masculine -- animate nouns. We also ran into an issue with words like мазло that are -- neuter-form but can be both masculine animate (in which case the -- acc sg inherits from the genitive) and neuter animate (in which case the -- acc sg has the fixed ending -о, same as nominative, despite the animacy). -- Remember also that the animate/inanimate accusative variants are the ones -- displayed, not the plain acc_sg/acc_pl ones. if not args.any_overridden.acc_sg_an then if acc_sg_overridden then args.acc_sg_an = args.acc_sg elseif not args.any_non_nil.acc_sg then args.acc_sg_an = args.acc_sg or args.a == "i" and args.nom_sg or args.gen_sg or args.acc_sg_an end end if not args.any_overridden.acc_sg_in then if acc_sg_overridden then args.acc_sg_in = args.acc_sg elseif not args.any_non_nil.acc_sg then args.acc_sg_in = args.acc_sg or args.a == "a" and args.gen_sg or args.nom_sg or args.acc_sg_in end end if not args.any_overridden.acc_pl_an then if acc_pl_overridden then args.acc_pl_an = args.acc_pl elseif not args.any_non_nil.acc_pl then args.acc_pl_an = args.acc_pl or args.a == "i" and args.nom_pl or args.gen_pl or args.acc_pl_an end end if not args.any_overridden.acc_pl_in then if acc_pl_overridden then args.acc_pl_in = args.acc_pl elseif not args.any_non_nil.acc_pl then args.acc_pl_in = args.acc_pl or args.a == "a" and args.gen_pl or args.nom_pl or args.acc_pl_in end end -- Try to set the values of acc_sg and acc_pl. The only time we can't is -- when the noun is bianimate and the anim/inan values are different. -- This is used primarily for generate_forms() and generate_multi_forms(), -- since we don't actually display these forms. if args.a == "a" then args.acc_sg = args.acc_sg or args.acc_sg_an args.acc_pl = args.acc_pl or args.acc_pl_an elseif args.a == "i" then args.acc_sg = args.acc_sg or args.acc_sg_in args.acc_pl = args.acc_pl or args.acc_pl_in else -- bianimate args.acc_sg = args.acc_sg or m_table.deepEquals(args.acc_sg_in, args.acc_sg_an) and args.acc_sg_in or nil args.acc_pl = args.acc_pl or m_table.deepEquals(args.acc_pl_in, args.acc_pl_an) and args.acc_pl_in or nil end end -- Subfunction of concat_word_forms(), used to implement recursively -- generating all combinations of elements from WORD_FORMS (a list, one -- element per word, of a list of the forms for a word, each of which is a -- two-element list of {RUSSIAN, TR}) and TRAILING_FORMS (a list of forms, the -- accumulated suffixes for trailing words so far in the recursion process, -- again where each form is a two-element list {RUSSIAN, TR}). Each time we -- recur we take the last FORMS item off of WORD_FORMS and to each form in -- FORMS we add all elements in TRAILING_FORMS, passing the newly generated -- list of items down the next recursion level with the shorter WORD_FORMS. -- We end up returning a list of concatenated forms, where each list item -- is a two-element list {RUSSIAN, TR}. local function concat_word_forms_1(word_forms, trailing_forms) if #word_forms == 0 then local retforms = {} for _, form in ipairs(trailing_forms) do local ru, tr = form[1], form[2] -- Remove <insa> and <insb> markers; they've served their purpose. ru = rsub(ru, "<ins[ab]>", "") tr = tr and rsub(tr, "<ins[ab]>", "") table.insert(retforms, {ru, tr}) end return retforms else local last_form_info = table.remove(word_forms) local last_forms, joiner = last_form_info[1], last_form_info[2] local new_trailing_forms = {} for _, form in ipairs(last_forms) do for _, trailing_form in ipairs(trailing_forms) do -- If form to prepend is empty, don't add the joiner; this -- is principally used in overall overrides, where we stuff -- the entire override into the last word local full_form = form[1] == "" and trailing_form or com.concat_paired_russian_tr(form, com.concat_paired_russian_tr(joiner, trailing_form), "movenotes") if rfind(full_form[1], "<insa>") and rfind(full_form[1], "<insb>") then -- REJECT! So we don't get mixtures of the two feminine -- instrumental singular endings. else table.insert(new_trailing_forms, full_form) end end end return concat_word_forms_1(word_forms, new_trailing_forms) end end -- Generate a list of overall forms by concatenating the per-word forms. -- PER_WORD_INFO comes from args.per_word_info and is a list of -- WORD_INFO items, one per word, each of which a two element list of -- WORD_FORMS (a table listing the forms for each case) and JOINER (a string). -- We loop over all possible combinations of elements from each word's list -- of forms for the given case; this requires recursion. concat_word_forms = function(per_word_info, case) local word_forms = {} -- Gather the appropriate word forms. We have to recreate this anew -- because it will be destructively modified by concat_word_forms_1(). for _, word_info in ipairs(per_word_info) do table.insert(word_forms, {word_info[1][case], word_info[2]}) end -- We need to start the recursion with the second parameter containing -- one blank element rather than no elements, otherwise no elements -- will be propagated to the next recursion level. return concat_word_forms_1(word_forms, {{""}}) end local accel_forms = { nom_sg = "nom|s", nom_sg_linked = "nom|s", nom_pl = "nom|p", nom_pl_linked = "nom|p", gen_sg = "gen|s", gen_pl = "gen|p", dat_sg = "dat|s", dat_pl = "dat|p", acc_sg_an = "an|acc|s", acc_pl_an = "an|acc|p", acc_sg_in = "in|acc|s", acc_pl_in = "in|acc|p", ins_sg = "ins|s", ins_pl = "ins|p", pre_sg = "pre|s", pre_pl = "pre|p", loc = "loc|s", loc_pl = "loc|p", voc = "voc|s", voc_pl = "voc|p", par = "par|s", par_pl = "par|p", count = "count|form", pauc = "pau", } -- Make the table make_table = function(args) local data = {} data.after_title = " " .. args.heading data.number = args.nonumber and "" or numbers[args.n] local lemma_forms = args[args.n == "p" and "nom_pl" or "nom_sg"] data.lemma = nom.show_form(args.explicit_lemma and {{args.explicit_lemma, args.explicit_lemmatr}} or args[args.n == "p" and "nom_pl_linked" or "nom_sg_linked"], "lemma", nil, nil) data.title = args.title or strutils.format(args.old and old_title_temp or title_temp, data) local sg_an_in_equal = m_table.deepEquals(args.acc_sg_an, args.acc_sg_in) local pl_an_in_equal = m_table.deepEquals(args.acc_pl_an, args.acc_pl_in) for _, case in ipairs(displayable_cases) do local accel_form = accel_forms[case] if not accel_form then error("Something wrong, can't find accelerator form for " .. case) end if (sg_an_in_equal and (case == "acc_sg_an" or case == "acc_sg_in") or pl_an_in_equal and (case == "acc_pl_an" or case == "acc_pl_in")) then accel_form = rsub(accel_form, "^[ai]n|", "") end if args.n == "p" then accel_form = rsub(accel_form, "|p$", "") end data[case] = nom.show_form(args[case], false, accel_form, lemma_forms, "remove monosyllabic accents only lemma") end local temp = nil if args.n == "s" then data.nom_x = data.nom_sg data.gen_x = data.gen_sg data.dat_x = data.dat_sg data.acc_x_an = data.acc_sg_an data.acc_x_in = data.acc_sg_in data.ins_x = data.ins_sg data.pre_x = data.pre_sg if sg_an_in_equal then temp = "one_number" else temp = "one_number_split_animacy" end elseif args.n == "p" then data.nom_x = data.nom_pl data.gen_x = data.gen_pl data.dat_x = data.dat_pl data.acc_x_an = data.acc_pl_an data.acc_x_in = data.acc_pl_in data.ins_x = data.ins_pl data.pre_x = data.pre_pl data.par = data.par_pl data.loc = data.loc_pl data.voc = data.voc_pl if pl_an_in_equal then temp = "one_number" else temp = "one_number_split_animacy" end else if pl_an_in_equal then temp = "both_numbers" elseif sg_an_in_equal then temp = "both_numbers_split_animacy_plural_only" else temp = "both_numbers_split_animacy" end end for _, extra_case in ipairs({ {"par", "partitive"}, {"loc", "locative"}, {"voc", "vocative"}, }) do local case, engcase = unpack(extra_case) local template if args.n ~= "s" and args.n ~= "p" and args.any_overridden[case .. "_pl"] then if not args.any_overridden[case] then data[case] = "" end template = extra_case_template_with_plural elseif args.n ~= "p" and args.any_overridden[case] or args.n == "p" and args.any_overridden[case .. "_pl"] then template = extra_case_template end if template then template = strutils.format(template, {case=case, engcase=engcase}) data[case .. "_clause"] = strutils.format(template, data) else data[case .. "_clause"] = "" end end for _, extra_case in ipairs({ {"count", "count form"}, {"pauc", "paucal"}, }) do local case, engcase = unpack(extra_case) local template if args.n ~= "p" and args.any_overridden[case] then template = extra_case_template end if template then template = strutils.format(template, {case=case, engcase=engcase}) data[case .. "_clause"] = strutils.format(template, data) else data[case .. "_clause"] = "" end end local notes = get_arg_chain(args, "notes", "notes") local all_notes = {} for _, note in ipairs(args.internal_notes) do -- Superscript footnote marker at beginning of note, similarly to what's -- done at end of forms. local symbol, entry = m_table_tools.get_initial_notes(note) table.insert(all_notes, symbol .. entry) end for _, note in ipairs(notes) do -- Here too. local symbol, entry = m_table_tools.get_initial_notes(note) table.insert(all_notes, symbol .. entry) end data.notes = table.concat(all_notes, "<br />") data.notes_clause = data.notes ~= "" and strutils.format(notes_template, data) or "" return strutils.format(templates[temp], data) end extra_case_template = [===[ ! style="background:#eff7ff" | {engcase} | {\op}{case}{\cl} | |-]===] extra_case_template_with_plural = [===[ ! style="background:#eff7ff" | {engcase} | {\op}{case}{\cl} | {\op}{case}_pl{\cl} |-]===] notes_template = [===[ <div style="width:100%;text-align:left;background:#d9ebff"> <div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em"> {notes} </div></div> ]===] local function template_prelude(min_width) min_width = min_width or "70" return rsub([===[ <div> <div class="NavFrame" style="display:inline-block; min-width:MINWIDTHem"> <div class="NavHead" style="background:#eff7ff;">{title}<span style="font-weight:normal;">{after_title}</span>&nbsp;</div> <div class="NavContent"> {\op}| style="background:#F9F9F9; text-align:center; min-width:MINWIDTHem; width:100%;" class="inflection-table" |- ]===], "MINWIDTH", min_width) end local function template_postlude() return [===[|-{par_clause}{loc_clause}{voc_clause}{count_clause}{pauc_clause} |{\cl}{notes_clause}</div></div></div>]===] end templates["both_numbers"] = template_prelude("45") .. [===[ ! style="width:10em;background:#d9ebff" | ! style="background:#d9ebff" | singular ! style="background:#d9ebff" | plural |- ! style="background:#eff7ff" | nominative | {nom_sg} | {nom_pl} |- ! style="background:#eff7ff" | genitive | {gen_sg} | {gen_pl} |- ! style="background:#eff7ff" | dative | {dat_sg} | {dat_pl} |- ! style="background:#eff7ff" | accusative | {acc_sg_an} | {acc_pl_an} |- ! style="background:#eff7ff" | instrumental | {ins_sg} | {ins_pl} |- ! style="background:#eff7ff" | prepositional | {pre_sg} | {pre_pl} ]===] .. template_postlude() templates["both_numbers_split_animacy"] = template_prelude("50") .. [===[ ! style="width:15em;background:#d9ebff" | ! style="background:#d9ebff" | singular ! style="background:#d9ebff" | plural |- ! style="background:#eff7ff" | nominative | {nom_sg} | {nom_pl} |- ! style="background:#eff7ff" | genitive | {gen_sg} | {gen_pl} |- ! style="background:#eff7ff" | dative | {dat_sg} | {dat_pl} |- ! style="background:#eff7ff" rowspan="2" | accusative <span style="padding-left:1em;display:inline-block;vertical-align:middle">animate<br/><br/>inanimate</span> | {acc_sg_an} | {acc_pl_an} |- | {acc_sg_in} | {acc_pl_in} |- ! style="background:#eff7ff" | instrumental | {ins_sg} | {ins_pl} |- ! style="background:#eff7ff" | prepositional | {pre_sg} | {pre_pl} ]===] .. template_postlude() templates["both_numbers_split_animacy_plural_only"] = template_prelude("50") .. [===[ ! style="width:15em;background:#d9ebff" | ! style="background:#d9ebff" | singular ! style="background:#d9ebff" | plural |- ! style="background:#eff7ff" | nominative | {nom_sg} | {nom_pl} |- ! style="background:#eff7ff" | genitive | {gen_sg} | {gen_pl} |- ! style="background:#eff7ff" | dative | {dat_sg} | {dat_pl} |- ! style="background:#eff7ff" rowspan="2" | accusative <span style="padding-left:1em;display:inline-block;vertical-align:middle">animate<br/><br/>inanimate</span> | rowspan="2" | {acc_sg_an} | {acc_pl_an} |- | {acc_pl_in} |- ! style="background:#eff7ff" | instrumental | {ins_sg} | {ins_pl} |- ! style="background:#eff7ff" | prepositional | {pre_sg} | {pre_pl} ]===] .. template_postlude() templates["one_number"] = template_prelude("30") .. [===[ ! style="width:10em;background:#d9ebff" | ! style="background:#d9ebff" | {number} |- ! style="background:#eff7ff" | nominative | {nom_x} |- ! style="background:#eff7ff" | genitive | {gen_x} |- ! style="background:#eff7ff" | dative | {dat_x} |- ! style="background:#eff7ff" | accusative | {acc_x_an} |- ! style="background:#eff7ff" | instrumental | {ins_x} |- ! style="background:#eff7ff" | prepositional | {pre_x} ]===] .. template_postlude() templates["one_number_split_animacy"] = template_prelude("35") .. [===[ ! style="width:15em;background:#d9ebff" | ! style="background:#d9ebff" | {number} |- ! style="background:#eff7ff" | nominative | {nom_x} |- ! style="background:#eff7ff" | genitive | {gen_x} |- ! style="background:#eff7ff" | dative | {dat_x} |- ! style="background:#eff7ff" rowspan="2" | accusative <span style="padding-left:1em;display:inline-block;vertical-align:middle">animate<br/><br/>inanimate</span> | {acc_x_an} |- | {acc_x_in} |- ! style="background:#eff7ff" | instrumental | {ins_x} |- ! style="background:#eff7ff" | prepositional | {pre_x} ]===] .. template_postlude() return export ax0pvsu49m6zbgahq6haqcj9n2oabvc Module:ru-common 828 5225 13217 2022-07-26T12:15:58Z Asinis632 1829 Created page with "--[[ Author: Benwing; some very early work by CodeCat and Atitarev This module holds some commonly used functions for the Russian language. It's generally for use from other modules, not #invoke, although some functions can be invoked from a template (export.iotation(), export.reduce_stem(), export.dereduce_stem() -- this was actually added to support calling from a bot script rather than from a user template). There's also export.main(), which supposedly can be used t..." Scribunto text/plain --[[ Author: Benwing; some very early work by CodeCat and Atitarev This module holds some commonly used functions for the Russian language. It's generally for use from other modules, not #invoke, although some functions can be invoked from a template (export.iotation(), export.reduce_stem(), export.dereduce_stem() -- this was actually added to support calling from a bot script rather than from a user template). There's also export.main(), which supposedly can be used to invoke most functions in this module from a template, but it may or may not work. There may also be issues when invoking such functions from templates when transliteration is present, due to the need for the transliteration to be decomposed, as mentioned below (all strings from Wiktionary pages are normally in composed form). NOTE NOTE NOTE: All functions assume that transliteration (but not Russian) has had its acute and grave accents decomposed using export.decompose(). This is the first thing that should be done to all user-specified transliteration and any transliteration we compute that we expect to work with. ]] local export = {} local lang = require("Module:languages").getByCode("ru") local strutils = require("Module:string utilities") local m_ru_translit = require("Module:ru-translit") local m_table_tools = require("Module:table tools") local u = mw.ustring.char local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local rmatch = mw.ustring.match local rsplit = mw.text.split local ulower = mw.ustring.lower local uupper = mw.ustring.upper local usub = mw.ustring.sub local AC = u(0x0301) -- acute = ́ local GR = u(0x0300) -- grave = ̀ local CFLEX = u(0x0302) -- circumflex = ̂ local BREVE = u(0x0306) -- breve ̆ local DIA = u(0x0308) -- diaeresis = ̈ local CARON = u(0x030C) -- caron ̌ local PSEUDOVOWEL = u(0xFFF1) -- pseudovowel placeholder local PSEUDOCONS = u(0xFFF2) -- pseudoconsonant placeholder -- any accent export.accent = AC .. GR .. DIA .. BREVE .. CARON -- regex for any optional accent(s) export.opt_accent = "[" .. export.accent .. "]*" -- any composed Cyrillic vowel with grave accent export.composed_grave_vowel = "ѐЀѝЍ" -- any Cyrillic vowel except ёЁ export.vowel_no_jo = "аеиоуяэыюіѣѵАЕИОУЯЭЫЮІѢѴ" .. PSEUDOVOWEL .. export.composed_grave_vowel -- any Cyrillic vowel, including ёЁ export.vowel = export.vowel_no_jo .. "ёЁ" -- any vowel in transliteration export.tr_vowel = "aeěɛiouyAEĚƐIOUY" .. PSEUDOVOWEL -- any consonant in transliteration, omitting soft/hard sign export.tr_cons_no_sign = "bcčdfghjklmnpqrsštvwxzžBCČDFGHJKLMNPQRSŠTVWXZŽ" .. PSEUDOCONS -- any consonant in transliteration, including soft/hard sign export.tr_cons = export.tr_cons_no_sign .. "ʹʺ" -- regex for any consonant in transliteration, including soft/hard sign, -- optionally followed by any accent export.tr_cons_acc_re = "[" .. export.tr_cons .. "]" .. export.opt_accent -- any Cyrillic consonant except sibilants and ц export.cons_except_sib_c = "бдфгйклмнпрствхзьъБДФГЙКЛМНПРСТВХЗЬЪ" .. PSEUDOCONS -- Cyrillic sibilant consonants export.sib = "шщчжШЩЧЖ" -- Cyrillic sibilant consonants and ц export.sib_c = export.sib .. "цЦ" -- any Cyrillic consonant export.cons = export.cons_except_sib_c .. export.sib_c -- Cyrillic velar consonants export.velar = "кгхКГХ" -- uppercase Cyrillic consonants export.uppercase = "АЕИОУЯЭЫЁЮІѢѴБДФГЙКЛМНПРСТВХЗЬЪШЩЧЖЦ" -- version of rsubn() that discards all but the first return value local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end local function ine(x) return x ~= "" and x or nil end -- this function enables the module to be called from a template; -- FIXME, does this actually work? function export.main(frame) -- FIXME: Not used. Consider deleting. if type(export[frame.args[1]]) == 'function' then return export[frame.args[1]](frame.args[2], frame.args[3]) else return export[frame.args[1]][frame.args[2]] end end -- selects preposition о, об or обо for next phrase, which can start from -- punctuation function export.obo(phr) -- FIXME: Not used. Consider deleting. --Algorithm design is mainly inherited from w:ru:template:Обо local w = rmatch(phr,"[%p%s%c]*(.-)[%p%s%c]") or rmatch(phr,"[%p%s%c]*(.-)$") if not w then return nil end if string.find(" всей всём всех мне ",' '..ulower(w)..' ',1,true) then return 'обо' end local ws=usub(w,1,2) if ws==uupper(ws) then -- abbrev if rmatch(ws,"^[ЙУНФЫАРОЛЭСМИRYUIOASFHLXNMÖÜÄΑΕΟΥΩ]") then return 'об' else return 'о' end elseif rmatch(uupper(w),"^[АОЭИУЫAOIEÖÜÄΑΕΟΥΩ]") then return 'об' else return 'о' end end -- Apply Proto-Slavic iotation. This is the change that is affected by a -- Slavic -j- after a consonant. function export.iotation(stem, tr, shch) local combine_tr = false -- so this can be called from a template if type(stem) == 'table' then stem, tr, shch = ine(stem.args[1]), ine(stem.args[2]), ine(stem.args[3]) combine_tr = true end stem = rsub(stem, "[сх]$", "ш") stem = rsub(stem, "ск$", "щ") stem = rsub(stem, "ст$", "щ") stem = rsub(stem, "[кц]$", "ч") -- normally "т" is iotated as "ч" but there are many verbs that are iotated with "щ" if shch == "щ" then stem = rsub(stem, "т$", "щ") else stem = rsub(stem, "т$", "ч") end stem = rsub(stem, "[гдз]$", "ж") stem = rsub(stem, "([бвмпф])$", "%1л") if tr then tr = rsub(tr, "[sx]$", "š") tr = rsub(tr, "sk$", "šč") tr = rsub(tr, "st$", "šč") tr = rsub(tr, "[kc]$", "č") -- normally "т" is iotated as "ч" but there are many verbs that are iotated with "щ" if shch == "щ" then tr = rsub(tr, "t$", "šč") else tr = rsub(tr, "t$", "č") end tr = rsub(tr, "[gdz]$", "ž") tr = rsub(tr, "([bvmpf])$", "%1l") end if combine_tr then return export.combine_russian_tr(stem, tr) else return stem, tr end end -- Does a set of Cyrillic words in connected text need accents? We need to -- split by word and check each one. function export.needs_accents(text) local function word_needs_accents(word) -- A word needs accents if it is unstressed and contains more than -- one vowel, unless it's a prefix or suffix return not rfind(word, "^%-") and not rfind(word, "%-$") and export.is_unstressed(word) and not export.is_monosyllabic(word) end local words = rsplit(text, "%s") for _, word in ipairs(words) do if word_needs_accents(word) then return true end end return false end -- True if Cyrillic word is stressed (acute or diaeresis) function export.is_stressed(word) -- A word that has ё in it is inherently stressed. -- diaeresis occurs in сѣ̈дла plural of сѣдло́ return rfind(word, "[́̈ёЁ]") end -- True if Cyrillic word has no stress mark (acute or diaeresis) function export.is_unstressed(word) return not export.is_stressed(word) end -- True if Cyrillic word is stressed on the last syllable function export.is_ending_stressed(word) return rfind(word, "[ёЁ][^" .. export.vowel .. "]*$") or rfind(word, "[" .. export.vowel .. "][́̈][^" .. export.vowel .. "]*$") end -- True if a Cyrillic word has two or more stresses (acute or diaeresis) function export.is_multi_stressed(word) word = rsub(word, "[ёЁ]", "е́") return rfind(word, "[" .. export.vowel .. "][́̈].*[" .. export.vowel .. "][́̈]") end -- True if Cyrillic word is stressed on the first syllable function export.is_beginning_stressed(word) return rfind(word, "^[^" .. export.vowel .. "]*[ёЁ]") or rfind(word, "^[^" .. export.vowel .. "]*[" .. export.vowel .. "]́") end -- True if Cyrillic word has no vowel. Don't treat suffixes as nonsyllabic -- even if they have no vowel, as they are generally added onto words with -- vowels. function export.is_nonsyllabic(word) return not rfind(word, "^%-") and not rfind(word, "[" .. export.vowel .. "]") end -- True if Cyrillic word has no more than one vowel; includes non-syllabic -- stems such as льд- function export.is_monosyllabic(word) return not rfind(word, "[" .. export.vowel .. "].*[" .. export.vowel .. "]") end local recomposer = { ["и" .. BREVE] = "й", ["И" .. BREVE] = "Й", ["е" .. DIA] = "ё", -- WARNING: Cyrillic е and Е ["Е" .. DIA] = "Ё", ["e" .. CARON] = "ě", -- WARNING: Latin e and E ["E" .. CARON] = "Ě", ["c" .. CARON] = "č", ["C" .. CARON] = "Č", ["s" .. CARON] = "š", ["S" .. CARON] = "Š", ["z" .. CARON] = "ž", ["Z" .. CARON] = "Ž", -- used in ru-pron: ["ж" .. BREVE] = "ӂ", -- used in ru-pron ["Ж" .. BREVE] = "Ӂ", ["j" .. CFLEX] = "ĵ", ["J" .. CFLEX] = "Ĵ", ["j" .. CARON] = "ǰ", -- no composed uppercase equivalent of J-caron ["ʒ" .. CARON] = "ǯ", ["Ʒ" .. CARON] = "Ǯ", } -- Decompose acute, grave, etc. on letters (esp. Latin) into individivual -- character + combining accent. But recompose Cyrillic and Latin characters -- that we want to treat as units and get caught in the crossfire. We mostly -- want acute and grave decomposed; perhaps should just explicitly decompose -- those and no others. function export.decompose(text) text = mw.ustring.toNFD(text) text = rsub(text, ".[" .. BREVE .. DIA .. CARON .. "]", recomposer) return text end function export.assert_decomposed(text) assert(not rfind(text, "[áéíóúýàèìòùỳäëïöüÿÁÉÍÓÚÝÀÈÌÒÙỲÄËÏÖÜŸ]")) end -- Transliterate text and then apply acute/grave decomposition. function export.translit(text, no_include_monosyllabic_jo_accent) return export.decompose(m_ru_translit.tr(text, nil, nil, not no_include_monosyllabic_jo_accent)) end -- Recompose acutes and graves into preceding vowels. Probably not necessary. function export.recompose(text) return mw.ustring.toNFC(text) end local grave_decomposer = { ["ѐ"] = "е" .. GR, ["Ѐ"] = "Е" .. GR, ["ѝ"] = "и" .. GR, ["Ѝ"] = "И" .. GR, } -- decompose precomposed Cyrillic chars w/grave accent; not necessary for -- acute accent as there aren't precomposed Cyrillic chars w/acute accent, -- and undesirable for precomposed ё and Ё function export.decompose_grave(word) return rsub(word, "[ѐЀѝЍ]", grave_decomposer) end local grave_deaccenter = { [GR] = "", -- grave accent ["ѐ"] = "е", -- composed Cyrillic chars w/grave accent ["Ѐ"] = "Е", ["ѝ"] = "и", ["Ѝ"] = "И", } local deaccenter = mw.clone(grave_deaccenter) deaccenter[AC] = "" -- acute accent -- Remove acute and grave accents; don't affect composed diaeresis in ёЁ or -- uncomposed diaeresis in -ѣ̈- (as in plural сѣ̈дла of сѣдло́). -- NOTE: Translit must already be decomposed! See comment at top. function export.remove_accents(word, tr) local ru_removed = rsub(word, "[́̀ѐЀѝЍ]", deaccenter) if not tr then return ru_removed, nil end return ru_removed, rsub(tr, "[" .. AC .. GR .. "]", deaccenter) end -- Remove grave accents; don't affect acute or composed diaeresis in ёЁ or -- uncomposed diaeresis in -ѣ̈- (as in plural сѣ̈дла of сѣдло́). -- NOTE: Translit must already be decomposed! See comment at top. function export.remove_grave_accents(word, tr) local ru_removed = rsub(word, "[̀ѐЀѝЍ]", grave_deaccenter) if not tr then return ru_removed, nil end return ru_removed, rsub(tr, GR, "") end -- Remove acute and grave accents in monosyllabic words; don't affect -- diaeresis (composed or uncomposed) because it indicates a change in vowel -- quality, which still applies to monosyllabic words. Don't change suffixes, -- where a "monosyllabic" stress is still significant (e.g. -ча́т short -- masculine of -ча́тый, vs. -́чат short masculine of -́чатый). -- NOTE: Translit must already be decomposed! See comment at top. function export.remove_monosyllabic_accents(word, tr) if export.is_monosyllabic(word) and not rfind(word, "^%-") then return export.remove_accents(word, tr) else return word, tr end end local destresser = mw.clone(deaccenter) destresser["ё"] = "е" destresser["Ё"] = "Е" destresser["̈"] = "" -- diaeresis -- Subfunction of split_syllables(). On input we get sections of text -- consisting of CONSONANT - VOWEL - CONSONANT - VOWEL ... - CONSONANT, -- where CONSONANT consists of zero or more consonants and VOWEL consists -- of exactly one vowel plus any following accent(s); we combine these into -- syllables as required by split_syllables(). local function combine_captures(captures) if #captures == 1 then return captures end local combined = {} for i = 1,(#captures-1),2 do table.insert(combined, captures[i] .. captures[i+1]) end combined[#combined] = combined[#combined] .. captures[#captures] return combined end -- Split Russian text and transliteration into syllables. Syllables end with -- vowel + accent(s), except for the last syllable, which includes any -- trailing consonants. -- NOTE: Translit must already be decomposed! See comment at top. function export.split_syllables(ru, tr) -- Split into alternating consonant/vowel sequences, as described in -- combine_captures(). Uses capturing_split(), which is like rsplit() -- but also includes any capturing groups in the split pattern. local rusyllables = combine_captures(strutils.capturing_split(ru, "([" .. export.vowel .. "]" .. export.opt_accent .. ")")) local trsyllables if tr then export.assert_decomposed(tr) trsyllables = combine_captures(strutils.capturing_split(tr, "([" .. export.tr_vowel .. "]" .. export.opt_accent .. ")")) if #rusyllables ~= #trsyllables then error("Russian " .. ru .. " doesn't have same number of syllables as translit " .. tr) end end --error(table.concat(rusyllables, "/") .. "(" .. #rusyllables .. (trsyllables and (") || " .. table.concat(trsyllables, "/") .. "(" .. #trsyllables .. ")") or "")) return rusyllables, trsyllables end -- Split Russian word and transliteration into hyphen-separated components. -- Rejoining with table.concat(..., "-") will recover the original word. -- If the original word ends in a hyphen, that hyphen gets included with the -- preceding component (this is the only case when an individual component has -- a hyphen in it). function export.split_hyphens(ru, tr) local rucomponents = rsplit(ru, "%-") if rucomponents[#rucomponents] == "" and #rucomponents > 1 then rucomponents[#rucomponents - 1] = rucomponents[#rucomponents - 1] .. "-" table.remove(rucomponents) end local trcomponents if tr then trcomponents = rsplit(tr, "%-") if trcomponents[#trcomponents] == "" and #trcomponents > 1 then trcomponents[#trcomponents - 1] = trcomponents[#trcomponents - 1] .. "-" table.remove(trcomponents) end if #rucomponents ~= #trcomponents then error("Russian " .. ru .. " doesn't have same number of hyphenated components as translit " .. tr) end end return rucomponents, trcomponents end -- Apply j correction, converting je to e after consonants, jo to o after -- a sibilant, ju to u after hard sibilant. -- NOTE: Translit must already be decomposed! See comment at top. function export.j_correction(tr) tr = rsub(tr, "([" .. export.tr_cons_no_sign .. "]" .. export.opt_accent ..")[Jj]([EeĚě])", "%1%2") tr = rsub(tr, "([žščŽŠČ])[Jj]([Oo])", "%1%2") tr = rsub(tr, "([žšŽŠ])[Jj]([Uu])", "%1%2") return tr end local function make_unstressed_ru(ru) -- The following regexp has grave+acute+diaeresis after the bracket -- return rsub(ru, "[̀́̈ёЁѐЀѝЍ]", destresser) end -- Remove all stress marks (acute, grave, diaeresis). -- NOTE: Translit must already be decomposed! See comment at top. function export.make_unstressed(ru, tr) if not tr then return make_unstressed_ru(ru), nil end -- In the presence of TR, we need to do things the hard way: Splitting -- into syllables and only converting Latin o to e opposite a ё. rusyl, trsyl = export.split_syllables(ru, tr) for i=1,#rusyl do if rfind(rusyl[i], "[ёЁ]") then trsyl[i] = rsub(trsyl[i], "[Oo]", {["O"] = "E", ["o"] = "e"}) end rusyl[i] = make_unstressed_ru(rusyl[i]) -- the following should still work as it will affect accents only trsyl[i] = make_unstressed_ru(trsyl[i]) end -- Also need to apply j correction as otherwise we'll have je after cons, etc. return table.concat(rusyl, ""), export.j_correction(table.concat(trsyl, "")) end function remove_jo_ru(word) return rsub(word, "[̈ёЁ]", destresser) end -- Remove diaeresis stress marks only. -- NOTE: Translit must already be decomposed! See comment at top. function export.remove_jo(ru, tr) if not tr then return remove_jo_ru(ru), nil end -- In the presence of TR, we need to do things the hard way: Splitting -- into syllables and only converting Latin o to e opposite a ё. rusyl, trsyl = export.split_syllables(ru, tr) for i=1,#rusyl do if rfind(rusyl[i], "[ёЁ]") then trsyl[i] = rsub(trsyl[i], "[Oo]", {["O"] = "E", ["o"] = "e"}) end rusyl[i] = remove_jo_ru(rusyl[i]) -- the following should still work as it will affect accents only trsyl[i] = make_unstressed_once_ru(trsyl[i]) end -- Also need to apply j correction as otherwise we'll have je after cons, etc. return table.concat(rusyl, ""), export.j_correction(table.concat(trsyl, "")) end local function make_unstressed_once_ru(word) -- leave graves alone return rsub(word, "([́̈ёЁ])([^́̈ёЁ]*)$", function(x, rest) return destresser[x] .. rest; end, 1) end local function map_last_hyphenated_component(fn, ru, tr) if rfind(ru, "%-") then -- If there is a hyphen, do it the hard way by splitting into -- individual components and doing the last one. Otherwise we just do -- the whole string. local rucomponents, trcomponents = export.split_hyphens(ru, tr) local lastru, lasttr = fn(rucomponents[#rucomponents], trcomponents and trcomponents[#trcomponents] or nil) rucomponents[#rucomponents] = lastru ru = table.concat(rucomponents, "-") if trcomponents then trcomponents[#trcomponents] = lasttr tr = table.concat(trcomponents, "-") end return ru, tr end return fn(ru, tr) end -- Make last stressed syllable (acute or diaeresis) unstressed; leave -- unstressed; leave graves alone; if NOCONCAT, return individual syllables. -- NOTE: Translit must already be decomposed! See comment at top. local function make_unstressed_once_after_hyphen_split(ru, tr, noconcat) if not tr then return make_unstressed_once_ru(ru), nil end -- In the presence of TR, we need to do things the hard way, as with -- make_unstressed(). rusyl, trsyl = export.split_syllables(ru, tr) for i=#rusyl,1,-1 do local stressed = export.is_stressed(rusyl[i]) if stressed then if rfind(rusyl[i], "[ёЁ]") then trsyl[i] = rsub(trsyl[i], "[Oo]", {["O"] = "E", ["o"] = "e"}) end rusyl[i] = make_unstressed_once_ru(rusyl[i]) -- the following should still work as it will affect accents only trsyl[i] = make_unstressed_once_ru(trsyl[i]) break end end if noconcat then return rusyl, trsyl end -- Also need to apply j correction as otherwise we'll have je after cons return table.concat(rusyl, ""), export.j_correction(table.concat(trsyl, "")) end -- Make last stressed syllable (acute or diaeresis) to the right of any hyphen -- unstressed (unless the hyphen is word-final); leave graves alone. We don't -- destress a syllable to the left of a hyphen unless the hyphen is word-final -- (i.e. a prefix). Otherwise e.g. the accents in the first part of words like -- ко́е-како́й and а́льфа-лу́ч won't remain. -- NOTE: Translit must already be decomposed! See comment at top. function export.make_unstressed_once(ru, tr) return map_last_hyphenated_component(make_unstressed_once_after_hyphen_split, ru, tr) end local function make_unstressed_once_at_beginning_ru(word) -- leave graves alone return rsub(word, "^([^́̈ёЁ]*)([́̈ёЁ])", function(rest, x) return rest .. destresser[x]; end, 1) end -- Make first stressed syllable (acute or diaeresis) unstressed; leave -- graves alone; if NOCONCAT, return individual syllables. -- NOTE: Translit must already be decomposed! See comment at top. function export.make_unstressed_once_at_beginning(ru, tr, noconcat) if not tr then return make_unstressed_once_at_beginning_ru(ru), nil end -- In the presence of TR, we need to do things the hard way, as with -- make_unstressed(). rusyl, trsyl = export.split_syllables(ru, tr) for i=1,#rusyl do local stressed = export.is_stressed(rusyl[i]) if stressed then if rfind(rusyl[i], "[ёЁ]") then trsyl[i] = rsub(trsyl[i], "[Oo]", {["O"] = "E", ["o"] = "e"}) end rusyl[i] = make_unstressed_once_at_beginning_ru(rusyl[i]) -- the following should still work as it will affect accents only trsyl[i] = make_unstressed_once_at_beginning_ru(trsyl[i]) break end end if noconcat then return rusyl, trsyl end -- Also need to apply j correction as otherwise we'll have je after cons return table.concat(rusyl, ""), export.j_correction(table.concat(trsyl, "")) end -- Subfunction of make_ending_stressed(), make_beginning_stressed(), which -- add an acute accent to a syllable that may already have a grave accent; -- in such a case, remove the grave. -- NOTE: Translit must already be decomposed! See comment at top. function export.correct_grave_acute_clash(word, tr) word = rsub(word, "([̀ѐЀѝЍ])́", function(x) return grave_deaccenter[x] .. AC; end) word = rsub(word, AC .. GR, AC) if not tr then return word, nil end tr = rsub(tr, GR .. AC, AC) tr = rsub(tr, AC .. GR, AC) return word, tr end local function make_ending_stressed_ru(word) -- If already ending stressed, just return word so we don't mess up ё if export.is_ending_stressed(word) then return word end -- Destress the last stressed syllable word = make_unstressed_once_ru(word) -- Add an acute to the last syllable word = rsub(word, "([" .. export.vowel_no_jo .. "])([^" .. export.vowel .. "]*)$", "%1́%2") -- If that caused an acute and grave next to each other, remove the grave return export.correct_grave_acute_clash(word) end -- Remove the last primary stress from the word and put it on the final -- syllable. Leave grave accents alone except in the last syllable. -- If final syllable already has primary stress, do nothing. -- NOTE: Translit must already be decomposed! See comment at top. local function make_ending_stressed_after_hyphen_split(ru, tr) if not tr then return make_ending_stressed_ru(ru), nil end -- If already ending stressed, just return ru/tr so we don't mess up ё if export.is_ending_stressed(ru) then return ru, tr end -- Destress the last stressed syllable; pass in "noconcat" so we get -- the individual syllables back rusyl, trsyl = make_unstressed_once_after_hyphen_split(ru, tr, "noconcat") -- Add an acute to the last syllable of both Russian and translit rusyl[#rusyl] = rsub(rusyl[#rusyl], "([" .. export.vowel_no_jo .. "])", "%1" .. AC) trsyl[#trsyl] = rsub(trsyl[#trsyl], "([" .. export.tr_vowel .. "])", "%1" .. AC) -- If that caused an acute and grave next to each other, remove the grave rusyl[#rusyl], trsyl[#trsyl] = export.correct_grave_acute_clash(rusyl[#rusyl], trsyl[#trsyl]) -- j correction didn't get applied in make_unstressed_once because -- we short-circuited it and made it return lists of syllables return table.concat(rusyl, ""), export.j_correction(table.concat(trsyl, "")) end -- Remove the last primary stress from the portion of the word to the right of -- any hyphen (unless the hyphen is word-final) and put it on the final -- syllable. Leave grave accents alone except in the last syllable. If final -- syllable already has primary stress, do nothing. (See make_unstressed_once() -- for why we don't affect stresses to the left of a hyphen.) -- NOTE: Translit must already be decomposed! See comment at top. function export.make_ending_stressed(ru, tr) return map_last_hyphenated_component(make_ending_stressed_after_hyphen_split, ru, tr) end local function make_beginning_stressed_ru(word) -- If already beginning stressed, just return word so we don't mess up ё if export.is_beginning_stressed(word) then return word end -- Destress the first stressed syllable word = make_unstressed_once_at_beginning_ru(word) -- Add an acute to the first syllable word = rsub(word, "^([^" .. export.vowel .. "]*)([" .. export.vowel_no_jo .. "])", "%1%2́") -- If that caused an acute and grave next to each other, remove the grave return export.correct_grave_acute_clash(word) end -- Remove the first primary stress from the word and put it on the initial -- syllable. Leave grave accents alone except in the first syllable. -- If initial syllable already has primary stress, do nothing. -- NOTE: Translit must already be decomposed! See comment at top. function export.make_beginning_stressed(ru, tr) if not tr then return make_beginning_stressed_ru(ru), nil end -- If already beginning stressed, just return ru/tr so we don't mess up ё if export.is_beginning_stressed(ru) then return ru, tr end -- Destress the first stressed syllable; pass in "noconcat" so we get -- the individual syllables back rusyl, trsyl = export.make_unstressed_once_at_beginning(ru, tr, "noconcat") -- Add an acute to the first syllable of both Russian and translit rusyl[1] = rsub(rusyl[1], "([" .. export.vowel_no_jo .. "])", "%1" .. AC) trsyl[1] = rsub(trsyl[1], "([" .. export.tr_vowel .. "])", "%1" .. AC) -- If that caused an acute and grave next to each other, remove the grave rusyl[1], trsyl[1] = export.correct_grave_acute_clash(rusyl[1], trsyl[1]) -- j correction didn't get applied in make_unstressed_once_at_beginning -- because we short-circuited it and made it return lists of syllables return table.concat(rusyl, ""), export.j_correction(table.concat(trsyl, "")) end -- used for tracking and categorization local trailing_letter_type = { ["ш"] = {"sibilant", "cons"}, ["щ"] = {"sibilant", "cons"}, ["ч"] = {"sibilant", "cons"}, ["ж"] = {"sibilant", "cons"}, ["ц"] = {"c", "cons"}, ["к"] = {"velar", "cons"}, ["г"] = {"velar", "cons"}, ["х"] = {"velar", "cons"}, ["ь"] = {"soft-cons", "cons"}, ["ъ"] = {"hard-cons", "cons"}, ["й"] = {"palatal", "cons"}, ["а"] = {"vowel", "hard-vowel"}, ["я"] = {"vowel", "soft-vowel"}, ["э"] = {"vowel", "hard-vowel"}, ["е"] = {"vowel", "soft-vowel"}, ["ѣ"] = {"vowel", "soft-vowel"}, ["и"] = {"i", "vowel", "soft-vowel"}, ["і"] = {"i", "vowel", "soft-vowel"}, ["ѵ"] = {"i", "vowel", "soft-vowel"}, ["ы"] = {"vowel", "hard-vowel"}, ["о"] = {"vowel", "hard-vowel"}, ["ё"] = {"vowel", "soft-vowel"}, ["у"] = {"vowel", "hard-vowel"}, ["ю"] = {"vowel", "soft-vowel"}, } function export.get_stem_trailing_letter_type(stem) local hint = ulower(usub(export.remove_accents(stem), -1)) local hint_types = trailing_letter_type[hint] or {"hard-cons", "cons"} return hint_types end -- Reduce stem by eliminating the "epenthetic" vowel. Applies to -- nominative singular masculine 2nd-declension hard and soft, and -- 3rd-declension feminine in -ь (e.g. любовь). STEM should be the -- result after calling detect_stem_type(), but with final -й if -- present. Normally returns two arguments (STEM and TR), but can be -- called from a template using #invoke and will return one argument -- (STEM, or STEM//TR if TR is present). Returns nil if unable to -- reduce. -- NOTE: Translit must already be decomposed! See comment at top. function export.reduce_stem(stem, tr) local pre, letter, post local pretr, lettertr, posttr local combine_tr = false -- test cases with translit: -- =p.reduce_stem("фе́ез", "fɛ́jez") -> фе́йз, fɛ́jz -- =p.reduce_stem("фе́йез", "fɛ́jez") -> фе́йз, fɛ́jz -- =p.reduce_stem("фе́без", "fɛ́bez") -> фе́бз, fɛ́bz -- =p.reduce_stem("фе́лез", "fɛ́lez") -> фе́льз, fɛ́lʹz -- =p.reduce_stem("феёз", p.decompose("fɛjóz")) -> фейз, fɛjz -- don't worry about the next one, won't occur and translit might -- be wrong anyway -- =p.reduce_stem("фейёз", p.decompose("fɛjjóz")) -> ??? -- =p.reduce_stem("фебёз", p.decompose("fɛbjóz")) -> фебз, fɛbz -- =p.reduce_stem("фелёз", p.decompose("fɛljóz")) -> фельз, fɛlʹz -- =p.reduce_stem("фе́бей", "fɛ́bej") -> фе́бь, fɛ́bʹ -- =p.reduce_stem("фебёй", p.decompose("fɛbjój")) -> фебь, fɛbʹ -- =p.reduce_stem("фе́ей", "fɛ́jej") -> фе́йй, fɛ́jj -- =p.reduce_stem("феёй", p.decompose("fɛjój")) -> фейй, fɛjj -- so this can be called from a template if type(stem) == 'table' then stem, tr = ine(stem.args[1]), ine(stem.args[2]) combine_tr = true end pre, letter, post = rmatch(stem, "^(.*)([оОеЕёЁ])́?([" .. export.cons .. "]+)$") if not pre then return nil, nil end if tr then -- FIXME, may not be necessary to write the posttr portion as a -- consonant + zero or more consonant/accent combinations -- when will -- we ever get an accent after a consonant? That would indicate a -- failure of the decompose mechanism. pretr, lettertr, posttr = rmatch(tr, "^(.*)([oOeE])́?([" .. export.tr_cons .. "][" .. export.tr_cons .. export.accent .. "]*)$") if not pretr then return nil, nil -- should not happen unless tr is really messed up end -- Unless Cyrillic stem ends in -й, Latin stem shouldn't end in -j, -- or we will get problems with cases like индонези́ец//indonɛzíjec. if not rfind(pre, "[йЙ]$") then pretr = rsub(pretr, "[jJ]$", "") end end if letter == "О" or letter == "о" then -- FIXME, what about when the accent is on the removed letter? if post == "й" or post == "Й" then -- FIXME, is this correct? return nil, nil end letter = "" else local is_upper = rfind(post, "[" .. export.uppercase .. "]") if rfind(pre, "[" .. export.vowel .. "]́?$") then letter = is_upper and "Й" or "й" elseif post == "й" or post == "Й" then letter = is_upper and "Ь" or "ь" post = "" if posttr then posttr = "" end elseif (rfind(post, "[" .. export.velar .. "]$") and rfind(pre, "[" .. export.cons_except_sib_c .. "]$")) or (rfind(post, "[^йЙ" .. export.velar .. "]$") and rfind(pre, "[лЛ]$")) then letter = is_upper and "Ь" or "ь" else letter = "" end end stem = pre .. letter .. post if tr then tr = pretr .. export.translit(letter) .. posttr end if combine_tr then return export.combine_russian_tr(stem, tr) else return stem, tr end end -- Generate the dereduced stem given STEM and EPENTHETIC_STRESS (which -- indicates whether the epenthetic vowel should be stressed); this is -- without any terminating non-syllabic ending, which is added if needed by -- the calling function. Normally returns two arguments (STEM and TR), but -- can be called from a template using #invoke and will return one argument -- (STEM, or STEM//TR if TR is present). Returns nil if unable to dereduce. -- NOTE: Translit must already be decomposed! See comment at top. function export.dereduce_stem(stem, tr, epenthetic_stress) local combine_tr = false -- so this can be called from a template if type(stem) == 'table' then stem, tr, epenthetic_stress = ine(stem.args[1]), ine(stem.args[2]), ine(stem.args[3]) combine_tr = true end if epenthetic_stress then stem, tr = export.make_unstressed_once(stem, tr) end local pre, letter, post local pretr, lettertr, posttr -- FIXME!!! Deal with this special case --if not (z.stem_type == 'soft' and _.equals(z.stress_type, {'b', 'f'}) -- we should ignore asterix for 2*b and 2*f (so to process it just like 2b or 2f) -- or _.contains(z.specific, '(2)') and _.equals(z.stem_type, {'velar', 'letter-ц', 'vowel'})) -- and also the same for (2)-specific and 3,5,6 stem-types --then -- I think this corresponds to our -ья and -ье types, which we -- handle separately --if z.stem_type == 'vowel' then -- 1). -- if _.equals(z.stress_type, {'b', 'c', 'e', 'f', "f'", "b'" }) then -- gen_pl ending stressed -- TODO: special vars for that -- z.stems['gen_pl'] = _.replace(z.stems['gen_pl'], 'ь$', 'е́') -- else -- z.stems['gen_pl'] = _.replace(z.stems['gen_pl'], 'ь$', 'и') -- end --end pre, letter, post = rmatch(stem, "^(.*)([" .. export.cons .. "])([" .. export.cons .. "])$") if tr then pretr, lettertr, posttr = rmatch(tr, "^(.*)(" .. export.tr_cons_acc_re .. ")(" .. export.tr_cons_acc_re .. ")$") if pre and not pretr then return nil, nil -- should not happen unless tr is really messed up end end if pre then local is_upper = rfind(post, "[" .. export.uppercase .. "]") local epvowel if rfind(letter, "[ьйЬЙ]") then letter = "" lettertr = "" if rfind(post, "[цЦ]$") or not epenthetic_stress then epvowel = is_upper and "Е" or "е" else epvowel = is_upper and "Ё" or "ё" end elseif rfind(letter, "[" .. export.cons_except_sib_c .. "]") and rfind(post, "[" .. export.velar .. "]") or rfind(letter, "[" .. export.velar .. "]") then epvowel = is_upper and "О" or "о" elseif post == "ц" or post == "Ц" then epvowel = is_upper and "Е" or "е" elseif epenthetic_stress then if rfind(letter, "[" .. export.sib .. "]") then epvowel = is_upper and "О́" or "о́" else epvowel = is_upper and "Ё" or "ё" end else epvowel = is_upper and "Е" or "е" end assert(epvowel) stem = pre .. letter .. epvowel .. post if tr then tr = pretr .. lettertr .. export.translit(epvowel) .. posttr tr = export.j_correction(tr) end if epenthetic_stress then stem, tr = export.make_ending_stressed(stem, tr) end if combine_tr then return export.combine_russian_tr(stem, tr) else return stem, tr end end return nil, nil end -- Parse an entry that potentially has final footnote symbols and initial * -- for a hypothetical entry into initial symbols, text and final symbols. function export.split_symbols(entry, do_subscript) local prefentry, finalnotes = m_table_tools.separate_notes(entry) local initnotes, text = rmatch(prefentry, "(%*?)(.*)$") return initnotes, text, finalnotes end -------------------------------------------------------------------------- -- Used for manual translit -- -------------------------------------------------------------------------- function export.translit_no_links(text) return export.translit(require("Module:links").remove_links(text)) end function export.split_russian_tr(term, dopair) local ru, tr if not rfind(term, "//") then ru = term else splitvals = rsplit(term, "//") if #splitvals ~= 2 then error("Must have at most one // in a Russian//translit expr: '" .. term .. "'") end ru, tr = splitvals[1], export.decompose(splitvals[2]) end if dopair then return {ru, tr} else return ru, tr end end function export.combine_russian_tr(ru, tr) if type(ru) == "table" then ru, tr = unpack(ru) end if tr then return ru .. "//" .. tr else return ru end end local function concat_maybe_moving_notes(x, y, movenotes) if movenotes then local xentry, xnotes = m_table_tools.separate_notes(x) local yentry, ynotes = m_table_tools.separate_notes(y) return xentry .. yentry .. xnotes .. ynotes else return x .. y end end -- Concatenate two Russian strings RU1 and RU2 that may have corresponding -- manual transliteration TR1 and TR2 (which should be nil if there is no -- manual translit). If DOPAIR, return a two-item list of the combined -- Russian and manual translit (which will be nil if both TR1 and TR2 are -- nil); else, return two values, the combined Russian and manual translit. -- If MOVENOTES, extract any footnote symbols at the end of RU1 and move -- them to the end of the concatenated string, before any footnote symbols -- for RU2; same thing goes for TR1 and TR2. function export.concat_russian_tr(ru1, tr1, ru2, tr2, dopair, movenotes) local ru, tr if not tr1 and not tr2 then ru = concat_maybe_moving_notes(ru1, ru2, movenotes) else if not tr1 then tr1 = export.translit_no_links(ru1) end if not tr2 then tr2 = export.translit_no_links(ru2) end ru, tr = concat_maybe_moving_notes(ru1, ru2, movenotes), export.j_correction(concat_maybe_moving_notes(tr1, tr2, movenotes)) end if dopair then return {ru, tr} else return ru, tr end end -- Concatenate two Russian/translit combinations (where each combination is -- a two-element list of {RUSSIAN, TRANSLIT} where TRANSLIT may be nil) by -- individually concatenating the Russian and translit portions, and return -- a concatenated combination as a two-element list. If the manual translit -- portions of both terms on entry are nil, the result will also have nil -- manual translit. If MOVENOTES, extract any footnote symbols at the end -- of TERM1 and move them after the concatenated string and before any -- footnote symbols at the end of TERM2. function export.concat_paired_russian_tr(term1, term2, movenotes) assert(type(term1) == "table") assert(type(term2) == "table") local ru1, tr1 = term1[1], term1[2] local ru2, tr2 = term2[1], term2[2] return export.concat_russian_tr(ru1, tr1, ru2, tr2, "dopair", movenotes) end function export.concat_forms(forms) local joined_rutr = {} for _, form in ipairs(forms) do table.insert(joined_rutr, export.combine_russian_tr(form)) end return table.concat(joined_rutr, ",") end -- Given a list of forms, where each form is a two-element list of {RUSSIAN, TRANSLIT}, strip footnote symbols from the -- end of the Russian and translit. function export.strip_notes_from_forms(forms) local newforms = {} for _, form in ipairs(forms) do local ru, tr = form[1], form[2] ru, _ = m_table_tools.separate_notes(ru) if tr then tr, _ = m_table_tools.separate_notes(tr) end table.insert(newforms, {ru, tr}) end return newforms end -- Given a list of forms, where each form is a two-element list of {RUSSIAN, TRANSLIT}, unzip into parallel lists of -- Russian and translit. The latter list may have gaps in it. function export.unzip_forms(forms) local rulist = {} local trlist = {} for i, form in ipairs(forms) do local ru, tr = form[1], form[2] rulist[i] = ru trlist[i] = tr end return rulist, trlist end -- Given parallel lists of Russian and translit (where the latter list may have gaps in it), return a list of forms, -- where each form is a two-element list of {RUSSIAN, TRANSLIT}. function export.zip_forms(rulist, trlist) local forms = {} for i, ru in ipairs(rulist) do table.insert(forms, {ru, trlist[i]}) end return forms end local function any_forms_have_translit(forms) for _, form in ipairs(forms) do if form[2] then return true end end return false end -- Given a list of forms, where each form is a two-element list of {RUSSIAN, TRANSLIT}, combine forms with -- identical Russian, concatenating the translit with a comma in between. function export.combine_translit_of_duplicate_forms(forms) if #forms == 0 then return forms end -- Optimization to avoid creating a new list in the majority case when no translit exists. if not any_forms_have_translit(forms) then return forms end local newforms = {} table.insert(newforms, {forms[1][1], forms[1][2]}) for i = 2, #forms do local found_duplicate = false for j = 1, #newforms do -- If the Russian of the next form is the same as that of the last one, combine their translits and modify -- newforms[] in-place. Otherwise add the next form to newforms[]. Make sure to clone the form rather than -- just appending it directly since we may modify it in-place; we don't want to side-effect `forms` as passed -- in. if forms[i][1] == newforms[j][1] then local tr1 = newforms[j][2] local tr2 = forms[i][2] if not tr1 and not tr2 then -- this shouldn't normally happen else tr1 = tr1 or export.translit_no_links(newforms[j][1]) tr2 = tr2 or export.translit_no_links(forms[i][1]) if tr1 == tr2 then -- this shouldn't normally happen else newforms[j][2] = tr1 .. ", " .. tr2 end end found_duplicate = true break end end if not found_duplicate then table.insert(newforms, {forms[i][1], forms[i][2]}) end end return newforms end -- Given a list of forms, where each form is a two-element list of {RUSSIAN, TRANSLIT}, split cases where two different -- transliterations have been packed into a single translit field by creating two adjacent term/translit pairs. This is -- the opposite operation of combine_translit_of_duplicate_forms(). function export.split_translit_of_duplicate_forms(forms) if #forms == 0 then return forms end -- Optimization to avoid creating a new list in the majority case when no translit exists. if not any_forms_have_translit(forms) then return forms end local newforms = {} for _, form in ipairs(forms) do local ru, tr = unpack(form) if not tr or not tr:find(",") or ru:find(",") then table.insert(newforms, form) else local split_trs = rsplit(tr, ",%s*") local default_tr = export.translit_no_links(ru) for _, split_tr in ipairs(split_trs) do if split_tr == default_tr then split_tr = nil end table.insert(newforms, {ru, split_tr}) end end end return newforms end function export.strip_ending(ru, tr, ending) local strippedru = rsub(ru, ending .. "$", "") if strippedru == ru then error("Argument " .. ru .. " doesn't end with expected ending " .. ending) end ru = strippedru tr = export.strip_tr_ending(tr, ending) return ru, tr end function export.strip_tr_ending(tr, ending) if not tr then return nil end local endingtr = rsub(export.translit_no_links(ending), "^([Jj])", "%1?") local strippedtr = rsub(tr, endingtr .. "$", "") if strippedtr == tr then error("Translit " .. tr .. " doesn't end with expected ending " .. endingtr) end return strippedtr end return export 7fbl0z90bq10opmbo1lkbfcxt8nragr Module:table tools 828 5227 13218 2022-07-26T12:17:03Z Asinis632 1829 Created page with "local export = {} local m_links = require("Module:links") local u = mw.ustring.char local notes_ranges = { -- First three represent symbols in ISO-8859-1 -- Including ÷ (U+00F7) × (U+00D7) § (U+00B7) ¤ (U+00A4) {0xA1,0xBF}, {0xD7,0xD7}, -- × {0xF7,0xF7}, -- ÷ -- Next two are "General Punctuation" minus non-spacing chars -- First one includes † (U+2020) ‡ (U+2021) • (U+2022) ※ (U+203B) ⁕ (U+2055) {0x2010,0x2027}, {0x2030,0x205E}, --..." Scribunto text/plain local export = {} local m_links = require("Module:links") local u = mw.ustring.char local notes_ranges = { -- First three represent symbols in ISO-8859-1 -- Including ÷ (U+00F7) × (U+00D7) § (U+00B7) ¤ (U+00A4) {0xA1,0xBF}, {0xD7,0xD7}, -- × {0xF7,0xF7}, -- ÷ -- Next two are "General Punctuation" minus non-spacing chars -- First one includes † (U+2020) ‡ (U+2021) • (U+2022) ※ (U+203B) ⁕ (U+2055) {0x2010,0x2027}, {0x2030,0x205E}, -- Next one is "Superscripts and Subscripts" and "Currency Symbols" {0x2070,0x20CF}, -- Next one is a whole series of symbol ranges {0x2100,0x2B5F}, -- Next one is "Supplemental Punctuation" {0x2E00,0x2E3F} } local unicode_ranges = {} for _, range in ipairs(notes_ranges) do table.insert(unicode_ranges, u(range[1]) .. "-" .. u(range[2])) end local unicode_range_str = table.concat(unicode_ranges, "") local notes_re = "[%*%~%@%#%$%%%^%&%+0-9_ " .. unicode_range_str .. "]*" local function manipulate_entry(entries, f) entries = entries or "" entries = mw.text.split(mw.ustring.gsub(entries, "^%s*(.-)%s*$", "%1"), "%s*,%s*") local sep = "" local ret = "" for _, entry in ipairs(entries) do ret = ret .. sep .. (entry == "-" and "—" or entry == "" and "" or f(entry)) sep = ", " end return ret end local function gather_args(frame) local args = {} for key, val in pairs(frame.args) do if val ~= "" then args[key] = val end end local i = 1 for _, val in ipairs(frame:getParent().args) do if val and val ~= "" then while args[i] do i = i + 1 end args[i] = val i = i + 1 end end local lang = args["lang"] if not lang then lang = args[1] local n = 1 while args[n] do args[n] = args[n + 1] n = n + 1 end end return lang, args end function export.separate_notes(entry) local notes entry, notes = mw.ustring.match(entry, "^(.-)(" .. notes_re .. ")$") return entry, notes end function export.superscript_notes(notes) if notes ~= "" then notes = "<sup>" .. mw.ustring.gsub(notes, "_", " ") .. "</sup>" end return notes end function export.get_notes(entry) local notes entry, notes = export.separate_notes(entry) notes = export.superscript_notes(notes) return entry, notes end function export.separate_initial_notes(entry) local notes notes, entry = mw.ustring.match(entry, "^(" .. notes_re .. ")(.*)$") return notes, entry end function export.get_initial_notes(entry) local notes notes, entry = export.separate_initial_notes(entry) notes = export.superscript_notes(notes) return notes, entry end function export.linkify_entry(lang, entries, allow_self_link, prep) if type(lang) == "table" then local args lang, args = gather_args(lang) if (args["prep"] or "") ~= "" then local mod, func = unpack(mw.text.split(args["prep"], "#", true)) prep = require("Module:" .. mod)[func] end entries = args[1] allow_self_link = (args["allowSelfLink"] or "") ~= "" end lang = require("Module:languages").getByCode(lang) local function f(entry) local e, notes = export.get_notes(entry) local ep = prep and prep(e) return m_links.language_link({lang = lang, term = ep or e, alt = ep and e}, allow_self_link) .. notes end return manipulate_entry(entries, f) end function export.translit_entry(lang, entries) if type(lang) == "table" then local args lang, args = gather_args(lang) entries = args[1] end lang = require("Module:languages").getByCode(lang) local function f(entry) local e, notes = export.get_notes(entry) return lang:transliterate(e) .. notes end return manipulate_entry(m_links.remove_links(entries), f) end function export.format_entry(lang, entries) if type(lang) == "table" then local args lang, args = gather_args(lang) entries = args[1] end return manipulate_entry(m_links.remove_links(entries), function(entry) local e, n = export.get_notes(entry); return e .. n end) end function export.first_entry(lang, entries) if type(lang) == "table" then local args lang, args = gather_args(lang) entries = args[1] end local entry = mw.text.split(mw.ustring.gsub(entries, "^%s*(.-)%s*$", "%1"), "%s*,%s*")[1] local e, notes = export.get_notes(entry) return e .. notes end return export 33xw3d68wuwgye7s4452wzebuwkgksk Module:ru-nominal 828 5228 13219 2022-07-26T12:18:07Z Asinis632 1829 Created page with "--[[ This module holds functions shared between ru-noun and ru-adjective. ]] local export = {} local lang = require("Module:languages").getByCode("ru") local m_links = require("Module:links") local m_table = require("Module:table") local com = require("Module:ru-common") local m_ru_translit = require("Module:ru-translit") local m_table_tools = require("Module:table tools") local u = mw.ustring.char local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local usu..." Scribunto text/plain --[[ This module holds functions shared between ru-noun and ru-adjective. ]] local export = {} local lang = require("Module:languages").getByCode("ru") local m_links = require("Module:links") local m_table = require("Module:table") local com = require("Module:ru-common") local m_ru_translit = require("Module:ru-translit") local m_table_tools = require("Module:table tools") local u = mw.ustring.char local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local usub = mw.ustring.sub local HYPMARKER = "⟐" -- version of rsubn() that discards all but the first return value local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end -- Insert an entry into an existing list if not already present, comparing the entry to items in the existing list -- using a key function. If entry already found, combine it into the existing entry using combine_func, a function of -- two arguments (the existing and new entries), which should return the combined entry. Return false if entry already -- found, true if new entry inserted. If combine_func not specified, the existing entry is left alone. If combine_func -- is specified, the return value will be written over the existing value (i.e. the existing list will be modified -- in-place). -- -- FIXME: General enough to consider moving to [[Module:table]]. local function insert_if_not_by_key(list, new_entry, keyfunc, combine_func) local new_entry_key = keyfunc(new_entry) for i, item in ipairs(list) do local item_key = keyfunc(item) if m_table.deepEquals(item_key, new_entry_key) then if combine_func then list[i] = combine_func(item, new_entry) end return false end end table.insert(list, new_entry) return true end -------------------------------------------------------------------------- -- Used for manual translit -- -------------------------------------------------------------------------- function export.combine_stem_and_suffix(stem, tr, suf, rules, old) local first = usub(suf, 1, 1) if rules then local conv = rules[first] if conv then local ending = usub(suf, 2) -- The following regexp is not quite the same as com.vowels. For one thing -- it includes й, which is important. It leaves out ы, which may or may not -- be important. if old and conv == "и" and rfind(ending, "^́?[аеёиійоуэюяѣ]") then conv = "і" end suf = conv .. ending end end -- If <adj> is present in the suffix, it means we need to translate it -- specially; do that now. local is_adj = rfind(suf, "<adj>") suf = rsub(suf, "<adj>", "") local suftr = is_adj and m_ru_translit.tr_adj(suf, "include monosyllabic jo accent") return com.concat_russian_tr(stem, tr, suf, suftr, "dopair"), suf end -------------------------------------------------------------------------- -- Formatting forms for display -- -------------------------------------------------------------------------- -- Generate a string to substitute into a particular form in a Wiki-markup table. `forms` is the list of forms, -- generated by concat_word_forms(). `is_lemma` is true if we're formatting the entry for use in displaying the lemma -- in the declension table title. In this case, we don't include the translit, and remove monosyllabic accents from the -- Cyrillic (but not in multiword expressions). `accel_form` is the form code to speicfy in the accelerator, e.g. -- 'nom|m|s', or nil for no accelerator. `lemma_forms` is the list of {RU, TR} lemma forms for use in the accelerator, -- or nil if `accel_form` is nil. `remove_monosyllabic_accents_lemma_only` indicates that monosyllabic accents should -- be removed only in the lemma; otherwise we remove them from all forms. (FIXME: Rethink why we have this flag; we -- should be consistent.) function export.show_form(forms, is_lemma, accel_form, lemma_forms, remove_monosyllabic_accents_lemma_only) local russianvals = {} local latinvals = {} local lemmavals = {} -- First fetch the lemma forms and translit. If there are adjacent forms that have identical Russian including -- stress but different translit (e.g. азербайджа́нец with translits 'azerbajdžánec' and 'azɛrbajdžánec'), we -- combine the translits, comma-separating them. (This is necessary because there is currently only one tr= -- field per term.) We don't do this when processing the forms below; instead we handle this in a different -- and more general fashion (see below). local lemmaru, lemmatr if accel_form and lemma_forms and lemma_forms[1] ~= "-" then lemma_forms = com.combine_translit_of_duplicate_forms(com.strip_notes_from_forms(lemma_forms)) for i, form in ipairs(lemma_forms) do local ru, tr = unpack(lemma_forms[i]) ru, tr = com.remove_monosyllabic_accents(ru, tr) lemma_forms[i] = {ru, tr} end lemmaru, lemmatr = com.unzip_forms(lemma_forms) end -- Accumulate separately the Russian and transliteration into RUSSIANVALS and LATINVALS, then concatenate each down -- below. We need a fair amount of logic here: -- (1) to separate out footnote symbols; -- (2) to separate out the hypothetical marker (a footnote symbol but causes display of the Russian and translit -- in a special font); -- (3) to maybe remove monosyllabic accents; -- (4) to deduplicate repeated forms. -- We used to generate the display (HTML) as we went, but this prevented proper deduplication because the -- accelerator classes included in the HTML were different for otherwise identical forms. (Specifically, if two -- forms are the same in the Russian but different in the translit, the Russian will have different display forms -- because the translit is included in the accelerator classes.) So what we do is accumulate, separately for the -- Russian and translit, objects containing the entry (Russian or translit), the separated footnote symbols, -- whether the entry is hypothetical, and (for Russian only) the corresponding translit(s), for accelerator -- generation. As we accumulate, we duduplicate based only on comparing the entries of two objects. If we need to -- deduplicate two objects, we also need to combine their footnotes and transliteration (in the latter case, by -- comma-separating; we do this because there is only one tr= field for each term). for _, form in ipairs(forms) do local ru, tr = form[1], form[2] local ruentry, runotes = m_table_tools.separate_notes(ru) local trentry, trnotes if tr then trentry, trnotes = m_table_tools.separate_notes(tr) trnotes = rsub(trnotes, HYPMARKER, "") end if (is_lemma or not remove_monosyllabic_accents_lemma_only) then ruentry, trentry = com.remove_monosyllabic_accents(ruentry, trentry) end local ishyp = rfind(runotes, HYPMARKER) if ishyp then runotes = rsub(runotes, HYPMARKER, "") end local ruobj = {entry = ruentry, tr = {trentry or true}, ishyp = ishyp, notes = runotes} if not trentry then trentry = com.translit_no_links(ruentry) end if not trnotes then trnotes = com.translit_no_links(runotes) end local trobj = {entry = trentry, ishyp = ishyp, notes = trnotes} local function keyfunc(obj) return obj.entry end local function combine_func_ru(obj1, obj2) for _, tr in ipairs(obj2.tr) do m_table.insertIfNot(obj1.tr, tr) end obj1.notes = obj1.notes .. obj2.notes obj1.ishyp = obj1.ishyp or obj2.ishyp return obj1 end local function combine_func_tr(obj1, obj2) obj1.notes = obj1.notes .. obj2.notes obj1.ishyp = obj1.ishyp or obj2.ishyp return obj1 end if is_lemma then -- m_table.insertIfNot(lemmavals, ruspan .. " (" .. trspan .. ")") insert_if_not_by_key(lemmavals, ruobj, keyfunc, combine_func_ru) else insert_if_not_by_key(russianvals, ruobj, keyfunc, combine_func_ru) insert_if_not_by_key(latinvals, trobj, keyfunc, combine_func_tr) end end -- Now finally format each object and concatenate them together. local function concatenate_ru(objs) local is_missing = false for i, obj in ipairs(objs) do local accel = nil if lemmaru then local translit = nil if #obj.tr == 1 and obj.tr[1] == true then -- no translit else for j, tr in ipairs(obj.tr) do if tr == true then obj.tr[j] = com.translit_no_links(obj.entry) end end translit = table.concat(obj.tr, ", ") end accel = {form = accel_form, translit = translit, lemma = lemmaru, lemma_translit = lemmatr} end if obj.entry == "-" and #forms == 1 then objs[i] = "&mdash;" is_missing = true end if obj.ishyp then -- no accelerator for hypothetical forms objs[i] = m_links.full_link({lang = lang, term = nil, alt = obj.entry, tr = "-"}, "hypothetical") else objs[i] = m_links.full_link({lang = lang, term = obj.entry, tr = "-", accel = accel}) end objs[i] = objs[i] .. m_table_tools.superscript_notes(obj.notes) end return table.concat(objs, ", "), is_missing end local function concatenate_tr(objs) local scriptutils = require("Module:script utilities") for i, obj in ipairs(objs) do local trspan = m_links.remove_links(obj.entry) .. m_table_tools.superscript_notes(obj.notes) if obj.ishyp then -- FIXME, in the old [[Module:ru-noun]] code, notes were omitted from hypothetical entries. Correct? objs[i] = scriptutils.tag_text(trspan, lang, require("Module:scripts").getByCode("Latn"), "hypothetical") else objs[i] = scriptutils.tag_translit(trspan, lang, "default", " style=\"color: #888;\"") end end return table.concat(objs, ", ") end if is_lemma then local russian_span, is_missing = concatenate_ru(lemmavals) return russian_span else local russian_span, is_missing = concatenate_ru(russianvals) if is_missing then return russian_span end local latin_span = concatenate_tr(latinvals) return russian_span .. "<br />" .. latin_span end end -------------------------------------------------------------------------- -- Sibilant/Velar/ц rules -- -------------------------------------------------------------------------- local stressed_sibilant_rules = { ["я"] = "а", ["ы"] = "и", ["ё"] = "о́", ["ю"] = "у", } local stressed_c_rules = { ["я"] = "а", ["ё"] = "о́", ["ю"] = "у", } local unstressed_sibilant_rules = { ["я"] = "а", ["ы"] = "и", ["о"] = "е", ["ю"] = "у", } local unstressed_c_rules = { ["я"] = "а", ["о"] = "е", ["ю"] = "у", } local velar_rules = { ["ы"] = "и", } export.stressed_rules = { ["ш"] = stressed_sibilant_rules, ["щ"] = stressed_sibilant_rules, ["ч"] = stressed_sibilant_rules, ["ж"] = stressed_sibilant_rules, ["ц"] = stressed_c_rules, ["к"] = velar_rules, ["г"] = velar_rules, ["х"] = velar_rules, } export.unstressed_rules = { ["ш"] = unstressed_sibilant_rules, ["щ"] = unstressed_sibilant_rules, ["ч"] = unstressed_sibilant_rules, ["ж"] = unstressed_sibilant_rules, ["ц"] = unstressed_c_rules, ["к"] = velar_rules, ["г"] = velar_rules, ["х"] = velar_rules, } export.nonsyllabic_suffixes = m_table.listToSet({"", "ъ", "ь", "й"}) export.sibilant_suffixes = m_table.listToSet({"ш", "щ", "ч", "ж"}) return export arltsphlswyj8egvivtawsw6kz51221 Module:ru-adjective 828 5230 13220 2022-07-26T12:19:11Z Asinis632 1829 Created page with "--[=[ This module contains functions for creating inflection tables for Russian adjectives. Author: Benwing, rewritten from early version by Wikitiki89 Arguments: 1: lemma; nom sg, or just the stem if an explicit declension type is given in arg 2 2: declension type (usually omitted to autodetect based on the lemma), along with any short accent type and optional irregular short stem; see below. CASE_NUMGEN: Override a given form; see abbreviatio..." Scribunto text/plain --[=[ This module contains functions for creating inflection tables for Russian adjectives. Author: Benwing, rewritten from early version by Wikitiki89 Arguments: 1: lemma; nom sg, or just the stem if an explicit declension type is given in arg 2 2: declension type (usually omitted to autodetect based on the lemma), along with any short accent type and optional irregular short stem; see below. CASE_NUMGEN: Override a given form; see abbreviations below suffix: any suffix to attach unchanged to the end of each form notes: Notes to add to the end of the table title: Override the title shorttail: Footnote (e.g. *, 1, 2, etc.) to add to short forms if there's more than one; automatically superscripted shorttailall: Same as shorttail= but applies to all short forms even if there's only one CASE_NUMGEN_tail: Like shorttailall but only for a specific form nofull: Short forms only Case abbreviations: nom: nominative gen: genitive dat: dative acc: accusative ins: instrumental pre: prepositional short: short form Number/gender abbreviations: m: masculine singular n: neuter singular f: feminine singular p: plural mp: masculine plural (old-style and special numeral tables only) fp: masculine plural (special numeral tables only) Animacy abbreviations: an: animate in: inanimate Declension-type argument (arg 2): Form is DECLSPEC or DECLSPEC,DECLSPEC,... where DECLSPEC is one of the following: DECLTYPE:SHORTACCENT:SHORTSTEM DECLTYPE:SHORTACCENT DECLTYPE SHORTACCENT:SHORTSTEM SHORTACCENT (blank) DECLTYPE should normally be omitted, and the declension autodetected from the ending; or it should be ь, to indicate that an adjective in -ий is of the possessive variety with an extra -ь- in most of the endings. Alternatively, it can be an explicit declension type, in which case the lemma field needs to be replaced with the bare stem; the following are the possibilities: ый ий ой ьий short mixed manual (new-style) ый ій ьій short stressed-short mixed proper stressed-proper ъ-short ъ-stressed-short ъ-mixed ъ-proper ъ-stressed-proper manual (old-style, where ъ-* is a synonym for *, for any *) SHORTACCENT is one of a a' b b' c c' c'' to auto-generate the short forms with the specified accent pattern (following Zaliznyak); if omitted, no short forms will be auto-generated. SHORTACCENT can contain a * in it for "reducible" adjectives, where the short masculine singular has an epenthetic vowel in the final syllable. It can also contain (1) or (2) to indicate special cases. Both are used in conjunction with adjectives in -нный/-нний. Special case (1) causes the short masculine singular to end in -н instead of -нн; special case (2) causes all short forms to end this way. SHORTSTEM, if present, is used as the short stem to base the short forms off of, instead of the normal adjective long stem (possibly with a final-syllable accent added in the case of declension type -о́й). TODO: 1. Figure out what the symbol X-inside-square (⊠) means, which seems to go with all adjectives in -о́й with multi-syllabic stems. It may mean that the masculine singular short form is missing. If this indeed a regular thing, we need to implement it (and if it's regular but means something else, we need to implement that, too). Also figure out what the other signs on pages 68-76 etc. mean: -, X, ~, П₂, Р₂, diamond (♢), triangle (△; might simply mean a misc. irregularity; explained on p. 61). 2. Mark irregular overridden forms with △ (esp. appropriate for short forms). 3. Should non-reducible adjectives in -нный and -нний default to special case (1)? 4. In the case of a non-dereducible short masc sing of stress type b, we don't currently move the stress to the last syllable. Should we? 5. FIXME: In decline(), we used to default acc_n to nom_n. Now we do that in handle_forms_and_overrides(). Verify that this is more correct. 6. FIXME: Allow multiple heads, both to handle cases where two manual translits exist (or rather, one automatic and one manual), and cases where two stresses are possible, e.g. мину́вший or ми́нувший. 7. FIXME: Add code to generate the regular comparative. The rules are as follows: If the stem doesn't end in к г х, add -ee with no stress change if the short form is type a, else add -е́е (including type a'). If the stem ends in к г х, turn the last consonant into ч ж ш, add -е, and place the stress on the syllable preceding the ending. (E.g. дорого́й -> доро́же) ]=]-- local m_utilities = require("Module:utilities") local m_links = require("Module:links") local m_table = require("Module:table") local com = require("Module:ru-common") local nom = require("Module:ru-nominal") local strutils = require("Module:string utilities") local m_table_tools = require("Module:table tools") local m_debug = require("Module:debug") local export = {} local lang = require("Module:languages").getByCode("ru") ----------------------------- Utility functions ------------------------ local u = mw.ustring.char local rfind = mw.ustring.find local rsubn = mw.ustring.gsub local rmatch = mw.ustring.match local rsplit = mw.text.split local ulower = mw.ustring.lower local usub = mw.ustring.sub -- version of rsubn() that discards all but the first return value local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end -- version of rsubn() that returns a 2nd argument boolean indicating whether -- a substitution was made. local function rsubb(term, foo, bar) local retval, nsubs = rsubn(term, foo, bar) return retval, nsubs > 0 end -- Insert a single form (consisting of {RUSSIAN, TR}) or a list of such -- forms into an existing list of such forms, adding NOTESYM (a string or nil) -- to the new forms if not nil. Return whether an insertion was performed. local function insert_forms_into_existing_forms(existing, newforms, notesym) if type(newforms) ~= "table" then newforms = {newforms} end local inserted = false for _, item in ipairs(newforms) do if not m_table.contains(existing, item) then if notesym then item = com.concat_paired_russian_tr(item, {notesym}) end table.insert(existing, item) inserted = true end end return inserted end local function track(page) m_debug.track("ru-adjective/" .. page) return true end -- Fancy version of ine() (if-not-empty). Converts empty string to nil, -- but also strips leading/trailing space and then single or double quotes, -- to allow for embedded spaces. local function ine(arg) if not arg then return nil end arg = rsub(arg, "^%s*(.-)%s*$", "%1") if arg == "" then return nil end local inside_quotes = rmatch(arg, '^"(.*)"$') if inside_quotes then return inside_quotes end inside_quotes = rmatch(arg, "^'(.*)'$") if inside_quotes then return inside_quotes end return arg end -- Clone parent's args while also assigning nil to empty strings. local function clone_args(frame) local args = {} for pname, param in pairs(frame:getParent().args) do args[pname] = ine(param) end return args end -------------------- Global declension/case/etc. variables ------------------- -- 'enable_categories' is a special hack for testing, which disables all -- category insertion if false. Delete this as soon as we've verified the -- working of the category code and created all the necessary categories. local enable_categories = true local declensions = {} local declensions_old = {} local internal_notes_table = {} local internal_notes_table_old = {} local internal_notes_genders = {} local internal_notes_genders_old = {} local short_declensions = {} local short_declensions_old = {} -- Formerly used for the ой-rare type, which has been removed; but keep -- the code around in case we need it later. local short_internal_notes_table = {} local short_internal_notes_table_old = {} local short_stress_patterns = {} local long_cases = { "nom_m", "nom_n", "nom_f", "nom_p", "gen_m", "gen_f", "gen_p", "dat_m", "dat_f", "dat_p", "acc_m_an", "acc_m_in", "acc_p_an", "acc_p_in", "acc_f", "acc_n", "ins_m", "ins_f", "ins_p", "pre_m", "pre_f", "pre_p", -- extra old long cases "nom_mp", "acc_mp_an", "acc_mp_in", -- extra dva cases "nom_fp", "acc_fp_an", "acc_fp_in", -- extra oba cases "gen_mp", "gen_fp", "dat_mp", "dat_fp", "ins_mp", "ins_fp", "pre_mp", "pre_fp", -- extra cases for compounds of два "acc_mp", "acc_fp", } -- Short cases and corresponding numbered arguments local short_cases = { "short_m", "short_n", "short_f", "short_p" } -- Create master list of all possible cases (actually case/number/gender pairs) local all_cases = mw.clone(long_cases) for _, case in ipairs(short_cases) do m_table.insertIfNot(all_cases, case) end -- If enabled, compare this module with new version of module to make -- sure all declensions are the same. local test_new_ru_adjective_module = false -- Forward references to functions local tracking_code local categorize local detect_stem_and_accent_type local construct_bare_and_short_stem local decline local canonicalize_override local handle_forms_and_overrides local decline_short local make_table -------------------------------------------------------------------------- -- Main code -- -------------------------------------------------------------------------- -- Implementation of main entry point function export.do_generate_forms(args, old, manual) local orig_args if test_new_ru_adjective_module then orig_args = mw.clone(args) end if args[3] or args[4] or args[5] or args[6] then error("Numbered short forms no longer supported") end if args.shorttailall then track("shorttailall") end local SUBPAGENAME = mw.title.getCurrentTitle().subpageText args.forms = {} args.categories = {} old = old or args.old args.old = old args.suffix = com.split_russian_tr(args.suffix or "", "dopair") args.internal_notes = {} -- Superscript footnote marker at beginning of note, similarly to what's -- done at end of forms. if args.notes then local notes, entry = m_table_tools.get_initial_notes(args.notes) args.notes = notes .. entry end local overall_short_forms_allowed manual = manual or args[2] == "manual" args.manual = manual local decl_types = manual and "$" or args[2] or "" local lemmas = manual and "-" or args[1] or SUBPAGENAME local normal_short_classes, rare_short_classes, dated_short_classes local saw_no_short for _, lemma_and_tr in ipairs(rsplit(lemmas, ",")) do -- reset these for each lemma so we get the short classes of the last -- lemma (doesn't really matter, as they should be the same for all -- lemmas) normal_short_classes = {} rare_short_classes = {} dated_short_classes = {} saw_no_short = false for _, decl_type in ipairs(rsplit(decl_types, ",")) do local lemma, lemmatr = com.split_russian_tr(lemma_and_tr) -- if lemma ends with -ся, strip it and act as if suffix=ся given -- (or rather, prepend ся to suffix) local active_base = rmatch(lemma, "^(.*)ся$") if active_base then lemma = active_base lemmatr = com.strip_tr_ending(lemmatr, "ся") args.refl = true args.real_suffix = com.concat_paired_russian_tr({"ся"}, args.suffix) else args.refl = false args.real_suffix = args.suffix end -- Auto-detect actual decl type, and get short accent and overriding -- short stem, if specified. local stem, stemtr, short_accent, short_stem, short_stemtr, datedrare stem, stemtr, decl_type, short_accent, short_stem, datedrare = detect_stem_and_accent_type(lemma, lemmatr, decl_type, args) if rfind(decl_type, "^[іи]й$") and rfind(stem, "[" .. com.velar .. com.sib .. "]$") then decl_type = "ый" end if datedrare == "none" then saw_no_short = true end local proper_decl = m_table.contains({"proper", "stressed-proper"}, decl_type) -- Use args.real_surname to avoid overwriting args.surname, since we may be overwriting -- `args` multiple times. FIXME: Use a separate data structure for this. args.real_surname = proper_decl or args.surname local short_title if short_accent then short_title = short_accent elseif args.real_surname then short_title = "surname" elseif m_table.contains({"ьій", "ьий", "short", "stressed-short", "mixed"}, decl_type) then short_title = "possessive" end if short_title then if datedrare == "dated" then m_table.insertIfNot(dated_short_classes, short_title) elseif datedrare == "rare" then m_table.insertIfNot(rare_short_classes, short_title) else m_table.insertIfNot(normal_short_classes, short_title) end end if short_stem then short_stem, short_stemtr = com.split_russian_tr(short_stem) end stem, args.allow_unaccented = rsubb(stem, "^%*", "") if args.allow_unaccented then track("allow-unaccented") end -- Treat suffixes without an accent, and suffixes with an accent on -- the initial hyphen, as if they were preceded with a *, which -- overrides all the logic that normally (a) normalizes the accent, -- and (b) complains about multisyllabic words without an accent. -- Don't do this if lemma is just -, which is used specially in -- manual declension tables. if lemma ~= "-" and (rfind(lemma, "^%-́") or (com.is_unstressed(lemma) and rfind(lemma, "^%-"))) then args.allow_unaccented = true end if not args.allow_unaccented and com.needs_accents(lemma) then -- Technically we don't need accents in -ой adjectives (which are -- always ending-stressed) and in -ый adjectives with a monosyllabic -- stem, such as полный (which are always stem-stressed), but it's -- better to enforce accents in all multisyllabic words, for -- consistency with nouns and verbs. Note that we still don't -- require an accent in monosyllabic adjectives such as злой. error("Lemma must have an accent in it: " .. lemma) end -- Set stem and unstressed version. Also construct end-accented version -- of stem if unstressed; needed for short forms of adjectives of -- type -о́й. We do this here before doing the dereduction -- transformation so that we don't end up stressing an unstressed -- epenthetic vowel, and so that the previous syllable instead ends -- up stressed (in type -о́й adjectives the stem won't have any stress). -- Note that the closest equivalent in nouns is handled in -- attach_unstressed(), which puts the stress onto the final syllable -- if the stress pattern calls for ending stress in the genitive -- plural. This works there because -- (1) It won't stress an unstressed epenthetic vowel because the -- cases where the epenthetic vowel is unstressed are precisely -- those with stem stress in the gen pl, not ending stress; -- (2) There isn't a need to stress the syllable preceding an -- unstressed epenthetic vowel because that syllable should -- already have stress, since we require that the base stem form -- (parameter 2) have stress in it whenever any case form has -- stem stress. This isn't the case here in type -о́й adjectives. -- NOTE: FIXME: I can't actually quote any forms from Zaliznyak -- (at least not from pages 58-60, where this is discussed) that -- seem to require last-stem-syllable-stress, i.e. where the stem is -- multisyllabic. The two examples given are both unusual: дорого́й -- has stress on the initial syllable до́рог etc. and these forms are -- marked with a triangle (indicating an apparent irregularity); and -- голубо́й seems not to have a masculine singular short form, and it's -- accent pattern b, so the remaining forms are all ending-stressed. -- In fact it's possible that these examples don't exist: It appears -- that all the multisyllabic adjectives in -о́й listed in the -- dictionary have a marking next to them consisting of an X inside of -- a square, which is glossed p. 69 to something I don't understand, -- but may be saying that the masculine singular short form is -- missing. If this is regular, we need to implement it. args.stem, args.stemtr = stem, stemtr args.ustem, args.ustemtr = com.make_unstressed_once(stem, stemtr) local accented_stem, accented_stemtr = stem, stemtr if not args.allow_unaccented then if accented_stemtr and com.is_unstressed(accented_stem) ~= com.is_unstressed(accented_stemtr) then error("Stem " .. accented_stem .. " and translit " .. accented_stemtr .. " must have same accent pattern") end if com.is_unstressed(accented_stem) then accented_stem, accented_stemtr = com.make_ending_stressed(accented_stem, accented_stemtr) end end local short_forms_allowed = manual and true or decl_type == "ый" or decl_type == "ой" or decl_type == (old and "ій" or "ий") overall_short_forms_allowed = overall_short_forms_allowed or short_forms_allowed if not short_forms_allowed then -- FIXME: We might want to allow this in case we have a -- reducible short, mixed or proper possessive adjective. But -- in that case we need to reduce rather than dereduce to get -- the stem. if short_accent or short_stem then error("Cannot specify short accent or short stem with declension type " .. decl_type .. ", as short forms aren't allowed") end if args.short_m or args.short_f or args.short_n or args.short_p then error("Cannot specify explicit short forms with declension type " .. decl_type .. ", as short forms aren't allowed") end end local orig_short_accent = short_accent local short_decl_type short_accent, short_decl_type = construct_bare_and_short_stem(args, short_accent, short_stem, short_stemtr, accented_stem, accented_stemtr, old, decl_type) local decls = old and declensions_old or declensions local short_decls = old and short_declensions_old or short_declensions if not decls[decl_type] then error("Unrecognized declension type " .. decl_type) end if short_accent == "" then error("Short accent type cannot be blank, should be omitted or given") end if short_accent and not short_stress_patterns[short_accent] then error("Unrecognized short accent type " .. short_accent) end tracking_code(decl_type, args, orig_short_accent, short_accent, short_stem, datedrare, short_forms_allowed) if not manual and enable_categories then categorize(decl_type, args, orig_short_accent, short_accent, short_stem) end decline(args, decls[decl_type], m_table.contains({"ой", "stressed-short", "stressed-proper"}, decl_type)) if short_forms_allowed and short_accent then decline_short(args, short_decls[short_decl_type], short_stress_patterns[short_accent], datedrare) end local intable = old and internal_notes_table_old or internal_notes_table local shortintab = old and short_internal_notes_table_old or short_internal_notes_table local internal_note = intable[decl_type] or shortintab[short_decl_type] if internal_note then m_table.insertIfNot(args.internal_notes, internal_note) end end end local short_class_titles = {} local function make_short_class_title(short_classes, datedrare) local sct = table.concat(short_classes, ",") -- short class title if sct == "" then return end if not m_table.contains({"surname", "possessive"}, sct) then -- Convert e.g. a*,a(1) into a*[(1)], either finally or followed by -- comma. sct = rsub(sct, "([abc]'*)%*,%1%*?(%([12]%))$", "%1*[%2]") sct = rsub(sct, "([abc]'*)%*,%1%*?(%([12]%)),", "%1*[%2],") -- Same for a(1),a*. sct = rsub(sct, "([abc]'*)%*?(%([12]%)),%1%*$", "%1*[%2]") sct = rsub(sct, "([abc]'*)%*?(%([12]%)),%1%*,", "%1*[%2],") -- Convert (1), (2) to ①, ②. sct = rsub(sct, "%(1%)", "①") sct = rsub(sct, "%(2%)", "②") -- Add a * before ①, ②, consistent with Zaliznyak. sct = rsub(sct, "([abc]'*)([①②])", "%1*%2") -- Avoid c'' turning into c with italics. sct = rsub(sct, "''", "&#39;&#39;") sct = "short class " .. sct end if datedrare then sct = datedrare .. " " .. sct end table.insert(short_class_titles, sct) end make_short_class_title(normal_short_classes, nil) make_short_class_title(rare_short_classes, "rare") make_short_class_title(dated_short_classes, "dated") if #short_class_titles == 0 then if saw_no_short then args.short_class_title = "no short forms" else args.short_class_title = "unknown short forms" end else args.short_class_title = table.concat(short_class_titles, " / ") end handle_forms_and_overrides(args, overall_short_forms_allowed) -- Test code to compare existing module to new one. if test_new_ru_adjective_module then local m_new_ru_adjective = require("Module:User:Benwing2/ru-adjective") local newargs = m_new_ru_adjective.do_generate_forms(orig_args, old, manual) local difdecl = false for _, case in ipairs(all_cases) do local arg = args[case] local newarg = newargs[case] if not m_table.deepEquals(arg, newarg) then -- Uncomment this to display the particular case and -- differing forms. --error(case .. " " .. (arg and com.concat_forms(arg) or "nil") .. " || " .. (newarg and com.concat_forms(newarg) or "nil")) track("different-decl") difdecl = true end break end if not difdecl then track("same-decl") end end return args end local function process_params(frame, include_form) local params = { [1] = {}, [2] = {}, suffix = {}, title = {}, special = {}, shorttail = {}, shorttailall = {}, notes = {}, old = {type = "boolean"}, noneuter = {type = "boolean"}, nofull = {type = "boolean"}, surname = {type = "boolean"}, } if include_form then params.form = {required = true} end for _, case in ipairs(all_cases) do params[case] = {} params[case .. "_tail"] = {} params[case .. "_tailall"] = {} end local parent_args = frame:getParent().args return require("Module:parameters").process(parent_args, params) end -- Implementation of main entry point local function do_show(frame, old, manual) local args = process_params(frame) local args = export.do_generate_forms(args, old, manual) return make_table(args) .. m_utilities.format_categories(args.categories, lang) end -- The main entry point for modern declension tables. function export.show(frame) return do_show(frame, false) end -- The main entry point for old declension tables. function export.show_old(frame) return do_show(frame, true) end -- The main entry point for manual declension tables. function export.show_manual(frame) return do_show(frame, false, "manual") end -- The main entry point for manual old declension tables. function export.show_manual_old(frame) return do_show(frame, true, "manual") end -- Entry point for use in Module:ru-noun. function export.get_nominal_decl(decl, gender, old) local d = old and declensions_old[decl] or declensions[decl] local n = {} if gender == "m" then n.nom_sg = d.nom_m n.gen_sg = d.gen_m n.dat_sg = d.dat_m n.ins_sg = d.ins_m n.pre_sg = d.pre_m elseif gender == "f" then n.nom_sg = d.nom_f n.gen_sg = d.gen_f n.dat_sg = d.dat_f n.acc_sg = d.acc_f n.ins_sg = d.ins_f n.pre_sg = d.pre_f elseif gender == "n" then n.nom_sg = d.nom_n n.gen_sg = d.gen_m n.dat_sg = d.dat_m n.acc_sg = d.acc_n n.ins_sg = d.ins_m n.pre_sg = d.pre_m else assert(false, "Unrecognized gender: " .. gender) end n.nom_pl = d.nom_p n.gen_pl = d.gen_p n.dat_pl = d.dat_p n.ins_pl = d.ins_p n.pre_pl = d.pre_p if gender == "m" and d.nom_mp then n.nom_pl = d.nom_mp end local intable = old and internal_notes_table_old or internal_notes_table local ingenders = old and internal_notes_genders_old or internal_notes_genders -- FIXME, what if there are multiple internal notes? See comment in -- do_generate_forms(). local internal_notes = ingenders[decl] and m_table.contains(ingenders[decl], gender) and intable[decl] return n, internal_notes end local function get_form(forms) local canon_forms = {} for _, form in ipairs(forms) do local ru, tr = form[1], form[2] local ruentry, runotes = m_table_tools.get_notes(ru) local trentry, trnotes if tr then trentry, trnotes = m_table_tools.get_notes(tr) end ruentry = m_links.remove_links(ruentry) m_table.insertIfNot(canon_forms, {ruentry, trentry}) end return com.concat_forms(canon_forms) end -- The entry point for 'ru-adj-forms' to generate all adjective forms. function export.generate_forms(frame) local args = process_params(frame) local args = export.do_generate_forms(args, false) local ins_text = {} for _, case in ipairs(all_cases) do if args[case] then table.insert(ins_text, case .. "=" .. get_form(args[case])) end end return table.concat(ins_text, "|") end -- The entry point for 'ru-adj-form' to generate a particular adjective form. function export.generate_form(frame) local args = process_params(frame, "include form") local form = args.form if not m_table.contains(all_cases, form) then error("Unrecognized form " .. form) end local args = export.do_generate_forms(args, false) if not args[form] then return "" else return get_form(args[form]) end end -------------------------------------------------------------------------- -- Tracking and categorization -- -------------------------------------------------------------------------- tracking_code = function(decl_class, args, orig_short_accent, short_accent, short_stem, datedrare, short_forms_allowed) local hint_types = com.get_stem_trailing_letter_type(args.stem) local function dotrack(prefix) if prefix ~= "" then track(prefix) prefix = prefix .. "/" end track(prefix .. decl_class) for _, hint_type in ipairs(hint_types) do track(prefix .. hint_type) track(prefix .. decl_class .. "/" .. hint_type) end end dotrack("") if args.short_m or args.short_f or args.short_n or args.short_p then dotrack("short") end if orig_short_accent then if rfind(orig_short_accent, "%*") then dotrack("reducible") dotrack("reducible/" .. short_accent) end if rfind(orig_short_accent, "%(1%)") then dotrack("special-case-1") dotrack("special-case-1/" .. short_accent) end if rfind(orig_short_accent, "%(2%)") then dotrack("special-case-2") dotrack("special-case-2/" .. short_accent) end end if short_accent then dotrack("short-accent/" .. short_accent) if datedrare == "dated" then dotrack("short-accent-dated") dotrack("short-accent-dated/" .. short_accent) elseif datedrare == "rare" then dotrack("short-accent-rare") dotrack("short-accent-rare/" .. short_accent) end elseif datedrare == "none" then dotrack("short-accent/none") else dotrack("short-accent/unknown") end if short_stem then dotrack("explicit-short-stem") dotrack("explicit-short-stem/" .. short_accent) end for _, case in ipairs(all_cases) do if args[case] then track("irreg/" .. case) -- questionable use: dotrack("irreg/" .. case) end end end -- Insert the category CAT (a string) into list CATEGORIES. String will -- have "Russian " prepended and ~ substituted for the part of speech. local function insert_category(categories, cat, plpos) table.insert(categories, "Russian " .. rsub(cat, "~", plpos)) end categorize = function(decl_type, args, orig_short_accent, short_accent, short_stem) local plpos = args.real_surname and "surnames" or "adjectives" -- Insert category CAT into the list of categories in ARGS. local function insert_cat(cat) insert_category(args.categories, cat, plpos) end -- FIXME: For compatibility with old {{temp|ru-adj7}}, {{temp|ru-adj8}}, -- {{temp|ru-adj9}}; maybe there's a better way. if m_table.contains({"ьій", "ьий", "short", "stressed-short", "mixed", "proper", "stressed-proper"}, decl_type) then insert_cat("possessive ~") end if m_table.contains({"ьій", "ьий"}, decl_type) then insert_cat("long possessive ~") elseif m_table.contains({"short", "stressed-short"}, decl_type) then insert_cat("short possessive ~") elseif m_table.contains({"mixed"}, decl_type) then insert_cat("mixed possessive ~") elseif m_table.contains({"proper", "stressed-proper"}, decl_type) then -- Don't insert a category like [[:Category:Russian proper-name surnames]]. Instead, rely on -- [[:Category:Russian possessive surnames]] generated above. if not args.real_surname then insert_cat("proper-name ~") end elseif decl_type == "$" then insert_cat("indeclinable ~") else local hint_types = com.get_stem_trailing_letter_type(args.stem) -- insert English version of Zaliznyak stem type local stem_type = m_table.contains(hint_types, "velar") and "velar-stem" or m_table.contains(hint_types, "sibilant") and "sibilant-stem" or m_table.contains(hint_types, "c") and "ц-stem" or m_table.contains(hint_types, "i") and "i-stem" or m_table.contains(hint_types, "vowel") and "vowel-stem" or m_table.contains(hint_types, "soft-cons") and "vowel-stem" or m_table.contains(hint_types, "palatal") and "vowel-stem" or decl_type == "ий" and "soft-stem" or "hard-stem" if stem_type == "soft-stem" or stem_type == "vowel-stem" then insert_cat(stem_type .. " ~") else insert_cat(stem_type .. " " .. (decl_type == "ой" and "ending-stressed" or "stem-stressed") .. " ~") end end if decl_type == "ой" then insert_cat("ending-stressed ~") end local short_forms_allowed = m_table.contains({"ый", "ой", "ій", "ий"}, decl_type) if short_forms_allowed then local override_m = args.short_m local override_f = args.short_f local override_n = args.short_n local override_p = args.short_p local has_short = short_accent or override_m or override_f or override_n or override_p local missing_short = override_m == "-" or override_f == "-" or override_n == "-" or override_p == "-" or not short_accent and (not override_m or not override_f or not override_n or not override_p) if has_short then insert_cat("~ with short forms") if missing_short then insert_cat("~ with missing short forms") end end if short_accent then insert_cat("~ with short accent pattern " .. short_accent) end if orig_short_accent then if rfind(orig_short_accent, "%*") then insert_cat("~ with reducible short stem") end if rfind(orig_short_accent, "%(1%)") then insert_cat("~ with Zaliznyak short form special case 1") end if rfind(orig_short_accent, "%(2%)") then insert_cat("~ with Zaliznyak short form special case 2") end end if short_stem and short_stem ~= args.stem then insert_cat("~ with irregular short stem") end end for _, case in ipairs(all_cases) do if args[case] and args[case] ~= "-" then local engcase = rsub(case, "^([a-z]*)", { nom="nominative", gen="genitive", dat="dative", acc="accusative", ins="instrumental", pre="prepositional", short="short", }) engcase = rsub(engcase, "(_[a-z]*)$", { _m=" masculine singular", _f=" feminine singular", _n=" neuter singular", _p=" plural", _mp=" masculine plural" }) insert_cat("~ with irregular " .. engcase) end end if args.nofull then insert_cat("short-form-only ~") end end -------------------------------------------------------------------------- -- Autodetection and stem munging -- -------------------------------------------------------------------------- -- Attempt to detect the type of the lemma based on its ending, separating -- off the base and the ending; also extract the accent type for short -- adjectives and optional short stem. DECL is the value passed in, and -- might already specify the ending. Return five values: STEM, STEMTR, DECL, -- SHORT_ACCENT (accent class of short adjective, or nil for no short -- adjectives other than specified through overrides), SHORT_STEM (special -- stem of short adjective, nil if same as long stem). The return value of -- SHORT_STEM is taken directly from the argument and will include any -- manual translit. detect_stem_and_accent_type = function(lemma, tr, decl, args) local datedrare = false -- If it looks like a short decl type, canonicalize. [abc] for types -- a, b, c'', etc.; [d] for dated-*; [r] for rare-*; -- [-] for - (no short forms); [*(] for * and (1) and (2) modifiers, -- which might precede the letter. if rfind(decl, "^[abcdr*(-]") then decl = ":" .. decl end splitvals = rsplit(decl, ":") if #splitvals > 3 then error("Should be at most three colon-separated parts of a declension spec: " .. decl) end local short_accent, short_stem decl, short_accent, short_stem = splitvals[1], splitvals[2], splitvals[3] -- Check for dated variant of short accent local dated_short = short_accent and rmatch(short_accent, "^dated%-(.*)$") if dated_short then datedrare = "dated" short_accent = dated_short else -- Check for rare variant of short accent local rare_short = short_accent and rmatch(short_accent, "^rare%-(.*)$") if rare_short then datedrare = "rare" short_accent = rare_short end end decl = ine(decl) -- Resolve aliases if decl then decl = rsub(decl, "^ъ%-", "") end if short_accent == "-" then short_accent = nil datedrare = "none" end short_accent = ine(short_accent) short_stem = ine(short_stem) if short_stem and not short_accent then error("With explicit short stem " .. short_stem .. ", must specify short accent") end local base, ending -- The while loop appears to function solely as a way of allowing a -- jump to the end of the loop with a 'break' statement. I don't think -- the loop is ever run more than once. while true do if not decl or decl == "ь" then base, ending = rmatch(lemma, "^(.*)([ыиіо]́?й)$") if base then if ending == "ий" and decl == "ь" then ending = "ьий" elseif ending == "ій" and decl == "ь" then ending = "ьій" end tr = com.strip_tr_ending(tr, ending) -- -ий/-ій will be converted to -ый after velars and sibilants -- by the caller decl = com.make_unstressed(ending) break else -- It appears that short, mixed and proper adjectives are always -- either of the -ов/ев/ёв or -ин/ын types. The former type is -- always (or almost always?) short, while the latter can be -- either; apparently mixed is the more "modern" type of -- declension, and short is "older". However, both -ов/ев/ёв or -- -ин/ын are of type "proper" (similar to "short") when -- capitalized. -- -- NOTE: Following regexp is accented base = rmatch(lemma, "^([" .. com.uppercase .. "].*[иы]́н)ъ?$") if base then decl = "stressed-proper" break end base = rmatch(lemma, "^([" .. com.uppercase .. "].*[еёо]́?в)ъ?$") if not base then -- Following regexp is not stressed base = rmatch(lemma, "^([" .. com.uppercase .. "].*[иы]н)ъ?$") end if base then decl = "proper" break end base = rmatch(lemma, "^(.*[еёо]́?в)ъ?$") if base then decl = "short" break end base = rmatch(lemma, "(.*[иы]́н)ъ?$") --accented if base then decl = "stressed-short" break end base = rmatch(lemma, "(.*[иы]н)ъ?$") --unaccented if base then decl = "mixed" break -- error("With -ин/ын adjectives, must specify 'short' or 'mixed':" .. lemma) end error("Cannot determine stem type of adjective: " .. lemma) end elseif m_table.contains({"short", "stressed-short", "mixed", "proper", "stressed-proper"}, decl) then base = rmatch(lemma, "^(.-)ъ?$") assert(base) break else base = lemma break end end if not datedrare and (args.refl or not (decl == "ый" or decl == "ий" and not rfind(base, "[цс]к$"))) then datedrare = "none" end return base, tr, decl, short_accent, short_stem, datedrare end -- Add a possible suffix to the bare stem, according to the declension and -- value of OLD. This may be -ь, -ъ, -й or nothing. We need to do this here -- because we don't actually attach such a suffix in attach_unstressed() due -- to situations where we don't want the suffix added, e.g. бескра́йний with -- dereduced nom sg бескра́ен without expected -ь. local function add_bare_suffix(bare, baretr, old, decl, dereduced) if old and decl ~= "ій" and decl ~= "$" then return bare .. "ъ", baretr elseif decl == "ий" or decl == "ій" then -- This next special case is mentioned in Zaliznyak's 1980 grammatical -- dictionary for adjectives (footnote, p. 60). if dereduced and rfind(bare, "[нН]$") then -- FIXME: What happens in this case old-style? I assume that -- -ъ is added, but this is a guess. return bare .. (old and "ъ" or ""), baretr elseif rfind(bare, "[" .. com.vowel .. "]́?$") then -- This happens with adjectives like длинноше́ий, short masculine -- singular длинноше́й. return bare .. "й", baretr and baretr .. "j" or nil else return bare .. "ь", baretr and baretr .. "ʹ" or nil end else return bare, baretr end end -- Construct and set bare and short form in args, and canonicalize -- short accent spec, handling cases *, (1) and (2). Return canonicalized -- short accent and the short declension, which is usually the same as -- the corresponding long one. construct_bare_and_short_stem = function(args, short_accent, short_stem, short_stemtr, accented_stem, accented_stemtr, old, decl) -- Check if short forms allowed; if not, no short-form params can be given. -- Construct bare version of stem; used for cases where the ending -- is non-syllabic (i.e. short masculine singular of long adjectives, -- and masculine singular of short, mixed and proper adjectives). Comes -- from short masculine or 3rd argument if explicitly given, else from the -- accented stem, possibly with the dereduction transformation applied -- (if * occurs in the short accent spec). local reducible, sc1, sc2 if short_accent then short_accent, reducible = rsubb(short_accent, "%*", "") short_accent, sc1 = rsubb(short_accent, "%(1%)", "") short_accent, sc2 = rsubb(short_accent, "%(2%)", "") end if sc1 or sc2 then -- Reducible isn't compatible with sc1 or sc2, but Zaliznyak's -- dictionary always seems to notate sc1 and sc2 with reducible *, -- so ignore it. reducible = false end if sc1 and sc2 then error("Special cases 1 and 2, i.e. (1) and (2), not compatible") end local explicit_short_stem, explicit_short_stemtr = short_stem, short_stemtr local short_decl = decl -- Construct short stem. May be explicitly given, else comes from -- end-accented stem. if not short_stem then short_stem, short_stemtr = accented_stem, accented_stemtr end -- Try to accent unaccented short stem (happens only when explicitly given), -- but be conservative -- only if monosyllabic, since otherwise we have -- no idea where stress should end up; after all, the explicit short stem -- is for exceptional cases. if not args.allow_unaccented then if short_stemtr and com.is_unstressed(short_stem) ~= com.is_unstressed(short_stemtr) then error("Explicit short stem " .. short_stem .. " and translit " .. short_stemtr .. " must have same accent pattern") end if com.is_monosyllabic(short_stem) then short_stem, short_stemtr = com.make_ending_stressed(short_stem, short_stemtr) elseif com.needs_accents(short_stem) then error("Explicit short stem " .. short_stem .. " needs an accent") end end if sc2 then if not rfind(short_stem, "нн$") then error("With special case 2, stem needs to end in -нн: " .. short_stem) end short_stem = rsub(short_stem, "нн$", "н") if short_stemtr then if not rfind(short_stemtr, "nn$") then error("With special case 2, stem translit needs to end in -nn: " .. short_stemtr) end short_stemtr = rsub(short_stemtr, "nn$", "n") end end -- Construct bare form, used for short masculine. local bare, baretr if reducible then bare, baretr = com.dereduce_stem(short_stem, short_stemtr, rfind(short_accent, "^b")) if not bare then error("Unable to dereduce stem: " .. short_stem) end bare, baretr = add_bare_suffix(bare, baretr, old, decl, true) else bare, baretr = short_stem, short_stemtr if sc1 then if not rfind(bare, "нн$") then error("With special case 1, stem needs to end in -нн: " .. bare) end bare = rsub(bare, "нн$", "н") if baretr then if not rfind(baretr, "nn$") then error("With special case 1, stem translit needs to end in -nn: " .. baretr) end baretr = rsub(baretr, "nn$", "n") end end -- With special case 1 or 2, we don't ever want -ь added, so treat -- it like a reducible (that may be why these are marked as -- reducible in Zaliznyak). bare, baretr = add_bare_suffix(bare, baretr, old, decl, sc1 or sc2) end args.short_stem, args.short_stemtr = short_stem, short_stemtr args.short_ustem, args.short_ustemtr = com.make_unstressed_once(short_stem, short_stemtr) args.bare, args.baretr = bare, baretr return short_accent, short_decl end -------------------------------------------------------------------------- -- Declensions -- -------------------------------------------------------------------------- declensions["ый"] = { ["nom_m"] = "ый", ["nom_n"] = "ое", ["nom_f"] = "ая", ["nom_p"] = "ые", ["gen_m"] = "ого", ["gen_f"] = "ой", ["gen_p"] = "ых", ["dat_m"] = "ому", ["dat_f"] = "ой", ["dat_p"] = "ым", ["acc_f"] = "ую", ["acc_n"] = "ое", ["ins_m"] = "ым", ["ins_f"] = {"ой", "ою"}, ["ins_p"] = "ыми", ["pre_m"] = "ом", ["pre_f"] = "ой", ["pre_p"] = "ых", } declensions["ий"] = { ["nom_m"] = "ий", ["nom_n"] = "ее", ["nom_f"] = "яя", ["nom_p"] = "ие", ["gen_m"] = "его", ["gen_f"] = "ей", ["gen_p"] = "их", ["dat_m"] = "ему", ["dat_f"] = "ей", ["dat_p"] = "им", ["acc_f"] = "юю", ["acc_n"] = "ее", ["ins_m"] = "им", ["ins_f"] = {"ей", "ею"}, ["ins_p"] = "ими", ["pre_m"] = "ем", ["pre_f"] = "ей", ["pre_p"] = "их", } declensions["ой"] = { ["nom_m"] = "о́й", ["nom_n"] = "о́е", ["nom_f"] = "а́я", ["nom_p"] = "ы́е", ["gen_m"] = "о́го", ["gen_f"] = "о́й", ["gen_p"] = "ы́х", ["dat_m"] = "о́му", ["dat_f"] = "о́й", ["dat_p"] = "ы́м", ["acc_f"] = "у́ю", ["acc_n"] = "о́е", ["ins_m"] = "ы́м", ["ins_f"] = {"о́й", "о́ю"}, ["ins_p"] = "ы́ми", ["pre_m"] = "о́м", ["pre_f"] = "о́й", ["pre_p"] = "ы́х", } -- These can be stressed in ничья́ "draw, tie (in sports)". declensions["ьий"] = { ["nom_m"] = "и́й", ["nom_n"] = "ье́", ["nom_f"] = "ья́", ["nom_p"] = "ьи́", ["gen_m"] = "ье́го", ["gen_f"] = "ье́й", ["gen_p"] = "ьи́х", ["dat_m"] = "ье́му", ["dat_f"] = "ье́й", ["dat_p"] = "ьи́м", ["acc_f"] = "ью́", ["acc_n"] = "ье́", ["ins_m"] = "ьи́м", ["ins_f"] = {"ье́й", "ье́ю"}, ["ins_p"] = "ьи́ми", ["pre_m"] = "ье́м", ["pre_f"] = "ье́й", ["pre_p"] = "ьи́х", } declensions["short"] = { ["nom_m"] = "", ["nom_n"] = "о́", ["nom_f"] = "а́", ["nom_p"] = "ы́", ["gen_m"] = "а́", ["gen_f"] = "о́й", ["gen_p"] = "ы́х", ["dat_m"] = "у́", ["dat_f"] = "о́й", ["dat_p"] = "ы́м", ["acc_f"] = "у́", ["acc_n"] = "о́", ["ins_m"] = "ы́м", ["ins_f"] = {"о́й", "о́ю"}, ["ins_p"] = "ы́ми", ["pre_m"] = "о́м", ["pre_f"] = "о́й", ["pre_p"] = "ы́х", } declensions["stressed-short"] = mw.clone(declensions["short"]) declensions["stressed-short"]["pre_m"] = "е́" declensions["mixed"] = { ["nom_m"] = "", ["nom_n"] = "о", ["nom_f"] = "а", ["nom_p"] = "ы", ["gen_m"] = {"ого", "а2"}, ["gen_f"] = "ой", ["gen_p"] = "ых", ["dat_m"] = {"ому", "у2"}, ["dat_f"] = "ой", ["dat_p"] = "ым", ["acc_f"] = "у", ["acc_n"] = "о", ["ins_m"] = "ым", ["ins_f"] = {"ой", "ою"}, ["ins_p"] = "ыми", ["pre_m"] = "ом", ["pre_f"] = "ой", ["pre_p"] = "ых", } internal_notes_table["mixed"] = "<sup>2</sup> Obsolete." internal_notes_genders["mixed"] = {"m"} internal_notes_table_old["mixed"] = "<sup>2</sup> Obsolete." internal_notes_genders_old["mixed"] = {"m"} declensions["proper"] = { ["nom_m"] = "", ["nom_n"] = nil, ["nom_f"] = "а́", ["nom_p"] = "ы́", ["gen_m"] = "а́", ["gen_f"] = "о́й", ["gen_p"] = "ы́х", ["dat_m"] = "у́", ["dat_f"] = "о́й", ["dat_p"] = "ы́м", ["acc_f"] = "у́", ["acc_n"] = nil, ["ins_m"] = "ы́м", ["ins_f"] = {"о́й", "о́ю1"}, ["ins_p"] = "ы́ми", ["pre_m"] = "е́", ["pre_f"] = "о́й", ["pre_p"] = "ы́х", } declensions["stressed-proper"] = declensions["proper"] for _, decl in ipairs({"proper", "stressed-proper"}) do internal_notes_table[decl] = "<sup>1</sup> Rare." internal_notes_table_old[decl] = "<sup>1</sup> Rare." internal_notes_genders[decl] = {"f"} internal_notes_genders_old[decl] = {"f"} end declensions["$"] = { ["nom_m"] = "", ["nom_n"] = "", ["nom_f"] = "", ["nom_p"] = "", ["gen_m"] = "", ["gen_f"] = "", ["gen_p"] = "", ["dat_m"] = "", ["dat_f"] = "", ["dat_p"] = "", ["acc_f"] = "", -- don't do this; instead we default it to nom_n -- ["acc_n"] = "", ["ins_m"] = "", ["ins_f"] = "", ["ins_p"] = "", ["pre_m"] = "", ["pre_f"] = "", ["pre_p"] = "", -- for old-style templates, два, оба, compounds of два ["nom_mp"] = "", ["nom_fp"] = "", ["gen_mp"] = "", ["gen_fp"] = "", ["dat_mp"] = "", ["dat_fp"] = "", -- don't do this; instead we default them to nom_mp, nom_fp -- ["acc_mp"] = "", -- ["acc_fp"] = "", ["ins_mp"] = "", ["ins_fp"] = "", ["pre_mp"] = "", ["pre_fp"] = "", } declensions_old["ый"] = { ["nom_m"] = "ый", ["nom_n"] = "ое", ["nom_f"] = "ая", ["nom_mp"] = "ые", ["nom_p"] = "ыя", ["gen_m"] = "аго", ["gen_f"] = "ой", ["gen_p"] = "ыхъ", ["dat_m"] = "ому", ["dat_f"] = "ой", ["dat_p"] = "ымъ", ["acc_f"] = "ую", ["acc_n"] = "ое", ["ins_m"] = "ымъ", ["ins_f"] = {"ой", "ою"}, ["ins_p"] = "ыми", ["pre_m"] = "омъ", ["pre_f"] = "ой", ["pre_p"] = "ыхъ", } declensions_old["ій"] = { ["nom_m"] = "ій", ["nom_n"] = "ее", ["nom_f"] = "яя", ["nom_mp"] = "іе", ["nom_p"] = "ія", ["gen_m"] = "яго", ["gen_f"] = "ей", ["gen_p"] = "ихъ", ["dat_m"] = "ему", ["dat_f"] = "ей", ["dat_p"] = "имъ", ["acc_f"] = "юю", ["acc_n"] = "ее", ["ins_m"] = "имъ", ["ins_f"] = {"ей", "ею"}, ["ins_p"] = "ими", ["pre_m"] = "емъ", ["pre_f"] = "ей", ["pre_p"] = "ихъ", } declensions_old["ой"] = { ["nom_m"] = "о́й", ["nom_n"] = "о́е", ["nom_f"] = "а́я", ["nom_mp"] = "ы́е", ["nom_p"] = "ы́я", ["gen_m"] = {"а́го", "о́го"}, ["gen_f"] = "о́й", ["gen_p"] = "ы́хъ", ["dat_m"] = "о́му", ["dat_f"] = "о́й", ["dat_p"] = "ы́мъ", ["acc_f"] = "у́ю", ["acc_n"] = "о́е", ["ins_m"] = "ы́мъ", ["ins_f"] = {"о́й", "о́ю"}, ["ins_p"] = "ы́ми", ["pre_m"] = "о́мъ", ["pre_f"] = "о́й", ["pre_p"] = "ы́хъ", } declensions_old["ьій"] = { ["nom_m"] = "ій", ["nom_n"] = "ье", ["nom_f"] = "ья", ["nom_p"] = "ьи", ["gen_m"] = "ьяго", ["gen_f"] = "ьей", ["gen_p"] = "ьихъ", ["dat_m"] = "ьему", ["dat_f"] = "ьей", ["dat_p"] = "ьимъ", ["acc_f"] = "ью", ["acc_n"] = "ье", ["ins_m"] = "ьимъ", ["ins_f"] = {"ьей", "ьею"}, ["ins_p"] = "ьими", ["pre_m"] = "ьемъ", ["pre_f"] = "ьей", ["pre_p"] = "ьихъ", } declensions_old["short"] = { ["nom_m"] = "ъ", ["nom_n"] = "о", ["nom_f"] = "а", ["nom_p"] = "ы", ["gen_m"] = "а", ["gen_f"] = "ой", ["gen_p"] = "ыхъ", ["dat_m"] = "у", ["dat_f"] = "ой", ["dat_p"] = "ымъ", ["acc_f"] = "у", ["acc_n"] = "о", ["ins_m"] = "ымъ", ["ins_f"] = {"ой", "ою"}, ["ins_p"] = "ыми", ["pre_m"] = "омъ", ["pre_f"] = "ой", ["pre_p"] = "ыхъ", } declensions_old["stressed-short"] = mw.clone(declensions_old["short"]) declensions_old["stressed-short"]["pre_m"] = "ѣ́" declensions_old["mixed"] = { ["nom_m"] = "ъ", ["nom_n"] = "о", ["nom_f"] = "а", ["nom_p"] = "ы", ["gen_m"] = {"аго", "а1"}, ["gen_f"] = "ой", ["gen_p"] = "ыхъ", ["dat_m"] = {"ому", "у1"}, ["dat_f"] = "ой", ["dat_p"] = "ымъ", ["acc_f"] = "у", ["acc_n"] = "о", ["ins_m"] = "ымъ", ["ins_f"] = {"ой", "ою"}, ["ins_p"] = "ыми", ["pre_m"] = "омъ", ["pre_f"] = "ой", ["pre_p"] = "ыхъ", } declensions_old["proper"] = { ["nom_m"] = "ъ", ["nom_n"] = nil, ["nom_f"] = "а́", ["nom_p"] = "ы́", ["gen_m"] = "а́", ["gen_f"] = "о́й", ["gen_p"] = "ы́хъ", ["dat_m"] = "у́", ["dat_f"] = "о́й", ["dat_p"] = "ы́мъ", ["acc_f"] = "у́", ["acc_n"] = nil, ["ins_m"] = "ы́мъ", ["ins_f"] = {"о́й", "о́ю1"}, ["ins_p"] = "ы́ми", ["pre_m"] = "ѣ́", ["pre_f"] = "о́й", ["pre_p"] = "ы́хъ", } declensions_old["stressed-proper"] = declensions_old["proper"] declensions_old["$"] = declensions["$"] local function frob_genitive_masc(decl) -- signal to combine_stem_and_suffix() to use the special tr_adj() -- function so that -го gets transliterated to -vo if type(decl["gen_m"]) == "table" then local entries = {} for _, entry in ipairs(decl["gen_m"]) do table.insert(entries, rsub(entry, "го$", "го<adj>")) end decl["gen_m"] = entries else decl["gen_m"] = rsub(decl["gen_m"], "го$", "го<adj>") end end -- Frob declensions, adding <adj> to gen_m forms ending in -го. This is -- a signal to add manual translit early on that renders -го as -vo. for decltype, decl in pairs(declensions_old) do frob_genitive_masc(decl) end for decltype, decl in pairs(declensions) do frob_genitive_masc(decl) end -------------------------------------------------------------------------- -- Declension functions -- -------------------------------------------------------------------------- local function attach_unstressed(args, suf, short) local stem, stemtr if short then stem, stemtr = args.short_stem, args.short_stemtr else stem, stemtr = args.stem, args.stemtr end if suf == nil then return nil elseif nom.nonsyllabic_suffixes[suf] then if not args.bare then return nil elseif rfind(args.bare, "[йьъ]$") then return {args.bare, args.baretr} elseif suf == "ъ" then return com.concat_russian_tr(args.bare, args.baretr, suf, nil, "dopair") else return {args.bare, args.baretr} end end suf = com.make_unstressed(suf) local rules = nom.unstressed_rules[ulower(usub(stem, -1))] -- The parens around the return value drop all but the first return value return (nom.combine_stem_and_suffix(stem, stemtr, suf, rules, args.old)) end local function attach_stressed(args, suf, short) local ustem, ustemtr if short then ustem, ustemtr = args.short_ustem, args.short_ustemtr else ustem, ustemtr = args.ustem, args.ustemtr end if suf == nil then return nil elseif not rfind(suf, "[ё́]") then -- if suf has no "ё" or accent marks return attach_unstressed(args, suf, short) end local rules = nom.stressed_rules[ulower(usub(ustem, -1))] -- The parens around the return value drop all but the first return value return (nom.combine_stem_and_suffix(ustem, ustemtr, suf, rules, args.old)) end local function attach_both(args, suf, short) local results = {} -- Examples with stems with ё on Zaliznyak p. 61 list the -- ending-stressed forms first, so go with that. -- NOTE: This assumes we get one value returned, not a list of such values. table.insert(results, attach_stressed(args, suf, short)) table.insert(results, attach_unstressed(args, suf, short)) return results end local function attach_with(args, suf, fun, short) if type(suf) == "table" then local all_combineds = {} for _, x in ipairs(suf) do local combineds = attach_with(args, x, fun, short) for _, combined in ipairs(combineds) do table.insert(all_combineds, combined) end end return all_combineds else local funval = fun(args, suf, short) if funval then local tbl = {} assert(type(funval) == "table") if type(funval[1]) ~= "table" then funval = {funval} end for _, x in ipairs(funval) do table.insert(tbl, com.concat_paired_russian_tr(x, args.real_suffix)) end return tbl else return {} end end end local function gen_form(args, decl, case, fun) if not args.forms[case] then args.forms[case] = {} end insert_forms_into_existing_forms(args.forms[case], attach_with(args, decl[case], fun, false)) end decline = function(args, decl, stressed) local attacher = stressed and attach_stressed or attach_unstressed for _, case in ipairs(long_cases) do gen_form(args, decl, case, attacher) end end canonicalize_override = function(args, case) local val = args[case] if not val then return nil end val = rsplit(val, "%s*,%s*") -- auto-accent/check for necessary accents local newvals = {} for _, v in ipairs(val) do local ru, tr = com.split_russian_tr(v) if not args.allow_unaccented then if tr and com.is_unstressed(ru) ~= com.is_unstressed(tr) then error("Override " .. ru .. " and translit " .. tr .. " must have same accent pattern") end -- it's safe to accent monosyllabic stems if com.is_monosyllabic(ru) then ru, tr = com.make_ending_stressed(ru, tr) elseif com.needs_accents(ru) then error("Override " .. ru .. " for case " .. case .. " requires an accent") end end table.insert(newvals, {ru, tr}) end val = newvals return val end handle_forms_and_overrides = function(args, short_forms_allowed) local f = args.forms local function append_note_all(case, value) value = com.split_russian_tr(value, "dopair") if f[case] then for i=1,#f[case] do f[case][i] = com.concat_paired_russian_tr(f[case][i], value) end end end local function append_note_last(case, value, gt_one) value = com.split_russian_tr(value, "dopair") if f[case] then local lastarg = #f[case] if lastarg > (gt_one and 1 or 0) then f[case][lastarg] = com.concat_paired_russian_tr(f[case][lastarg], value) end end end for _, case in ipairs(long_cases) do if args[case .. "_tail"] then append_note_last(case, args[case .. "_tail"]) end if args[case .. "_tailall"] then append_note_all(case, args[case .. "_tailall"]) end args[case] = canonicalize_override(args, case) or f[case] end for _, case in ipairs(short_cases) do if short_forms_allowed then if args[case .. "_tail"] then append_note_last(case, args[case .. "_tail"]) end if args[case .. "_tailall"] then append_note_all(case, args[case .. "_tailall"]) end if args.shorttailall then append_note_all(case, args.shorttailall) end if args.shorttail then append_note_last(case, args.shorttail, ">1") end args[case] = canonicalize_override(args, case) or f[case] else args[case] = nil end end -- Convert an empty list to nil, so that an mdash is inserted. This happens, -- for example, with words like голубой where args.bare is set to nil. for _, case in ipairs(all_cases) do if args[case] and #args[case] == 0 then args[case] = nil end end -- default acc_n to nom_n; applies chiefly in the indeclinable declension -- (used with manual declension tables) if not args.acc_n then args.acc_n = args.nom_n end -- default inanimate/animate accusative variants as appropriate; this is -- almost always correct, but not with e.g. два́дцать оди́н, where the -- masculine animate accusative два́дцать одного́ differs from both the -- masculine nominative два́дцать оди́н and the masculine genitive -- двадцати́ одного́. if not args.acc_m_an then args.acc_m_an = args.gen_m end if not args.acc_m_in then args.acc_m_in = args.nom_m end -- Compounds of два do not have animacy; everything else does. -- Only copy either the with-animacy or without-animacy variants to avoid -- having both forms in {{ru-generate-adj-forms}}. if args.special ~= "cdva" then if not args.acc_p_an then args.acc_p_an = args.gen_p end if not args.acc_p_in then args.acc_p_in = args.nom_p end if not args.acc_mp_an then args.acc_mp_an = args.gen_mp end if not args.acc_mp_in then args.acc_mp_in = args.nom_mp end if not args.acc_fp_an then args.acc_fp_an = args.gen_fp end if not args.acc_fp_in then args.acc_fp_in = args.nom_fp end else if not args.acc_mp then args.acc_mp = args.nom_mp end if not args.acc_fp then args.acc_fp = args.nom_fp end end end -------------------------------------------------------------------------- -- Short adjective declension -- -------------------------------------------------------------------------- short_declensions["ый"] = { m="", f="а́", n="о́", p="ы́" } short_declensions["ой"] = short_declensions["ый"] short_declensions["ий"] = { m="ь", f="я́", n="е́", p="и́" } short_declensions_old["ый"] = { m="ъ", f="а́", n="о́", p="ы́" } short_declensions_old["ой"] = short_declensions_old["ый"] short_declensions_old["ій"] = short_declensions["ий"] -- Short adjective stress patterns: -- "-" = stem-stressed -- "+" = ending-stressed (drawn onto the last syllable of stem in masculine) -- "-+" = both possibilities short_stress_patterns["a"] = { m="-", f="-", n="-", p="-" } short_stress_patterns["a'"] = { m="-", f="-+", n="-", p="-" } short_stress_patterns["b"] = { m="+", f="+", n="+", p="+" } short_stress_patterns["b'"] = { m="+", f="+", n="+", p="-+" } short_stress_patterns["c"] = { m="-", f="+", n="-", p="-" } short_stress_patterns["c'"] = { m="-", f="+", n="-", p="-+" } short_stress_patterns["c''"] = { m="-", f="+", n="-+", p="-+" } local function gen_short_form(args, decl, case, fun, datedrare) if not args.forms["short_" .. case] then args.forms["short_" .. case] = {} end local inserted = insert_forms_into_existing_forms( args.forms["short_" .. case], attach_with(args, decl[case], fun, true), (datedrare == "dated" and datedrare == "rare") and "*" or nil) if datedrare == "dated" and inserted then m_table.insertIfNot(args.internal_notes, "<sup>*</sup> Dated.") elseif datedrare == "rare" and inserted then m_table.insertIfNot(args.internal_notes, "<sup>*</sup> Rare.") end end local attachers = { ["+"] = attach_stressed, ["-"] = attach_unstressed, ["-+"] = attach_both, } decline_short = function(args, decl, stress_pattern, dated) if stress_pattern then for _, case in ipairs({"m", "f", "n", "p"}) do gen_short_form(args, decl, case, attachers[stress_pattern[case]], dated) end end end -------------------------------------------------------------------------- -- Create the table -- -------------------------------------------------------------------------- local title_temp = [=[Declension of <b lang="ru" class="Cyrl">{lemma}</b> ({short_class_title})]=] local old_title_temp = [=[Pre-reform declension of <b lang="ru" class="Cyrl">{lemma}</b> ({short_class_title})]=] local title_temp_no_short_msg = [=[Declension of <b lang="ru" class="Cyrl">{lemma}</b>]=] local old_title_temp_no_short_msg = [=[Pre-reform declension of <b lang="ru" class="Cyrl">{lemma}</b>]=] local template = nil local full_clause = nil local template_no_neuter = nil local full_clause_no_neuter = nil local surname_full_clause = nil local template_mp = nil local full_clause_mp = nil local template_mp_no_neuter = nil local full_clause_mp_no_neuter = nil local surname_full_clause_mp = nil local template_dva = nil local full_clause_dva = nil local full_clause_compound_dva = nil local template_oba = nil local full_clause_oba = nil local short_clause_separator = nil local short_clause = nil local short_clause_no_neuter_separator = nil local short_clause_no_neuter = nil local short_clause_mp_separator = nil local short_clause_mp = nil local short_clause_mp_no_neuter_separator = nil local short_clause_mp_no_neuter = nil local internal_notes_template = nil local notes_template = nil local function get_accel_forms(old, special, has_nom_mp) return { -- used with all variants nom_m = "nom|m|s", nom_f = "nom|f|s", nom_n = "nom|n|s", -- not used with special; applies to all genders normally but only -- feminine and neuter with old=1 nom_p = old and has_nom_mp and "nom|f//n|p" or "nom|p", -- only used with old=1 or special; applies to the masculine and neuter if -- special, but only masculine if old=1 nom_mp = special and "nom|m//n|p" or "nom|m|p", -- only used with special nom_fp = "nom|f|p", -- the remaining singulars and non-gendered plurals used with all variants -- except special == "oba" gen_m = "gen|m//n|s", gen_f = "gen|f|s", gen_p = "gen|p", dat_m = "dat|m//n|s", dat_f = "dat|f|s", dat_p = "dat|p", acc_m_an = "an|acc|m|s", acc_m_in = "in|acc|m|s", acc_f = "acc|f|s", acc_n = "acc|n|s", -- the following two not used with special in ("dva", "oba"); applies to -- all genders normally but only feminine and neuter with old=1 acc_p_an = old and has_nom_mp and "an|acc|f//n|p" or "an|acc|p", acc_p_in = old and has_nom_mp and "in|acc|f//n|p" or "in|acc|p", -- the following two only used with old=1 or special in ("dva|oba"); -- applies to the masculine and neuter if special, but only masculine if -- old=1 acc_mp_an = special and "an|acc|m//n|p" or "an|acc|m|p", acc_mp_in = special and "in|acc|m//n|p" or "in|acc|m|p", -- the following two only used with special in ("dva", "oba") acc_fp_an = "an|acc|f|p", acc_fp_in = "in|acc|f|p", -- the next 6 are used with all variants except special == "oba" ins_m = "ins|m//n|s", ins_f = "ins|f|s", ins_p = "ins|p", pre_m = "pre|m//n|s", pre_f = "pre|f|s", pre_p = "pre|p", -- the following two gendered plurals are only used with special == "cdva" acc_mp = "acc|m//n|p", acc_fp = "acc|f|p", -- the remaining gendered plurals are only used with special == "oba" gen_mp = "gen|m//n|p", gen_fp = "gen|f|p", dat_mp = "dat|m//n|p", dat_fp = "dat|f|p", ins_mp = "ins|m//n|p", ins_fp = "ins|f|p", pre_mp = "pre|m//n|p", pre_fp = "pre|f|p", -- short forms short_m = "short|m|s", short_f = "short|f|s", short_n = "short|n|s", short_p = "short|p", } end -- Make the table make_table = function(args) local lemma_forms = args.special and args.nom_mp or args.nofull and args.short_m or args.nom_m args.lemma = m_links.remove_links(nom.show_form(lemma_forms, true, nil, nil)) args.title = args.title or strutils.format( (args.special or args.manual) and args.old and old_title_temp_no_short_msg or (args.special or args.manual) and title_temp_no_short_msg or args.old and old_title_temp or title_temp, args) local has_nom_mp = args.nom_mp and not (#args.nom_mp == 1 and args.nom_mp[1][1] == "-") local accel_forms = get_accel_forms(args.old, args.special, has_nom_mp) for _, case in ipairs(all_cases) do if args[case] then local accel_form = accel_forms[case] if not accel_form then error("Internal error: Unrecognized case " .. case .. " when looking up accelerator form") end if args.noneuter or args.real_surname then accel_form = rsub(accel_form, "//n", "") end if args.real_surname then accel_form = rsub(accel_form, "an|", "") end args[case] = nom.show_form(args[case], false, accel_form, lemma_forms) else args[case] = nil end end local temp, fullc if args.special == "oba" then temp = template_oba fullc = full_clause_oba elseif args.special == "dva" then temp = template_dva fullc = full_clause_dva elseif args.special == "cdva" then temp = template_dva -- no template_cdva fullc = full_clause_compound_dva elseif args.real_surname and args.old and has_nom_mp then temp = template_mp_no_neuter fullc = surname_full_clause_mp elseif args.real_surname then temp = template_no_neuter fullc = surname_full_clause elseif args.noneuter and args.old and has_nom_mp then temp = template_mp_no_neuter fullc = full_clause_mp_no_neuter elseif args.noneuter then temp = template_no_neuter fullc = full_clause_no_neuter elseif args.old and has_nom_mp then temp = template_mp fullc = full_clause_mp else temp = template fullc = full_clause end if args.old then if has_nom_mp then if args.short_m or args.short_n or args.short_f or args.short_p then args.short_m = args.short_m or "&mdash;" args.short_n = args.short_n or "&mdash;" args.short_f = args.short_f or "&mdash;" args.short_p = args.short_p or "&mdash;" args.shortsep = not args.nofull and ( args.noneuter and short_clause_mp_no_neuter_separator or short_clause_mp_separator ) or "" args.short_clause = strutils.format(args.noneuter and short_clause_mp_no_neuter or short_clause_mp, args) else args.short_clause = "" end else args.short_clause = "" end else if args.short_m or args.short_n or args.short_f or args.short_p then args.short_m = args.short_m or "&mdash;" args.short_n = args.short_n or "&mdash;" args.short_f = args.short_f or "&mdash;" args.short_p = args.short_p or "&mdash;" args.shortsep = not args.nofull and ( args.noneuter and short_clause_no_neuter_separator or short_clause_separator ) or "" args.short_clause = strutils.format(args.noneuter and short_clause_no_neuter or short_clause, args) else args.short_clause = "" end end if not args.nofull then args.full_clause = strutils.format(fullc, args) else args.full_clause = "" end args.internal_notes = table.concat(args.internal_notes, "<br />") args.internal_notes_clause = #args.internal_notes > 0 and strutils.format(internal_notes_template, args) or "" args.notes_clause = args.notes and strutils.format(notes_template, args) or "" return strutils.format(temp, args) end -- Used for new-style templates short_clause_separator = [===[ ! style="height:0.2em;background:#d9ebff" colspan="6" | |- ]===] -- Used for new-style templates short_clause = [===[ {shortsep}! style="background:#eff7ff" colspan="2" | short form | {short_m} | {short_n} | {short_f} | {short_p}]===] -- Used for new-style templates short_clause_no_neuter_separator = [===[ ! style="height:0.2em;background:#d9ebff" colspan="5" | |- ]===] -- Used for new-style templates short_clause_no_neuter = [===[ {shortsep}! style="background:#eff7ff" colspan="2" | short form | {short_m} | {short_f} | {short_p}]===] -- Used for old-style templates short_clause_mp_separator = [===[ ! style="height:0.2em;background:#d9ebff" colspan="7" | |- ]===] -- Used for old-style templates short_clause_mp = [===[ {shortsep}! style="background:#eff7ff" colspan="2" | short form | {short_m} | {short_n} | {short_f} | colspan="2" | {short_p}]===] -- Used for old-style templates short_clause_mp_no_neuter_separator = [===[ ! style="height:0.2em;background:#d9ebff" colspan="6" | |- ]===] -- Used for old-style templates short_clause_mp_no_neuter = [===[ {shortsep}! style="background:#eff7ff" colspan="2" | short form | {short_m} | {short_f} | colspan="2" | {short_p}]===] -- Used for both new-style and old-style templates notes_template = [===[ <div style="width:100%;text-align:left"> <div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em"> {notes} </div></div> ]===] -- Used for both new-style and old-style templates internal_notes_template = rsub(notes_template, "notes", "internal_notes") local function template_prelude(min_width) min_width = min_width or "70" return rsub([===[ <div> <div class="NavFrame" style="display: inline-block; min-width: MINWIDTHem"> <div class="NavHead" style="background:#eff7ff">{title}</div> <div class="NavContent"> {\op}| style="background:#F9F9F9;text-align:center; min-width:MINWIDTHem" class="inflection-table" |- ]===], "MINWIDTH", min_width) end local function template_postlude() return [===[{full_clause}|-{short_clause} |{\cl}{internal_notes_clause}{notes_clause}</div></div></div>]===] end -- Used for both new-style and old-style templates template = template_prelude() .. [===[ ! style="width:20%;background:#d9ebff" colspan="2" | ! style="background:#d9ebff" | masculine ! style="background:#d9ebff" | neuter ! style="background:#d9ebff" | feminine ! style="background:#d9ebff" | plural ]===] .. template_postlude() -- Used for both new-style and old-style templates full_clause = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_n} | {nom_f} | {nom_p} |- ! style="background:#eff7ff" colspan="2" | genitive | colspan="2" | {gen_m} | {gen_f} | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | colspan="2" | {dat_m} | {dat_f} | {dat_p} |- ! style="background:#eff7ff" rowspan="2" | accusative ! style="background:#eff7ff" | animate | {acc_m_an} | rowspan="2" | {acc_n} | rowspan="2" | {acc_f} | {acc_p_an} |- ! style="background:#eff7ff" | inanimate | {acc_m_in} | {acc_p_in} |- ! style="background:#eff7ff" colspan="2" | instrumental | colspan="2" | {ins_m} | {ins_f} | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | colspan="2" | {pre_m} | {pre_f} | {pre_p} ]===] -- Used for both new-style and old-style templates template_no_neuter = template_prelude("55") .. [===[ ! style="width:20%;background:#d9ebff" colspan="2" | ! style="background:#d9ebff" | masculine ! style="background:#d9ebff" | feminine ! style="background:#d9ebff" | plural ]===] .. template_postlude() -- Used for both new-style and old-style templates full_clause_no_neuter = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_f} | {nom_p} |- ! style="background:#eff7ff" colspan="2" | genitive | {gen_m} | {gen_f} | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | {dat_m} | {dat_f} | {dat_p} |- ! style="background:#eff7ff" rowspan="2" | accusative ! style="background:#eff7ff" | animate | {acc_m_an} | rowspan="2" | {acc_f} | {acc_p_an} |- ! style="background:#eff7ff" | inanimate | {acc_m_in} | {acc_p_in} |- ! style="background:#eff7ff" colspan="2" | instrumental | {ins_m} | {ins_f} | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | {pre_m} | {pre_f} | {pre_p} ]===] -- Used for both new-style and old-style templates surname_full_clause = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_f} | {nom_p} |- ! style="background:#eff7ff" colspan="2" | genitive | {gen_m} | {gen_f} | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | {dat_m} | {dat_f} | {dat_p} |- ! style="background:#eff7ff" colspan="2" | accusative | {acc_m_an} | {acc_f} | {acc_p_an} |- ! style="background:#eff7ff" colspan="2" | instrumental | {ins_m} | {ins_f} | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | {pre_m} | {pre_f} | {pre_p} ]===] -- Used for old-style templates template_mp = template_prelude() .. [===[ ! style="width:20%;background:#d9ebff" colspan="2" | ! style="background:#d9ebff" | masculine ! style="background:#d9ebff" | neuter ! style="background:#d9ebff" | feminine ! style="background:#d9ebff" | m. plural ! style="background:#d9ebff" | n./f. plural ]===] .. template_postlude() -- Used for old-style templates full_clause_mp = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_n} | {nom_f} | {nom_mp} | {nom_p} |- ! style="background:#eff7ff" colspan="2" | genitive | colspan="2" | {gen_m} | {gen_f} | colspan="2" | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | colspan="2" | {dat_m} | {dat_f} | colspan="2" | {dat_p} |- ! style="background:#eff7ff" rowspan="2" | accusative ! style="background:#eff7ff" | animate | {acc_m_an} | rowspan="2" | {acc_n} | rowspan="2" | {acc_f} | colspan="2" | {acc_p_an} |- ! style="background:#eff7ff" | inanimate | {acc_m_in} | {acc_mp_in} | {acc_p_in} |- ! style="background:#eff7ff" colspan="2" | instrumental | colspan="2" | {ins_m} | {ins_f} | colspan="2" | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | colspan="2" | {pre_m} | {pre_f} | colspan="2" | {pre_p} ]===] -- Used for old-style templates template_mp_no_neuter = template_prelude("60") .. [===[ ! style="width:20%;background:#d9ebff" colspan="2" | ! style="background:#d9ebff" | masculine ! style="background:#d9ebff" | feminine ! style="background:#d9ebff" | m. plural ! style="background:#d9ebff" | f. plural ]===] .. template_postlude() -- Used for old-style templates full_clause_mp_no_neuter = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_f} | {nom_mp} | {nom_p} |- ! style="background:#eff7ff" colspan="2" | genitive | {gen_m} | {gen_f} | colspan="2" | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | {dat_m} | {dat_f} | colspan="2" | {dat_p} |- ! style="background:#eff7ff" rowspan="2" | accusative ! style="background:#eff7ff" | animate | {acc_m_an} | rowspan="2" | {acc_f} | colspan="2" | {acc_p_an} |- ! style="background:#eff7ff" | inanimate | {acc_m_in} | {acc_mp_in} | {acc_p_in} |- ! style="background:#eff7ff" colspan="2" | instrumental | {ins_m} | {ins_f} | colspan="2" | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | {pre_m} | {pre_f} | colspan="2" | {pre_p} ]===] -- Used for some old-style templates surname_full_clause_mp = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_f} | {nom_mp} | {nom_p} |- ! style="background:#eff7ff" colspan="2" | genitive | {gen_m} | {gen_f} | colspan="2" | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | {dat_m} | {dat_f} | colspan="2" | {dat_p} |- ! style="background:#eff7ff" colspan="2" | accusative | {acc_m_an} | {acc_f} | colspan="2" | {acc_p_an} |- ! style="background:#eff7ff" colspan="2" | instrumental | {ins_m} | {ins_f} | colspan="2" | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | {pre_m} | {pre_f} | colspan="2" | {pre_p} ]===] -- Used for два and compounds template_dva = template_prelude("55") .. [===[ ! style="width:20%;background:#d9ebff" colspan="2" | ! style="background:#d9ebff" | masculine/neuter ! style="background:#d9ebff" | feminine ]===] .. template_postlude() -- Used for both new-style and old-style templates of два (only for два itself, -- which has an animacy distinction; not for compounds) full_clause_dva = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_mp} | {nom_fp} |- ! style="background:#eff7ff" colspan="2" | genitive | colspan="2" | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | colspan="2" | {dat_p} |- ! style="background:#eff7ff" rowspan="2" | accusative ! style="background:#eff7ff" | animate | colspan="2" | {acc_p_an} |- ! style="background:#eff7ff" | inanimate | {acc_mp_in} | {acc_fp_in} |- ! style="background:#eff7ff" colspan="2" | instrumental | colspan="2" | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | colspan="2" | {pre_p} ]===] -- Used for both new-style and old-style templates of compounds of два full_clause_compound_dva = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_mp} | {nom_fp} |- ! style="background:#eff7ff" colspan="2" | genitive | colspan="2" | {gen_p} |- ! style="background:#eff7ff" colspan="2" | dative | colspan="2" | {dat_p} |- ! style="background:#eff7ff" colspan="2" | accusative | {acc_mp} | {acc_fp} |- ! style="background:#eff7ff" colspan="2" | instrumental | colspan="2" | {ins_p} |- ! style="background:#eff7ff" colspan="2" | prepositional | colspan="2" | {pre_p} ]===] -- Used for оба template_oba = template_prelude() .. [===[ ! style="width:20%;background:#d9ebff" colspan="2" | ! style="background:#d9ebff" | masculine ! style="background:#d9ebff" | neuter ! style="background:#d9ebff" | feminine ! style="background:#d9ebff" | m./n. plural ! style="background:#d9ebff" | f. plural ]===] .. template_postlude() -- Used for both new-style and old-style templates of оба full_clause_oba = [===[ |- ! style="background:#eff7ff" colspan="2" | nominative | {nom_m} | {nom_n} | {nom_f} | {nom_mp} | {nom_fp} |- ! style="background:#eff7ff" colspan="2" | genitive | colspan="2" | {gen_m} | {gen_f} | {gen_mp} | {gen_fp} |- ! style="background:#eff7ff" colspan="2" | dative | colspan="2" | {dat_m} | {dat_f} | {dat_mp} | {dat_fp} |- ! style="background:#eff7ff" rowspan="2" | accusative ! style="background:#eff7ff" | animate | {acc_m_an} | rowspan="2" | {acc_n} | rowspan="2" | {acc_f} | {acc_mp_an} | {acc_fp_an} |- ! style="background:#eff7ff" | inanimate | {acc_m_in} | {acc_mp_in} | {acc_fp_in} |- ! style="background:#eff7ff" colspan="2" | instrumental | colspan="2" | {ins_m} | {ins_f} | {ins_mp} | {ins_fp} |- ! style="background:#eff7ff" colspan="2" | prepositional | colspan="2" | {pre_m} | {pre_f} | {pre_mp} | {pre_fp} ]===] return export d64obghk2etrs4g3nt60xzxw6uaw061 Templet:sr-naslov 10 5231 13227 2022-07-26T19:04:16Z Asinis632 1829 Created page with "{{-sr-}} <includeonly>{{#switch:{{padleft:{{{3|3}}}|1|0}} |1= '''{{{1}}}''' == [[{{{2}}}|{{{1}}}]] ([[Викиречник:Српски|српски]], [[Викиречник:Latinica|lat.]] [[{{{2}}}]]) == [[Категорија:{{{4}}}:Ћирилица]] |2= '''{{{2}}}''' == [[{{{1}}}|{{{2}}}]] ([[Викиречник:Српски|српски]], [[Викиречник:Ћирилица|ћир.]] [[{{{1}}}]]) == [[Категорија:{{{4}}}:Латиница]] |#defaul..." wikitext text/x-wiki {{-sr-}} <includeonly>{{#switch:{{padleft:{{{3|3}}}|1|0}} |1= '''{{{1}}}''' == [[{{{2}}}|{{{1}}}]] ([[Викиречник:Српски|српски]], [[Викиречник:Latinica|lat.]] [[{{{2}}}]]) == [[Категорија:{{{4}}}:Ћирилица]] |2= '''{{{2}}}''' == [[{{{1}}}|{{{2}}}]] ([[Викиречник:Српски|српски]], [[Викиречник:Ћирилица|ћир.]] [[{{{1}}}]]) == [[Категорија:{{{4}}}:Латиница]] |#default=※}}</includeonly> jk41yupav0fw3mgi68pkqtuhkk43la9