@scrabble-solver/word-definitions 2.5.0 → 2.7.0
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 +4 -0
- package/build/crawl/crawlGerman.d.ts +2 -0
- package/build/crawl/crawlGerman.js +11 -0
- package/build/crawl/crawlSpanish.d.ts +2 -0
- package/build/crawl/crawlSpanish.js +11 -0
- package/build/crawl/index.d.ts +2 -0
- package/build/crawl/index.js +5 -1
- package/build/parse/index.d.ts +2 -0
- package/build/parse/index.js +5 -1
- package/build/parse/parse.js +4 -0
- package/build/parse/parseGerman.d.ts +3 -0
- package/build/parse/parseGerman.js +22 -0
- package/build/parse/parseSpanish.d.ts +3 -0
- package/build/parse/parseSpanish.js +32 -0
- package/package.json +4 -4
- package/src/crawl/crawl.ts +4 -0
- package/src/crawl/crawlGerman.ts +11 -0
- package/src/crawl/crawlSpanish.ts +11 -0
- package/src/crawl/index.ts +2 -0
- package/src/parse/__tests__/expected/es-ES.corma.json +7 -0
- package/src/parse/__tests__/expected/es-ES.portero.json +9 -0
- package/src/parse/__tests__/input/es-ES.corma.html +762 -0
- package/src/parse/__tests__/input/es-ES.portero.html +764 -0
- package/src/parse/index.ts +2 -0
- package/src/parse/parse.test.ts +2 -0
- package/src/parse/parse.ts +4 -0
- package/src/parse/parseGerman.ts +21 -0
- package/src/parse/parseSpanish.ts +35 -0
package/build/crawl/crawl.js
CHANGED
|
@@ -7,10 +7,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
var types_1 = require("@scrabble-solver/types");
|
|
8
8
|
var crawlEnglish_1 = __importDefault(require("./crawlEnglish"));
|
|
9
9
|
var crawlFrench_1 = __importDefault(require("./crawlFrench"));
|
|
10
|
+
var crawlGerman_1 = __importDefault(require("./crawlGerman"));
|
|
10
11
|
var crawlPolish_1 = __importDefault(require("./crawlPolish"));
|
|
12
|
+
var crawlSpanish_1 = __importDefault(require("./crawlSpanish"));
|
|
11
13
|
var crawlPerLocale = (_a = {},
|
|
14
|
+
_a[types_1.Locale.DE_DE] = crawlGerman_1.default,
|
|
12
15
|
_a[types_1.Locale.EN_GB] = crawlEnglish_1.default,
|
|
13
16
|
_a[types_1.Locale.EN_US] = crawlEnglish_1.default,
|
|
17
|
+
_a[types_1.Locale.ES_ES] = crawlSpanish_1.default,
|
|
14
18
|
_a[types_1.Locale.FR_FR] = crawlFrench_1.default,
|
|
15
19
|
_a[types_1.Locale.PL_PL] = crawlPolish_1.default,
|
|
16
20
|
_a);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var lib_1 = require("../lib");
|
|
4
|
+
var crawlGerman = function (word) {
|
|
5
|
+
return lib_1.request({
|
|
6
|
+
protocol: 'https',
|
|
7
|
+
hostname: 'www.dwds.de',
|
|
8
|
+
path: "?q=" + encodeURIComponent(word) + "&from=wb",
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
exports.default = crawlGerman;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var lib_1 = require("../lib");
|
|
4
|
+
var crawlSpanish = function (word) {
|
|
5
|
+
return lib_1.request({
|
|
6
|
+
protocol: 'https',
|
|
7
|
+
hostname: 'www.diccionarios.com',
|
|
8
|
+
path: "/diccionario/espanol/" + encodeURIComponent(word),
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
exports.default = crawlSpanish;
|
package/build/crawl/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { default as crawl } from './crawl';
|
|
|
2
2
|
export { default as crawlEnglish } from './crawlEnglish';
|
|
3
3
|
export { default as crawlFrench } from './crawlFrench';
|
|
4
4
|
export { default as crawlPolish } from './crawlPolish';
|
|
5
|
+
export { default as crawlSpanish } from './crawlSpanish';
|
|
6
|
+
export { default as crawlGerman } from './crawlGerman';
|
package/build/crawl/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.crawlPolish = exports.crawlFrench = exports.crawlEnglish = exports.crawl = void 0;
|
|
6
|
+
exports.crawlGerman = exports.crawlSpanish = exports.crawlPolish = exports.crawlFrench = exports.crawlEnglish = exports.crawl = void 0;
|
|
7
7
|
var crawl_1 = require("./crawl");
|
|
8
8
|
Object.defineProperty(exports, "crawl", { enumerable: true, get: function () { return __importDefault(crawl_1).default; } });
|
|
9
9
|
var crawlEnglish_1 = require("./crawlEnglish");
|
|
@@ -12,3 +12,7 @@ var crawlFrench_1 = require("./crawlFrench");
|
|
|
12
12
|
Object.defineProperty(exports, "crawlFrench", { enumerable: true, get: function () { return __importDefault(crawlFrench_1).default; } });
|
|
13
13
|
var crawlPolish_1 = require("./crawlPolish");
|
|
14
14
|
Object.defineProperty(exports, "crawlPolish", { enumerable: true, get: function () { return __importDefault(crawlPolish_1).default; } });
|
|
15
|
+
var crawlSpanish_1 = require("./crawlSpanish");
|
|
16
|
+
Object.defineProperty(exports, "crawlSpanish", { enumerable: true, get: function () { return __importDefault(crawlSpanish_1).default; } });
|
|
17
|
+
var crawlGerman_1 = require("./crawlGerman");
|
|
18
|
+
Object.defineProperty(exports, "crawlGerman", { enumerable: true, get: function () { return __importDefault(crawlGerman_1).default; } });
|
package/build/parse/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as parse } from './parse';
|
|
2
2
|
export { default as parseEnglish } from './parseEnglish';
|
|
3
3
|
export { default as parseFrench } from './parseFrench';
|
|
4
|
+
export { default as parseGerman } from './parseGerman';
|
|
4
5
|
export { default as parsePolish } from './parsePolish';
|
|
6
|
+
export { default as parseSpanish } from './parseSpanish';
|
package/build/parse/index.js
CHANGED
|
@@ -3,12 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parsePolish = exports.parseFrench = exports.parseEnglish = exports.parse = void 0;
|
|
6
|
+
exports.parseSpanish = exports.parsePolish = exports.parseGerman = exports.parseFrench = exports.parseEnglish = exports.parse = void 0;
|
|
7
7
|
var parse_1 = require("./parse");
|
|
8
8
|
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return __importDefault(parse_1).default; } });
|
|
9
9
|
var parseEnglish_1 = require("./parseEnglish");
|
|
10
10
|
Object.defineProperty(exports, "parseEnglish", { enumerable: true, get: function () { return __importDefault(parseEnglish_1).default; } });
|
|
11
11
|
var parseFrench_1 = require("./parseFrench");
|
|
12
12
|
Object.defineProperty(exports, "parseFrench", { enumerable: true, get: function () { return __importDefault(parseFrench_1).default; } });
|
|
13
|
+
var parseGerman_1 = require("./parseGerman");
|
|
14
|
+
Object.defineProperty(exports, "parseGerman", { enumerable: true, get: function () { return __importDefault(parseGerman_1).default; } });
|
|
13
15
|
var parsePolish_1 = require("./parsePolish");
|
|
14
16
|
Object.defineProperty(exports, "parsePolish", { enumerable: true, get: function () { return __importDefault(parsePolish_1).default; } });
|
|
17
|
+
var parseSpanish_1 = require("./parseSpanish");
|
|
18
|
+
Object.defineProperty(exports, "parseSpanish", { enumerable: true, get: function () { return __importDefault(parseSpanish_1).default; } });
|
package/build/parse/parse.js
CHANGED
|
@@ -8,10 +8,14 @@ var types_1 = require("@scrabble-solver/types");
|
|
|
8
8
|
var lib_1 = require("../lib");
|
|
9
9
|
var parseEnglish_1 = __importDefault(require("./parseEnglish"));
|
|
10
10
|
var parseFrench_1 = __importDefault(require("./parseFrench"));
|
|
11
|
+
var parseGerman_1 = __importDefault(require("./parseGerman"));
|
|
11
12
|
var parsePolish_1 = __importDefault(require("./parsePolish"));
|
|
13
|
+
var parseSpanish_1 = __importDefault(require("./parseSpanish"));
|
|
12
14
|
var parsePerLocale = (_a = {},
|
|
15
|
+
_a[types_1.Locale.DE_DE] = parseGerman_1.default,
|
|
13
16
|
_a[types_1.Locale.EN_GB] = parseEnglish_1.default,
|
|
14
17
|
_a[types_1.Locale.EN_US] = parseEnglish_1.default,
|
|
18
|
+
_a[types_1.Locale.ES_ES] = parseSpanish_1.default,
|
|
15
19
|
_a[types_1.Locale.FR_FR] = parseFrench_1.default,
|
|
16
20
|
_a[types_1.Locale.PL_PL] = parsePolish_1.default,
|
|
17
21
|
_a);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
var parseGerman = function (html) {
|
|
8
|
+
var $ = cheerio_1.default.load(html);
|
|
9
|
+
var $meaningOverview = $('.bedeutungsuebersicht');
|
|
10
|
+
var $definitions;
|
|
11
|
+
if ($meaningOverview.length > 0) {
|
|
12
|
+
$definitions = $('.bedeutungsuebersicht > ol > li > a');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
$definitions = $('.dwdswb-lesart .dwdswb-definition');
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
definitions: Array.from($definitions).map(function (definition) { return $(definition).text().replace('/\n/', ''); }),
|
|
19
|
+
isAllowed: $definitions.length > 0,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.default = parseGerman;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
var parseSpanish = function (html) {
|
|
8
|
+
var $ = cheerio_1.default.load(html);
|
|
9
|
+
$('.verdBold14 + .gris11 + .gris13').remove();
|
|
10
|
+
$('br + .gris13').remove();
|
|
11
|
+
$('.grisItalic13 + .gris13').remove();
|
|
12
|
+
$('font[class^="verd"]').remove();
|
|
13
|
+
$('font.gris11').remove();
|
|
14
|
+
$('font[class^="grisBold"]').remove();
|
|
15
|
+
$('font[class^="grisItalic"]').remove();
|
|
16
|
+
Array.from($('.gris13')).forEach(function (element) {
|
|
17
|
+
var children = $(element).find('.gris13');
|
|
18
|
+
if (children && children.length > 0) {
|
|
19
|
+
children.remove();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var definitions = Array.from($('.dcom-search-result .gris13'));
|
|
23
|
+
return {
|
|
24
|
+
definitions: definitions
|
|
25
|
+
.map(function (definition) { return $(definition).text().trim(); })
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.map(function (definition) { return definition.replace(/\s+\.$/g, ''); })
|
|
28
|
+
.map(function (definition) { return (definition.endsWith('.') ? definition : definition + "."); }),
|
|
29
|
+
isAllowed: definitions.length > 0,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.default = parseSpanish;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-definitions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Scrabble Solver 2 - Word definitions",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "Kamil Mielnik",
|
|
13
13
|
"email": "kamil.adam.mielnik@gmail.com",
|
|
14
|
-
"url": "
|
|
14
|
+
"url": "https://kamilmielnik.com/"
|
|
15
15
|
},
|
|
16
16
|
"license": "CC-BY-NC-ND-4.0",
|
|
17
17
|
"bugs": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"clean": "rimraf build/ node_modules/ package-lock.json"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@scrabble-solver/types": "^2.
|
|
26
|
+
"@scrabble-solver/types": "^2.7.0",
|
|
27
27
|
"cheerio": "^1.0.0-rc.5",
|
|
28
28
|
"follow-redirects": "^1.13.2",
|
|
29
29
|
"striptags": "^3.1.1"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/follow-redirects": "^1.13.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "db0e2eab74ee597f70df456444312241f2646f9e"
|
|
35
35
|
}
|
package/src/crawl/crawl.ts
CHANGED
|
@@ -2,11 +2,15 @@ import { Locale } from '@scrabble-solver/types';
|
|
|
2
2
|
|
|
3
3
|
import crawlEnglish from './crawlEnglish';
|
|
4
4
|
import crawlFrench from './crawlFrench';
|
|
5
|
+
import crawlGerman from './crawlGerman';
|
|
5
6
|
import crawlPolish from './crawlPolish';
|
|
7
|
+
import crawlSpanish from './crawlSpanish';
|
|
6
8
|
|
|
7
9
|
const crawlPerLocale: Record<Locale, (word: string) => Promise<string>> = {
|
|
10
|
+
[Locale.DE_DE]: crawlGerman,
|
|
8
11
|
[Locale.EN_GB]: crawlEnglish,
|
|
9
12
|
[Locale.EN_US]: crawlEnglish,
|
|
13
|
+
[Locale.ES_ES]: crawlSpanish,
|
|
10
14
|
[Locale.FR_FR]: crawlFrench,
|
|
11
15
|
[Locale.PL_PL]: crawlPolish,
|
|
12
16
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { request } from '../lib';
|
|
2
|
+
|
|
3
|
+
const crawlSpanish = (word: string): Promise<string> => {
|
|
4
|
+
return request({
|
|
5
|
+
protocol: 'https',
|
|
6
|
+
hostname: 'www.diccionarios.com',
|
|
7
|
+
path: `/diccionario/espanol/${encodeURIComponent(word)}`,
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default crawlSpanish;
|
package/src/crawl/index.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { default as crawl } from './crawl';
|
|
|
2
2
|
export { default as crawlEnglish } from './crawlEnglish';
|
|
3
3
|
export { default as crawlFrench } from './crawlFrench';
|
|
4
4
|
export { default as crawlPolish } from './crawlPolish';
|
|
5
|
+
export { default as crawlSpanish } from './crawlSpanish';
|
|
6
|
+
export { default as crawlGerman } from './crawlGerman';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"definitions": [
|
|
3
|
+
"Se aplica al ladrillo que no está bastante cocido.",
|
|
4
|
+
"Persona que guarda la portería en las casas de vecinos.",
|
|
5
|
+
"Funcionario subalterno que se encarga de la vigilancia, limpieza o servicios auxiliares en oficinas públicas.",
|
|
6
|
+
"Jugador que en algunos deportes defiende la portería."
|
|
7
|
+
],
|
|
8
|
+
"isAllowed": true
|
|
9
|
+
}
|