@scrabble-solver/word-definitions 2.9.3 → 2.10.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/build/crawl/crawl.js +2 -0
- package/build/crawl/crawlFarsi.d.ts +2 -0
- package/build/crawl/crawlFarsi.js +11 -0
- package/build/lib/normalizeDefinition.js +2 -1
- package/build/parse/index.d.ts +1 -0
- package/build/parse/index.js +3 -1
- package/build/parse/parse.js +2 -0
- package/build/parse/parseEnglish.js +1 -1
- package/build/parse/parseFarsi.d.ts +3 -0
- package/build/parse/parseFarsi.js +13 -0
- package/package.json +3 -3
- package/src/crawl/crawl.ts +2 -0
- package/src/crawl/crawlFarsi.ts +11 -0
- package/src/lib/normalizeDefinition.ts +2 -1
- package/src/parse/__tests__/input/en-US.awe.html +2170 -323
- package/src/parse/__tests__/input/en-US.pawn.html +2405 -349
- package/src/parse/__tests__/input/en-US.pawnee.html +1326 -222
- package/src/parse/__tests__/input/en-US.pean.html +1490 -201
- package/src/parse/__tests__/input/en-US.wiz.html +1526 -272
- package/src/parse/index.ts +1 -0
- package/src/parse/parse.ts +2 -0
- package/src/parse/parseEnglish.ts +2 -1
- package/src/parse/parseFarsi.ts +17 -0
package/src/parse/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as parse } from './parse';
|
|
2
2
|
export { default as parseEnglish } from './parseEnglish';
|
|
3
|
+
export { default as parseFarsi } from './parseFarsi';
|
|
3
4
|
export { default as parseFrench } from './parseFrench';
|
|
4
5
|
export { default as parseGerman } from './parseGerman';
|
|
5
6
|
export { default as parsePolish } from './parsePolish';
|
package/src/parse/parse.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { normalizeDefinition, unique } from '../lib';
|
|
|
4
4
|
import { ParseResult } from '../types';
|
|
5
5
|
|
|
6
6
|
import parseEnglish from './parseEnglish';
|
|
7
|
+
import parseFarsi from './parseFarsi';
|
|
7
8
|
import parseFrench from './parseFrench';
|
|
8
9
|
import parseGerman from './parseGerman';
|
|
9
10
|
import parsePolish from './parsePolish';
|
|
@@ -14,6 +15,7 @@ const parsePerLocale: Record<Locale, (html: string) => ParseResult> = {
|
|
|
14
15
|
[Locale.EN_GB]: parseEnglish,
|
|
15
16
|
[Locale.EN_US]: parseEnglish,
|
|
16
17
|
[Locale.ES_ES]: parseSpanish,
|
|
18
|
+
[Locale.FA_IR]: parseFarsi,
|
|
17
19
|
[Locale.FR_FR]: parseFrench,
|
|
18
20
|
[Locale.PL_PL]: parsePolish,
|
|
19
21
|
};
|
|
@@ -10,7 +10,8 @@ const parseEnglish = (html: string): ParseResult => {
|
|
|
10
10
|
const $ = load(html);
|
|
11
11
|
$('strong.mw_t_bc').replaceWith(', ');
|
|
12
12
|
$('.text-lowercase').remove();
|
|
13
|
-
$('
|
|
13
|
+
$('.sub-content-thread').remove();
|
|
14
|
+
|
|
14
15
|
const $definitions = $('[id^=dictionary-entry]').find('.dtText, .cxl-ref');
|
|
15
16
|
|
|
16
17
|
return {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { load } from 'cheerio';
|
|
2
|
+
|
|
3
|
+
import { ParseResult } from '../types';
|
|
4
|
+
|
|
5
|
+
const DOES_NOT_EXIST_MESSAGE = '404 Page Not Found';
|
|
6
|
+
|
|
7
|
+
const parseFarsi = (html: string): ParseResult => {
|
|
8
|
+
const $ = load(html);
|
|
9
|
+
const $definitions = $('[itemprop=articleBody]');
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
definitions: Array.from($definitions).map((definition) => $(definition).text()),
|
|
13
|
+
exists: $('#container h1').text() !== DOES_NOT_EXIST_MESSAGE,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default parseFarsi;
|