@valueerror/ltjs-lang-pl 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +232 -0
- package/NOTICE +9 -0
- package/README.md +25 -2
- package/index.js +8 -0
- package/licenses/LGPL-2.1.txt +504 -0
- package/licenses/resource_pl_README.txt +67 -0
- package/licenses/resource_pl_hunspell_README_en.txt +34 -0
- package/package.json +60 -4
- package/resource-root.js +4 -0
- package/resources/META-INF/org/languagetool/language-module.properties +1 -0
- package/resources/org/languagetool/resource/pl/README.txt +67 -0
- package/resources/org/languagetool/resource/pl/added.txt +5 -0
- package/resources/org/languagetool/resource/pl/added_custom.txt +4 -0
- package/resources/org/languagetool/resource/pl/compounds.txt +1862 -0
- package/resources/org/languagetool/resource/pl/disambiguation.xml +15826 -0
- package/resources/org/languagetool/resource/pl/hunspell/README_en.txt +34 -0
- package/resources/org/languagetool/resource/pl/hunspell/ignore.txt +182 -0
- package/resources/org/languagetool/resource/pl/hunspell/pl_PL.dict +0 -0
- package/resources/org/languagetool/resource/pl/hunspell/pl_PL.info +19 -0
- package/resources/org/languagetool/resource/pl/hunspell/prohibit.txt +14 -0
- package/resources/org/languagetool/resource/pl/hunspell/spelling.txt +144 -0
- package/resources/org/languagetool/resource/pl/multiwords.txt +232 -0
- package/resources/org/languagetool/resource/pl/nie_compar_exceptions.txt +58 -0
- package/resources/org/languagetool/resource/pl/polish.dict +0 -0
- package/resources/org/languagetool/resource/pl/polish.info +38 -0
- package/resources/org/languagetool/resource/pl/polish_synth.dict +0 -0
- package/resources/org/languagetool/resource/pl/polish_synth.info +38 -0
- package/resources/org/languagetool/resource/pl/polish_tags.txt +1095 -0
- package/resources/org/languagetool/resource/pl/removed.txt +4 -0
- package/resources/org/languagetool/resource/pl/removed_custom.txt +4 -0
- package/resources/org/languagetool/rules/pl/bitext.xml +30 -0
- package/resources/org/languagetool/rules/pl/coherency.txt +323 -0
- package/resources/org/languagetool/rules/pl/grammar.xml +31052 -0
- package/resources/org/languagetool/rules/pl/replace.txt +237 -0
- package/src/lang/pl/language/Polish.js +111 -0
- package/src/lang/pl/rules/CompoundRule.js +40 -0
- package/src/lang/pl/rules/DashRule.js +32 -0
- package/src/lang/pl/rules/DateCheckFilter.js +56 -0
- package/src/lang/pl/rules/DecadeSpellingFilter.js +56 -0
- package/src/lang/pl/rules/MorfologikPolishSpellerRule.js +141 -0
- package/src/lang/pl/rules/PolishUnpairedBracketsRule.js +23 -0
- package/src/lang/pl/rules/PolishWordRepeatRule.js +64 -0
- package/src/lang/pl/rules/SimpleReplaceRule.js +63 -0
- package/src/lang/pl/rules/WordCoherencyRule.js +40 -0
- package/src/lang/pl/synthesis/PolishSynthesizer.js +151 -0
- package/src/lang/pl/tagging/PolishHybridDisambiguator.js +25 -0
- package/src/lang/pl/tagging/PolishTagger.js +95 -0
- package/src/lang/pl/tokenizers/PolishWordTokenizer.js +112 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# @author Marcin Miłkowski
|
|
2
|
+
#
|
|
3
|
+
# Bezkontekstowe literówki — tj. wyrazy niewykrywane przez normalny
|
|
4
|
+
# korektor pisowni, a bardzo rzadkie i będące literówkami. Są tutaj
|
|
5
|
+
# też formy bardzo odbiegające od błędu, a więc niegenerowane przez
|
|
6
|
+
# korektor pisowni.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
akcesorii=akcesoriów
|
|
10
|
+
akwarii=akwariów
|
|
11
|
+
akuku=a kuku
|
|
12
|
+
apropo=à propos
|
|
13
|
+
apropos=à propos
|
|
14
|
+
centr=centrów
|
|
15
|
+
jurz=już
|
|
16
|
+
poraz=po raz
|
|
17
|
+
piaty=piąty
|
|
18
|
+
dojąć=dojść
|
|
19
|
+
dzieję=dzieje
|
|
20
|
+
zawszę=zawsze
|
|
21
|
+
parz=patrz
|
|
22
|
+
przejcie=przejście
|
|
23
|
+
slaby=słaby
|
|
24
|
+
Aachen=Akwizgran
|
|
25
|
+
Andego=Andy’ego
|
|
26
|
+
Andemu=Andy’emu
|
|
27
|
+
Bałyku=Bałtyku
|
|
28
|
+
Barrego=Barry’ego
|
|
29
|
+
Barremu=Barry’emu
|
|
30
|
+
Billego=Billy’ego
|
|
31
|
+
Billemu=Billy’emu
|
|
32
|
+
Bruca=Bruce’a
|
|
33
|
+
Brucowi=Bruce’owi
|
|
34
|
+
Brucem=Bruce’em
|
|
35
|
+
Brucie=Brusie
|
|
36
|
+
Cliva=Clive’a
|
|
37
|
+
Clivowi=Clive’owi
|
|
38
|
+
Clivem=Clive’em
|
|
39
|
+
Chańcza=Hańcza
|
|
40
|
+
Dava=Dave’a
|
|
41
|
+
Davem=Dave’em
|
|
42
|
+
Dwayna=Dwayne’a
|
|
43
|
+
Dwaynem=Dwayne’em
|
|
44
|
+
Ericem=Erikiem
|
|
45
|
+
Ericiem=Erikiem
|
|
46
|
+
Garego=Gary’go
|
|
47
|
+
Garemu=Gary’emu
|
|
48
|
+
Gregorego=Gregory’ego
|
|
49
|
+
Gregoremu=Gregory’emu
|
|
50
|
+
Harrego=Harry’ego
|
|
51
|
+
Harremu=Harry’emu
|
|
52
|
+
Jeremego=Jeremy’ego
|
|
53
|
+
Jerememu=Jeremy’emu
|
|
54
|
+
Jerrego=Jerry’ego
|
|
55
|
+
Jerremu=Jerry’emu
|
|
56
|
+
Laurenca=Laurence’a
|
|
57
|
+
Laurencem=Laurence’em
|
|
58
|
+
Laurencie=Laurensie
|
|
59
|
+
Lawrenca=Lawrence’a
|
|
60
|
+
Lawrencem=Lawrence’em
|
|
61
|
+
Lawrencie=Lawrensie
|
|
62
|
+
Lukem=Lukiem
|
|
63
|
+
Mika=Mike’a
|
|
64
|
+
Mikowi=Mike’owi
|
|
65
|
+
Mikem=Mikiem
|
|
66
|
+
Miku=Mike’u
|
|
67
|
+
Pierca=Pierce’a
|
|
68
|
+
Piercem=Pierce’em
|
|
69
|
+
Ridga=Ridge’a
|
|
70
|
+
Ridgem=Ridge’em
|
|
71
|
+
Smithie=Smicie
|
|
72
|
+
Steva=Steve’a
|
|
73
|
+
Stevem=Steve’em
|
|
74
|
+
Stevowi=Steve’owi
|
|
75
|
+
Terrego=Terry’ego
|
|
76
|
+
Terremu=Terry’emu
|
|
77
|
+
Wayna=Wayne’a
|
|
78
|
+
Waynem=Wayne’em
|
|
79
|
+
Stéphana=Stéphane’a
|
|
80
|
+
Stéphanowi=Stéphane’owi
|
|
81
|
+
Stéphanem=Stéphane’em
|
|
82
|
+
Yvesa=Yves’a
|
|
83
|
+
Yvesem=Yves’em
|
|
84
|
+
Yvesie=Yvie
|
|
85
|
+
Europom=Europą
|
|
86
|
+
bezsensowy=bezsensowny
|
|
87
|
+
otocznia=otoczenia
|
|
88
|
+
otocznie=otoczenie
|
|
89
|
+
mięli=mieli
|
|
90
|
+
maił=miał
|
|
91
|
+
spadłą=spadła
|
|
92
|
+
conajmniej=co najmniej
|
|
93
|
+
wogle=w ogóle
|
|
94
|
+
wogole=w ogóle
|
|
95
|
+
codzien=co dzień
|
|
96
|
+
codzień=co dzień
|
|
97
|
+
moznaby=można by
|
|
98
|
+
narazie=na razie
|
|
99
|
+
nielada=nie lada
|
|
100
|
+
odrazu=od razu
|
|
101
|
+
opatrznie=opacznie
|
|
102
|
+
nieopacznie=nieopatrznie
|
|
103
|
+
poprostu=po prostu
|
|
104
|
+
pozatym=poza tym
|
|
105
|
+
przedewszystkim=przede wszystkim
|
|
106
|
+
spowrotem=z powrotem
|
|
107
|
+
pryz=przy
|
|
108
|
+
szłem=szedłem
|
|
109
|
+
poszłem=poszedłem
|
|
110
|
+
piatek=piątek
|
|
111
|
+
pokuj=pokój
|
|
112
|
+
prosze=proszę
|
|
113
|
+
rząda=żąda
|
|
114
|
+
sa=są
|
|
115
|
+
sei=się
|
|
116
|
+
sie=się
|
|
117
|
+
ise=się
|
|
118
|
+
ię=się
|
|
119
|
+
sią=się
|
|
120
|
+
chłopcowi=chłopcu
|
|
121
|
+
bratowi=bratu
|
|
122
|
+
aleji=alei
|
|
123
|
+
lubieć=lubić
|
|
124
|
+
bussinesmenów=businessmanów
|
|
125
|
+
synie=synu
|
|
126
|
+
non-stop=non stop
|
|
127
|
+
swomi=swoimi
|
|
128
|
+
uż=już
|
|
129
|
+
łep=łeb
|
|
130
|
+
cie=cię
|
|
131
|
+
dac=dać
|
|
132
|
+
dame=damę
|
|
133
|
+
domie=domu
|
|
134
|
+
mahała=machała
|
|
135
|
+
myłka=zmyłka
|
|
136
|
+
łab=łap
|
|
137
|
+
cz=czy|cz.
|
|
138
|
+
dzis=dziś
|
|
139
|
+
dżaz=jazz
|
|
140
|
+
duto=dłuto
|
|
141
|
+
gróz=gruz
|
|
142
|
+
istniej=istnieje
|
|
143
|
+
joystik=joystick
|
|
144
|
+
juz=już
|
|
145
|
+
krotko=krótko
|
|
146
|
+
lekaż=lekarz
|
|
147
|
+
lekaży=lekarzy
|
|
148
|
+
lekażach=lekarzach
|
|
149
|
+
lekażami=lekarzami
|
|
150
|
+
lekażom=lekarzom
|
|
151
|
+
lekażem=lekarzem
|
|
152
|
+
lekażowi=lekarzowi
|
|
153
|
+
lekażu=lekarzu
|
|
154
|
+
lekażów=lekarzy
|
|
155
|
+
lekaże=lekarze
|
|
156
|
+
mogla=mogła
|
|
157
|
+
moglem=mogłem
|
|
158
|
+
następce=następcę
|
|
159
|
+
niewiadomo=nie wiadomo
|
|
160
|
+
obiat=obiad
|
|
161
|
+
obiedwie=obydwie
|
|
162
|
+
ośródek=ośrodek
|
|
163
|
+
ośródka=ośrodka
|
|
164
|
+
ośródkiem=ośrodkiem
|
|
165
|
+
ośródkowi=ośrodkowi
|
|
166
|
+
ośródku=ośrodku
|
|
167
|
+
ośródków=ośrodków
|
|
168
|
+
ośródkach=ośrodkach
|
|
169
|
+
ośródkami=ośrodkami
|
|
170
|
+
ośródkom=ośrodkom
|
|
171
|
+
ośródki=ośrodki
|
|
172
|
+
pletwa=płetwa
|
|
173
|
+
pletwą=płetwą
|
|
174
|
+
pletwę=płetwę
|
|
175
|
+
pletwie=płetwie
|
|
176
|
+
pletwo=płetwo
|
|
177
|
+
pletwy=płetwy
|
|
178
|
+
pol=pół
|
|
179
|
+
powielekroć=po wielekroć
|
|
180
|
+
urzęd=urząd
|
|
181
|
+
pletwach=płetwach
|
|
182
|
+
pletwami=płetwami
|
|
183
|
+
pletwom=płetwom
|
|
184
|
+
pletw=płetw
|
|
185
|
+
prez=przez
|
|
186
|
+
prob=prób
|
|
187
|
+
bolach=bólach
|
|
188
|
+
bolami=bólami
|
|
189
|
+
bole=bóle
|
|
190
|
+
bolem=bólem
|
|
191
|
+
bolom=bólom
|
|
192
|
+
bolowi=bólowi
|
|
193
|
+
bolu=bólu
|
|
194
|
+
bolów=bólów
|
|
195
|
+
bul=ból
|
|
196
|
+
duh=duch
|
|
197
|
+
niz=niż
|
|
198
|
+
poobiedzie=po obiedzie
|
|
199
|
+
nieprawa=nieprawda
|
|
200
|
+
podroż=podróż
|
|
201
|
+
polak=Polak
|
|
202
|
+
tyko=tylko
|
|
203
|
+
sposobowy=sposoby
|
|
204
|
+
kopi=kopii
|
|
205
|
+
dosiego=do siego
|
|
206
|
+
dożo=dużo
|
|
207
|
+
stanowic=stanowić
|
|
208
|
+
działaś=działać|działań
|
|
209
|
+
storn=stron
|
|
210
|
+
następuję=następuje
|
|
211
|
+
linuks=Linux
|
|
212
|
+
osmy=ósmy
|
|
213
|
+
rug=róg
|
|
214
|
+
bódź=budź
|
|
215
|
+
bódźcie=budźcie
|
|
216
|
+
zespól=zespół
|
|
217
|
+
maż=mąż|masz
|
|
218
|
+
maży=marzy
|
|
219
|
+
mażę=marzę
|
|
220
|
+
maże=marzę
|
|
221
|
+
znal=znał
|
|
222
|
+
znalem=znałem
|
|
223
|
+
Jeszce=Jeszcze
|
|
224
|
+
jusz=już
|
|
225
|
+
Bedę=Będę
|
|
226
|
+
Bedą=Będą
|
|
227
|
+
zrobie=zrobię
|
|
228
|
+
czany=czarny
|
|
229
|
+
poco=po co
|
|
230
|
+
przestala=przestała
|
|
231
|
+
przestalam=przestałam
|
|
232
|
+
graja=grają
|
|
233
|
+
fer=fair
|
|
234
|
+
ostania=ostatnia
|
|
235
|
+
ekonomi=ekonomii
|
|
236
|
+
słonce=słońce
|
|
237
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Java: org.languagetool.language.Polish
|
|
2
|
+
import { Language } from '@valueerror/ltjs-core/src/core/Language.js';
|
|
3
|
+
import { MARCIN_MILKOWSKI } from '@valueerror/ltjs-core/src/core/language/Contributors.js';
|
|
4
|
+
import { LanguageMaintainedState } from '@valueerror/ltjs-core/src/core/LanguageMaintainedState.js';
|
|
5
|
+
import { createComponent } from '@valueerror/ltjs-core/src/core/language/components.js';
|
|
6
|
+
import { registerClass } from '@valueerror/ltjs-core/src/core/resources/ClassBroker.js';
|
|
7
|
+
import { SRXSentenceTokenizer } from '@valueerror/ltjs-core/src/core/text/tokenizers/SRXSentenceTokenizer.js';
|
|
8
|
+
import { CommaWhitespaceRule } from '@valueerror/ltjs-core/src/core/rules/CommaWhitespaceRule.js';
|
|
9
|
+
import { UppercaseSentenceStartRule } from '@valueerror/ltjs-core/src/core/rules/UppercaseSentenceStartRule.js';
|
|
10
|
+
import { WordRepeatRule } from '@valueerror/ltjs-core/src/core/rules/WordRepeatRule.js';
|
|
11
|
+
import { MultipleWhitespaceRule } from '@valueerror/ltjs-core/src/core/rules/MultipleWhitespaceRule.js';
|
|
12
|
+
import { SentenceWhitespaceRule } from '@valueerror/ltjs-core/src/core/rules/SentenceWhitespaceRule.js';
|
|
13
|
+
import { PolishUnpairedBracketsRule } from '../rules/PolishUnpairedBracketsRule.js';
|
|
14
|
+
import { MorfologikPolishSpellerRule } from '../rules/MorfologikPolishSpellerRule.js';
|
|
15
|
+
import { PolishWordRepeatRule } from '../rules/PolishWordRepeatRule.js';
|
|
16
|
+
import { CompoundRule } from '../rules/CompoundRule.js';
|
|
17
|
+
import { SimpleReplaceRule } from '../rules/SimpleReplaceRule.js';
|
|
18
|
+
import { WordCoherencyRule } from '../rules/WordCoherencyRule.js';
|
|
19
|
+
import { DashRule } from '../rules/DashRule.js';
|
|
20
|
+
import { PolishTagger } from '../tagging/PolishTagger.js';
|
|
21
|
+
import { PolishWordTokenizer } from '../tokenizers/PolishWordTokenizer.js';
|
|
22
|
+
import { PolishSynthesizer } from '../synthesis/PolishSynthesizer.js';
|
|
23
|
+
|
|
24
|
+
// Java: Polish
|
|
25
|
+
export class Polish extends Language {
|
|
26
|
+
static FQCN = 'org.languagetool.language.Polish';
|
|
27
|
+
|
|
28
|
+
// Java: Polish#getName()
|
|
29
|
+
getName() {
|
|
30
|
+
return 'Polish';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Java: Polish#getShortCode()
|
|
34
|
+
getShortCode() {
|
|
35
|
+
return 'pl';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Java: Polish#getCountries()
|
|
39
|
+
getCountries() {
|
|
40
|
+
return ['PL'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Java: Polish#createDefaultTagger()
|
|
44
|
+
createDefaultTagger() {
|
|
45
|
+
return new PolishTagger();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Java: Polish#createDefaultSentenceTokenizer()
|
|
49
|
+
createDefaultSentenceTokenizer() {
|
|
50
|
+
return new SRXSentenceTokenizer(this);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Java: Polish#createDefaultWordTokenizer()
|
|
54
|
+
createDefaultWordTokenizer() {
|
|
55
|
+
const wordTokenizer = new PolishWordTokenizer();
|
|
56
|
+
wordTokenizer.setTagger(this.getTagger());
|
|
57
|
+
return wordTokenizer;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Java: Polish#createDefaultDisambiguator()
|
|
61
|
+
createDefaultDisambiguator() {
|
|
62
|
+
return createComponent('org.languagetool.tagging.disambiguation.pl.PolishHybridDisambiguator');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Java: Polish#createDefaultSynthesizer()
|
|
66
|
+
createDefaultSynthesizer() {
|
|
67
|
+
return PolishSynthesizer.INSTANCE;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Java: Polish#getMaintainers()
|
|
71
|
+
getMaintainers() {
|
|
72
|
+
return [MARCIN_MILKOWSKI];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Java: Polish#getRelevantRules(ResourceBundle,UserConfig,Language,List)
|
|
76
|
+
getRelevantRules(messages, userConfig, motherTongue, altLanguages) {
|
|
77
|
+
return [
|
|
78
|
+
new CommaWhitespaceRule(messages),
|
|
79
|
+
new UppercaseSentenceStartRule(messages, this),
|
|
80
|
+
new WordRepeatRule(messages, this),
|
|
81
|
+
new MultipleWhitespaceRule(messages, this),
|
|
82
|
+
new SentenceWhitespaceRule(messages),
|
|
83
|
+
// specific to Polish:
|
|
84
|
+
new PolishUnpairedBracketsRule(messages, this),
|
|
85
|
+
new MorfologikPolishSpellerRule(messages, this, userConfig, altLanguages),
|
|
86
|
+
new PolishWordRepeatRule(messages),
|
|
87
|
+
new CompoundRule(messages, this, userConfig),
|
|
88
|
+
new SimpleReplaceRule(messages, this),
|
|
89
|
+
new WordCoherencyRule(messages),
|
|
90
|
+
new DashRule(messages),
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Java: Polish#getMaintainedState()
|
|
95
|
+
getMaintainedState() {
|
|
96
|
+
return LanguageMaintainedState.ActivelyMaintained;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Java: Polish#getPriorityForId(String)
|
|
100
|
+
getPriorityForId(id) {
|
|
101
|
+
if (id === 'ZDANIA_ZLOZONE') return -1; // so that it does not override more important rules
|
|
102
|
+
return super.getPriorityForId(id);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Java: Polish#createDefaultSpellingRule(ResourceBundle)
|
|
106
|
+
createDefaultSpellingRule(messages) {
|
|
107
|
+
return new MorfologikPolishSpellerRule(messages, this, null, null);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
registerClass(Polish.FQCN, Polish);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Java: org.languagetool.rules.pl.CompoundRule
|
|
2
|
+
import { AbstractCompoundRule } from '@valueerror/ltjs-core/src/core/rules/AbstractCompoundRule.js';
|
|
3
|
+
import { CompoundRuleData } from '@valueerror/ltjs-core/src/core/rules/CompoundRuleData.js';
|
|
4
|
+
import { Example } from '@valueerror/ltjs-core/src/core/rules/model/Examples.js';
|
|
5
|
+
|
|
6
|
+
let compoundData = null; // Java: static volatile compoundData
|
|
7
|
+
|
|
8
|
+
// Java: CompoundRule (pl)
|
|
9
|
+
export class CompoundRule extends AbstractCompoundRule {
|
|
10
|
+
static FQCN = 'org.languagetool.rules.pl.CompoundRule';
|
|
11
|
+
|
|
12
|
+
// Java: CompoundRule(ResourceBundle,Language,UserConfig)
|
|
13
|
+
constructor(messages, lang, userConfig) {
|
|
14
|
+
super(messages, lang, userConfig,
|
|
15
|
+
'Ten wyraz pisze się z łącznikiem.',
|
|
16
|
+
'Ten wyraz pisze się razem (bez spacji ani łącznika).',
|
|
17
|
+
'Ten wyraz pisze się z łącznikiem lub bez niego.',
|
|
18
|
+
'Brak łącznika lub zbędny łącznik');
|
|
19
|
+
this.addExamplePair(Example.wrong('Witamy w <marker>Rabce Zdroju</marker>.'),
|
|
20
|
+
Example.fixed('Witamy w <marker>Rabce-Zdroju</marker>.'));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Java: CompoundRule#getId()
|
|
24
|
+
getId() {
|
|
25
|
+
return 'PL_COMPOUNDS';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Java: CompoundRule#getDescription()
|
|
29
|
+
getDescription() {
|
|
30
|
+
return 'Sprawdza wyrazy z łącznikiem, np. „łapu capu” zamiast „łapu-capu”';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Java: CompoundRule#getCompoundRuleData()
|
|
34
|
+
getCompoundRuleData() {
|
|
35
|
+
if (compoundData === null) {
|
|
36
|
+
compoundData = new CompoundRuleData('/pl/compounds.txt');
|
|
37
|
+
}
|
|
38
|
+
return compoundData;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Java: org.languagetool.rules.pl.DashRule
|
|
2
|
+
import { AbstractDashRule } from '@valueerror/ltjs-core/src/core/rules/AbstractDashRule.js';
|
|
3
|
+
|
|
4
|
+
let trie = null; // Java: DashRule#trie (static, loaded once)
|
|
5
|
+
|
|
6
|
+
// Java: DashRule
|
|
7
|
+
export class DashRule extends AbstractDashRule {
|
|
8
|
+
static FQCN = 'org.languagetool.rules.pl.DashRule';
|
|
9
|
+
|
|
10
|
+
// Java: DashRule(ResourceBundle)
|
|
11
|
+
constructor(messages) {
|
|
12
|
+
super(messages);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Java: DashRule#getDescription()
|
|
16
|
+
getDescription() {
|
|
17
|
+
return 'Sprawdza, czy wyrazy pisane z łącznikiem zapisano z myślnikami (np. „Lądek — Zdrój” zamiast „Lądek-Zdrój”).';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Java: DashRule#getMessage()
|
|
21
|
+
getMessage() {
|
|
22
|
+
return 'Błędne użycie myślnika zamiast łącznika.';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Java: DashRule#getCompoundsData()
|
|
26
|
+
getCompoundsData() {
|
|
27
|
+
if (trie === null) {
|
|
28
|
+
trie = AbstractDashRule.loadCompoundFile('/pl/compounds.txt');
|
|
29
|
+
}
|
|
30
|
+
return trie;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Java: org.languagetool.rules.pl.DateCheckFilter
|
|
2
|
+
import { registerClass } from '@valueerror/ltjs-core/src/core/resources/ClassBroker.js';
|
|
3
|
+
import { Calendar } from '@valueerror/ltjs-core/src/lib/java/Calendar.js';
|
|
4
|
+
import { Locale } from '@valueerror/ltjs-core/src/lib/java/Locale.js';
|
|
5
|
+
import { RuntimeException } from '@valueerror/ltjs-core/src/lib/java/errors.js';
|
|
6
|
+
import { toLowerCase } from '@valueerror/ltjs-core/src/lib/java/strings.js';
|
|
7
|
+
import { AbstractDateCheckFilter } from '@valueerror/ltjs-core/src/core/rules/AbstractDateCheckFilter.js';
|
|
8
|
+
|
|
9
|
+
// Java: DateCheckFilter (pl)
|
|
10
|
+
export class DateCheckFilter extends AbstractDateCheckFilter {
|
|
11
|
+
static FQCN = 'org.languagetool.rules.pl.DateCheckFilter';
|
|
12
|
+
static JAVA_ABSTRACT = false;
|
|
13
|
+
static JAVA_CONSTRUCTORS = [{ params: [], text: 'public org.languagetool.rules.pl.DateCheckFilter()' }];
|
|
14
|
+
|
|
15
|
+
// Java: DateCheckFilter#getCalendar()
|
|
16
|
+
getCalendar() {
|
|
17
|
+
return Calendar.getInstance(Locale.forLanguageTag('pl'));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Java: DateCheckFilter#getDayOfWeek(String) and #getDayOfWeek(Calendar) (overloads, one JS method dispatching on the argument type)
|
|
21
|
+
getDayOfWeek(arg) {
|
|
22
|
+
if (arg instanceof Calendar) {
|
|
23
|
+
return arg.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag('pl'));
|
|
24
|
+
}
|
|
25
|
+
const dayStr = arg;
|
|
26
|
+
const day = toLowerCase(dayStr);
|
|
27
|
+
if (day.startsWith('pon')) return Calendar.MONDAY;
|
|
28
|
+
if (day.startsWith('wt')) return Calendar.TUESDAY;
|
|
29
|
+
if (day.startsWith('śr')) return Calendar.WEDNESDAY;
|
|
30
|
+
if (day.startsWith('czw')) return Calendar.THURSDAY;
|
|
31
|
+
if (day === 'pt' || day.startsWith('piątk') || day === 'piątek') return Calendar.FRIDAY;
|
|
32
|
+
if (day.startsWith('sob')) return Calendar.SATURDAY;
|
|
33
|
+
if (day.startsWith('niedz')) return Calendar.SUNDAY;
|
|
34
|
+
throw new RuntimeException("Could not find day of week for '" + dayStr + "'");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Java: DateCheckFilter#getMonth(String)
|
|
38
|
+
getMonth(monthStr) {
|
|
39
|
+
const mon = toLowerCase(monthStr);
|
|
40
|
+
if (mon === 'stycznia' || monthStr === 'I') return 1;
|
|
41
|
+
if (mon === 'lutego' || monthStr === 'II') return 2;
|
|
42
|
+
if (mon === 'marca' || monthStr === 'III') return 3;
|
|
43
|
+
if (mon === 'kwietnia' || monthStr === 'IV') return 4;
|
|
44
|
+
if (mon === 'maja' || monthStr === 'V') return 5;
|
|
45
|
+
if (mon === 'czerwca' || monthStr === 'VI') return 6;
|
|
46
|
+
if (mon === 'lipca' || monthStr === 'VII') return 7;
|
|
47
|
+
if (mon === 'sierpnia' || monthStr === 'VIII') return 8;
|
|
48
|
+
if (mon === 'września' || monthStr === 'IX') return 9;
|
|
49
|
+
if (mon === 'października' || monthStr === 'X') return 10;
|
|
50
|
+
if (mon === 'listopada' || monthStr === 'XI') return 11;
|
|
51
|
+
if (mon === 'grudnia' || monthStr === 'XII') return 12;
|
|
52
|
+
throw new RuntimeException("Could not find month '" + monthStr + "'");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
registerClass(DateCheckFilter.FQCN, DateCheckFilter);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Java: org.languagetool.rules.pl.DecadeSpellingFilter
|
|
2
|
+
import { registerClass } from '@valueerror/ltjs-core/src/core/resources/ClassBroker.js';
|
|
3
|
+
import { IllegalArgumentException, NullPointerException } from '@valueerror/ltjs-core/src/lib/java/errors.js';
|
|
4
|
+
import { Integer } from '@valueerror/ltjs-core/src/lib/java/int.js';
|
|
5
|
+
import { javaReplace, substring } from '@valueerror/ltjs-core/src/lib/java/strings.js';
|
|
6
|
+
import { RuleFilter } from '@valueerror/ltjs-core/src/core/patterns/RuleFilter.js';
|
|
7
|
+
import { RuleMatch } from '@valueerror/ltjs-core/src/core/rules/model/RuleMatch.js';
|
|
8
|
+
|
|
9
|
+
const numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
|
|
10
|
+
const letters = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
|
|
11
|
+
|
|
12
|
+
// Java: DecadeSpellingFilter
|
|
13
|
+
export class DecadeSpellingFilter extends RuleFilter {
|
|
14
|
+
static FQCN = 'org.languagetool.rules.pl.DecadeSpellingFilter';
|
|
15
|
+
static JAVA_ABSTRACT = false;
|
|
16
|
+
static JAVA_CONSTRUCTORS = [{ params: [], text: 'public org.languagetool.rules.pl.DecadeSpellingFilter()' }];
|
|
17
|
+
|
|
18
|
+
// Java: DecadeSpellingFilter#getRomanNumber(int)
|
|
19
|
+
getRomanNumber(num) {
|
|
20
|
+
let roman = '';
|
|
21
|
+
let n = num; // n represents the part of num that still has to be converted to Roman numeral representation
|
|
22
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
23
|
+
while (n >= numbers[i]) {
|
|
24
|
+
roman += letters[i];
|
|
25
|
+
n -= numbers[i];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return roman;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Java: DecadeSpellingFilter#acceptRuleMatch(RuleMatch,Map,int,AnalyzedTokenReadings[],List)
|
|
32
|
+
acceptRuleMatch(match, args) {
|
|
33
|
+
try {
|
|
34
|
+
const lata = args.get('lata');
|
|
35
|
+
if (lata === null || lata === undefined) {
|
|
36
|
+
throw new NullPointerException('Cannot invoke "String.substring(int)" because the return value of "java.util.Map.get(Object)" is null');
|
|
37
|
+
}
|
|
38
|
+
const decade = substring(lata, 2);
|
|
39
|
+
const century = substring(lata, 0, 2);
|
|
40
|
+
const cent = Integer.parseInt(century);
|
|
41
|
+
const message = javaReplace(javaReplace(match.getMessage(), '{dekada}', decade), '{wiek}', this.getRomanNumber(cent + 1));
|
|
42
|
+
const ruleMatch = new RuleMatch(match.getRule(), match.getSentence(), match.getFromPos(), match.getToPos(), match.getPatternFromPos(), match.getPatternToPos(),
|
|
43
|
+
message, match.getShortMessage(), match.getFromPos() === 0, null);
|
|
44
|
+
ruleMatch.setType(match.getType());
|
|
45
|
+
return ruleMatch;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e instanceof IllegalArgumentException) {
|
|
48
|
+
// ignore it silently
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
registerClass(DecadeSpellingFilter.FQCN, DecadeSpellingFilter);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Java: org.languagetool.rules.pl.MorfologikPolishSpellerRule
|
|
2
|
+
import { Pattern } from '@valueerror/ltjs-core/src/lib/java/regex/index.js';
|
|
3
|
+
import { javaSplit, toLowerCase } from '@valueerror/ltjs-core/src/lib/java/strings.js';
|
|
4
|
+
import { registerComponent } from '@valueerror/ltjs-core/src/core/language/components.js';
|
|
5
|
+
import { MorfologikSpellerRule } from '@valueerror/ltjs-core/src/core/rules/spelling/morfologik/MorfologikSpellerRule.js';
|
|
6
|
+
import { RuleMatch } from '@valueerror/ltjs-core/src/core/rules/model/RuleMatch.js';
|
|
7
|
+
import { SuggestedReplacement } from '@valueerror/ltjs-core/src/core/rules/model/SuggestedReplacement.js';
|
|
8
|
+
import { Categories } from '@valueerror/ltjs-core/src/core/rules/model/Category.js';
|
|
9
|
+
import { Example } from '@valueerror/ltjs-core/src/core/rules/model/Examples.js';
|
|
10
|
+
|
|
11
|
+
const RESOURCE_FILENAME = '/pl/hunspell/pl_PL.dict';
|
|
12
|
+
const POLISH_TOKENIZING_CHARS = Pattern.compile('(?:[Qq]uasi|[Nn]iby)-');
|
|
13
|
+
|
|
14
|
+
// The set of prefixes that are not allowed to be split in the suggestions.
|
|
15
|
+
const prefixes = new Set([
|
|
16
|
+
'arcy', 'neo', 'pre', 'anty', 'eks', 'bez', 'beze', 'ekstra', 'hiper', 'infra', 'kontr', 'maksi', 'midi', 'między',
|
|
17
|
+
'mini', 'nad', 'nade', 'około', 'ponad', 'post', 'pro', 'przeciw', 'pseudo', 'super', 'śród', 'ultra', 'wice', 'wokół', 'wokoło',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
// non-word suffixes that should not be suggested (only morphological endings, never after a space)
|
|
21
|
+
const bannedSuffixes = new Set(['ami', 'ach', 'e', 'ego', 'em', 'emu', 'ie', 'im', 'm', 'om', 'owie', 'owi', 'ze']);
|
|
22
|
+
|
|
23
|
+
// Java: MorfologikPolishSpellerRule
|
|
24
|
+
export class MorfologikPolishSpellerRule extends MorfologikSpellerRule {
|
|
25
|
+
static FQCN = 'org.languagetool.rules.pl.MorfologikPolishSpellerRule';
|
|
26
|
+
|
|
27
|
+
// Java: MorfologikPolishSpellerRule(ResourceBundle,Language,UserConfig,List)
|
|
28
|
+
constructor(messages, language, userConfig, altLanguages) {
|
|
29
|
+
super(messages, language, userConfig, altLanguages);
|
|
30
|
+
this.setCategory(Categories.TYPOS.getCategory(messages));
|
|
31
|
+
this.addExamplePair(Example.wrong('To jest zdanie z <marker>bledem</marker>'),
|
|
32
|
+
Example.fixed('To jest zdanie z <marker>błędem</marker>.'));
|
|
33
|
+
this.userConfig = userConfig;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Java: MorfologikPolishSpellerRule#getFileName()
|
|
37
|
+
getFileName() {
|
|
38
|
+
return RESOURCE_FILENAME;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Java: MorfologikPolishSpellerRule#getId()
|
|
42
|
+
getId() {
|
|
43
|
+
return 'MORFOLOGIK_RULE_PL_PL';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Java: MorfologikPolishSpellerRule#tokenizingPattern()
|
|
47
|
+
tokenizingPattern() {
|
|
48
|
+
return POLISH_TOKENIZING_CHARS;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Java: MorfologikPolishSpellerRule#getRuleMatches(String,int,AnalyzedSentence,List,int,AnalyzedTokenReadings[])
|
|
52
|
+
getRuleMatches(word, startPos, sentence, ruleMatchesSoFar) {
|
|
53
|
+
const speller1 = this.speller1;
|
|
54
|
+
const ruleMatches = [];
|
|
55
|
+
if ((this.isMisspelled(speller1, word) && this.isNotCompound(word)) || this.isProhibited(word)) {
|
|
56
|
+
const ruleMatch = new RuleMatch(this, sentence, startPos, startPos
|
|
57
|
+
+ word.length, this.messages.getString('spelling'),
|
|
58
|
+
this.messages.getString('desc_spelling_short'));
|
|
59
|
+
if (this.userConfig !== null && !this.userConfig.isSuggestionsEnabled()) {
|
|
60
|
+
ruleMatches.push(ruleMatch);
|
|
61
|
+
return ruleMatches;
|
|
62
|
+
}
|
|
63
|
+
// If lower case word is not a misspelled word, return it as the only suggestion
|
|
64
|
+
const createSuggestions = this.userConfig === null || this.userConfig.getMaxSpellingSuggestions() === 0
|
|
65
|
+
|| ruleMatchesSoFar.length <= this.userConfig.getMaxSpellingSuggestions();
|
|
66
|
+
if (!this.isMisspelled(speller1, toLowerCase(word, this.conversionLocale))) {
|
|
67
|
+
if (createSuggestions) {
|
|
68
|
+
ruleMatch.setSuggestedReplacements([toLowerCase(word, this.conversionLocale)]);
|
|
69
|
+
} else {
|
|
70
|
+
// limited to save CPU
|
|
71
|
+
ruleMatch.setSuggestedReplacement(this.messages.getString('too_many_errors'));
|
|
72
|
+
}
|
|
73
|
+
ruleMatches.push(ruleMatch);
|
|
74
|
+
return ruleMatches;
|
|
75
|
+
}
|
|
76
|
+
if (createSuggestions) {
|
|
77
|
+
const suggestions = SuggestedReplacement.convert(speller1.getSuggestions(word));
|
|
78
|
+
suggestions.splice(0, 0, ...this.getAdditionalTopSuggestions(suggestions, word));
|
|
79
|
+
suggestions.push(...this.getAdditionalSuggestions(suggestions, word));
|
|
80
|
+
if (suggestions.length > 0) {
|
|
81
|
+
ruleMatch.setSuggestedReplacementObjects(this.pruneSuggestions(this.orderSuggestions(suggestions, word)));
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
// limited to save CPU
|
|
85
|
+
ruleMatch.setSuggestedReplacement(this.messages.getString('too_many_errors'));
|
|
86
|
+
}
|
|
87
|
+
ruleMatches.push(ruleMatch);
|
|
88
|
+
}
|
|
89
|
+
return ruleMatches;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Java: MorfologikPolishSpellerRule#isNotCompound(String)
|
|
93
|
+
isNotCompound(word) {
|
|
94
|
+
const probablyCorrectWords = [];
|
|
95
|
+
for (let i = 2; i < word.length; i++) {
|
|
96
|
+
// chop from left to right
|
|
97
|
+
const first = word.substring(0, i);
|
|
98
|
+
const second = word.substring(i);
|
|
99
|
+
if (prefixes.has(toLowerCase(first, this.conversionLocale))
|
|
100
|
+
&& !this.isMisspelled(this.speller1, second)
|
|
101
|
+
&& second.length > first.length) { // but not for short words such as "premoc"
|
|
102
|
+
// ignore this match, it's fine
|
|
103
|
+
probablyCorrectWords.push(word); // FIXME: some strange words are being accepted, like prekupa
|
|
104
|
+
} else {
|
|
105
|
+
const testedTokens = [first, second];
|
|
106
|
+
const taggedToks = this.language.getTagger().tag(testedTokens);
|
|
107
|
+
if (taggedToks.length === 2
|
|
108
|
+
// "białozielony", trzynastobitowy
|
|
109
|
+
&& (taggedToks[0].hasPosTag('adja')
|
|
110
|
+
|| (taggedToks[0].hasPosTag('num:comp')
|
|
111
|
+
&& !taggedToks[0].hasPosTag('adv')))
|
|
112
|
+
&& taggedToks[1].hasPartialPosTag('adj:')) {
|
|
113
|
+
probablyCorrectWords.push(word);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (probablyCorrectWords.length > 0) {
|
|
118
|
+
this.addIgnoreTokens(probablyCorrectWords);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Java: MorfologikPolishSpellerRule#pruneSuggestions(List)
|
|
125
|
+
pruneSuggestions(suggestions) {
|
|
126
|
+
const prunedSuggestions = [];
|
|
127
|
+
for (const suggestion of suggestions) {
|
|
128
|
+
if (suggestion.getReplacement().indexOf(' ') === -1) {
|
|
129
|
+
prunedSuggestions.push(suggestion);
|
|
130
|
+
} else {
|
|
131
|
+
const complexSug = javaSplit(suggestion.getReplacement(), ' ');
|
|
132
|
+
if (complexSug.length > 1 && !bannedSuffixes.has(complexSug[1])) {
|
|
133
|
+
prunedSuggestions.push(suggestion);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return prunedSuggestions;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
registerComponent(MorfologikPolishSpellerRule.FQCN, (...args) => new MorfologikPolishSpellerRule(...args));
|