@scrabble-solver/word-definitions 2.8.2 → 2.8.3
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 +15 -16
- package/build/crawl/crawlEnglish.js +3 -3
- package/build/crawl/crawlFrench.js +3 -3
- package/build/crawl/crawlGerman.js +3 -3
- package/build/crawl/crawlPolish.js +3 -3
- package/build/crawl/crawlSpanish.js +3 -3
- package/build/getWordDefinition.js +9 -52
- package/build/lib/normalizeDefinition.js +15 -15
- package/build/lib/request.js +8 -20
- package/build/lib/unique.js +1 -1
- package/build/parse/parse.js +18 -19
- package/build/parse/parseEnglish.js +5 -5
- package/build/parse/parseFrench.js +5 -5
- package/build/parse/parseGerman.js +6 -6
- package/build/parse/parsePolish.js +6 -6
- package/build/parse/parseSpanish.js +9 -9
- package/package.json +3 -3
package/build/crawl/crawl.js
CHANGED
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const types_1 = require("@scrabble-solver/types");
|
|
7
|
+
const crawlEnglish_1 = __importDefault(require("./crawlEnglish"));
|
|
8
|
+
const crawlFrench_1 = __importDefault(require("./crawlFrench"));
|
|
9
|
+
const crawlGerman_1 = __importDefault(require("./crawlGerman"));
|
|
10
|
+
const crawlPolish_1 = __importDefault(require("./crawlPolish"));
|
|
11
|
+
const crawlSpanish_1 = __importDefault(require("./crawlSpanish"));
|
|
12
|
+
const crawlPerLocale = {
|
|
13
|
+
[types_1.Locale.DE_DE]: crawlGerman_1.default,
|
|
14
|
+
[types_1.Locale.EN_GB]: crawlEnglish_1.default,
|
|
15
|
+
[types_1.Locale.EN_US]: crawlEnglish_1.default,
|
|
16
|
+
[types_1.Locale.ES_ES]: crawlSpanish_1.default,
|
|
17
|
+
[types_1.Locale.FR_FR]: crawlFrench_1.default,
|
|
18
|
+
[types_1.Locale.PL_PL]: crawlPolish_1.default,
|
|
19
|
+
};
|
|
20
|
+
const crawl = (locale, word) => {
|
|
22
21
|
return crawlPerLocale[locale](word);
|
|
23
22
|
};
|
|
24
23
|
exports.default = crawl;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlEnglish = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.merriam-webster.com',
|
|
8
|
-
path:
|
|
8
|
+
path: `/dictionary/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlEnglish;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlFrench = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.cnrtl.fr',
|
|
8
|
-
path:
|
|
8
|
+
path: `/definition/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlFrench;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlGerman = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.dwds.de',
|
|
8
|
-
path:
|
|
8
|
+
path: `?q=${encodeURIComponent(word)}&from=wb`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlGerman;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlPolish = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'sjp.pl',
|
|
8
|
-
path:
|
|
8
|
+
path: `/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlPolish;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlSpanish = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.diccionarios.com',
|
|
8
|
-
path:
|
|
8
|
+
path: `/diccionario/espanol/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlSpanish;
|
|
@@ -1,55 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
html = _b.sent();
|
|
49
|
-
_a = (0, parse_1.parse)(locale, html), definitions = _a.definitions, isAllowed = _a.isAllowed;
|
|
50
|
-
wordDefinition = new types_1.WordDefinition({ definitions: definitions, isAllowed: isAllowed, word: word });
|
|
51
|
-
return [2 /*return*/, wordDefinition];
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}); };
|
|
3
|
+
const types_1 = require("@scrabble-solver/types");
|
|
4
|
+
const crawl_1 = require("./crawl");
|
|
5
|
+
const parse_1 = require("./parse");
|
|
6
|
+
const getWordDefinition = async (locale, word) => {
|
|
7
|
+
const html = await (0, crawl_1.crawl)(locale, word);
|
|
8
|
+
const { definitions, isAllowed } = (0, parse_1.parse)(locale, html);
|
|
9
|
+
const wordDefinition = new types_1.WordDefinition({ definitions, isAllowed, word });
|
|
10
|
+
return wordDefinition;
|
|
11
|
+
};
|
|
55
12
|
exports.default = getWordDefinition;
|
|
@@ -3,25 +3,25 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const striptags_1 = __importDefault(require("striptags"));
|
|
7
|
+
const EMPHASIS_TAGS = ['a', 'b', 'em', 'internalXref'];
|
|
8
|
+
const normalizeHtmlTags = (definition) => (0, striptags_1.default)((0, striptags_1.default)(definition, EMPHASIS_TAGS), undefined, '"');
|
|
9
|
+
const normalizeLineBreaks = (definition) => definition.replace(/[\r\n]/g, '');
|
|
10
|
+
const normalizeQuotes = (definition) => definition.replace(/\."/g, '".');
|
|
11
11
|
/**
|
|
12
12
|
* `(1.2) definition` -> `definition`
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const normalizeMarkers = (definition) => definition.replace(/^\(\d+\.\d+\)\s+/g, '');
|
|
15
|
+
const normalizeTrailingSymbols = (definition) => definition.trim().replace(/:$/, '');
|
|
16
|
+
const normalizeLeadingSymbols = (definition) => definition.trim().replace(/^:/, '');
|
|
17
|
+
const normalizeNonWords = (definition) => (/\w/.test(definition) ? definition : '');
|
|
18
|
+
const normalizeCommas = (definition) => {
|
|
19
19
|
return definition
|
|
20
20
|
.replace(/\s+,\s+/g, ', ')
|
|
21
21
|
.replace(/^,/, '')
|
|
22
22
|
.replace(/,$/, '');
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
const normalizers = [
|
|
25
25
|
normalizeHtmlTags,
|
|
26
26
|
normalizeMarkers,
|
|
27
27
|
normalizeQuotes,
|
|
@@ -30,11 +30,11 @@ var normalizers = [
|
|
|
30
30
|
normalizeLeadingSymbols,
|
|
31
31
|
normalizeNonWords,
|
|
32
32
|
normalizeCommas,
|
|
33
|
-
|
|
33
|
+
(definition) => definition.trim(),
|
|
34
34
|
];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const normalizeDefinition = (definition) => {
|
|
36
|
+
const normalized = normalizers.reduce((result, normalize) => normalize(result), definition);
|
|
37
|
+
const hasChanged = normalized !== definition;
|
|
38
38
|
return hasChanged ? normalizeDefinition(normalized) : normalized;
|
|
39
39
|
};
|
|
40
40
|
exports.default = normalizeDefinition;
|
package/build/lib/request.js
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return new Promise(function (resolve, reject) {
|
|
3
|
+
const follow_redirects_1 = require("follow-redirects");
|
|
4
|
+
const request = ({ protocol, ...options }) => {
|
|
5
|
+
const agent = protocol === 'https' ? follow_redirects_1.https : follow_redirects_1.http;
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
19
7
|
return agent
|
|
20
|
-
.get(options,
|
|
21
|
-
|
|
8
|
+
.get(options, (response) => {
|
|
9
|
+
let data = '';
|
|
22
10
|
response.setEncoding('utf8');
|
|
23
|
-
response.on('data',
|
|
11
|
+
response.on('data', (chunk) => {
|
|
24
12
|
data += chunk;
|
|
25
13
|
});
|
|
26
|
-
response.on('end',
|
|
14
|
+
response.on('end', () => {
|
|
27
15
|
try {
|
|
28
16
|
resolve(data);
|
|
29
17
|
}
|
package/build/lib/unique.js
CHANGED
package/build/parse/parse.js
CHANGED
|
@@ -2,28 +2,27 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
const types_1 = require("@scrabble-solver/types");
|
|
7
|
+
const lib_1 = require("../lib");
|
|
8
|
+
const parseEnglish_1 = __importDefault(require("./parseEnglish"));
|
|
9
|
+
const parseFrench_1 = __importDefault(require("./parseFrench"));
|
|
10
|
+
const parseGerman_1 = __importDefault(require("./parseGerman"));
|
|
11
|
+
const parsePolish_1 = __importDefault(require("./parsePolish"));
|
|
12
|
+
const parseSpanish_1 = __importDefault(require("./parseSpanish"));
|
|
13
|
+
const parsePerLocale = {
|
|
14
|
+
[types_1.Locale.DE_DE]: parseGerman_1.default,
|
|
15
|
+
[types_1.Locale.EN_GB]: parseEnglish_1.default,
|
|
16
|
+
[types_1.Locale.EN_US]: parseEnglish_1.default,
|
|
17
|
+
[types_1.Locale.ES_ES]: parseSpanish_1.default,
|
|
18
|
+
[types_1.Locale.FR_FR]: parseFrench_1.default,
|
|
19
|
+
[types_1.Locale.PL_PL]: parsePolish_1.default,
|
|
20
|
+
};
|
|
21
|
+
const parse = (locale, html) => {
|
|
22
|
+
const { definitions, isAllowed } = parsePerLocale[locale](html);
|
|
24
23
|
return {
|
|
25
24
|
definitions: (0, lib_1.unique)(definitions.map(lib_1.normalizeDefinition).filter(Boolean)),
|
|
26
|
-
isAllowed
|
|
25
|
+
isAllowed,
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
28
|
exports.default = parse;
|
|
@@ -3,15 +3,15 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
const parseEnglish = (html) => {
|
|
8
|
+
const $ = cheerio_1.default.load(html);
|
|
9
9
|
$('strong.mw_t_bc').replaceWith(', ');
|
|
10
10
|
$('.text-lowercase').remove();
|
|
11
11
|
$('[id^=dictionary-entry]').find('.dtText > *:not(a)').remove();
|
|
12
|
-
|
|
12
|
+
const $definitions = $('[id^=dictionary-entry]').find('.dtText, .cxl-ref');
|
|
13
13
|
return {
|
|
14
|
-
definitions: Array.from($definitions).map(
|
|
14
|
+
definitions: Array.from($definitions).map((definition) => $(definition).text()),
|
|
15
15
|
isAllowed: $definitions.length > 0,
|
|
16
16
|
};
|
|
17
17
|
};
|
|
@@ -3,12 +3,12 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
const parseFrench = (html) => {
|
|
8
|
+
const $ = cheerio_1.default.load(html);
|
|
9
|
+
const $definitions = $('.tlf_cdefinition');
|
|
10
10
|
return {
|
|
11
|
-
definitions: Array.from($definitions).map(
|
|
11
|
+
definitions: Array.from($definitions).map((definition) => $(definition).text()),
|
|
12
12
|
isAllowed: $('#vitemselected span').length > 0,
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -3,11 +3,11 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
const parseGerman = (html) => {
|
|
8
|
+
const $ = cheerio_1.default.load(html);
|
|
9
|
+
const $meaningOverview = $('.bedeutungsuebersicht');
|
|
10
|
+
let $definitions;
|
|
11
11
|
if ($meaningOverview.length > 0) {
|
|
12
12
|
$definitions = $('.bedeutungsuebersicht > ol > li > a');
|
|
13
13
|
}
|
|
@@ -15,7 +15,7 @@ var parseGerman = function (html) {
|
|
|
15
15
|
$definitions = $('.dwdswb-lesart .dwdswb-definition');
|
|
16
16
|
}
|
|
17
17
|
return {
|
|
18
|
-
definitions: Array.from($definitions).map(
|
|
18
|
+
definitions: Array.from($definitions).map((definition) => $(definition).text().replace('/\n/', '')),
|
|
19
19
|
isAllowed: $definitions.length > 0,
|
|
20
20
|
};
|
|
21
21
|
};
|
|
@@ -3,12 +3,12 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
const parsePolish = (html) => {
|
|
8
|
+
const $ = cheerio_1.default.load(html);
|
|
9
|
+
const $header = $($('h1')[0]);
|
|
10
|
+
const $isAllowed = $header.next();
|
|
11
|
+
const $definitions = $header.next().next().next().next();
|
|
12
12
|
return {
|
|
13
13
|
definitions: $definitions.text().trim().split(/\d+\./),
|
|
14
14
|
isAllowed: $isAllowed.text().trim().indexOf('dopuszczalne w grach') >= 0,
|
|
@@ -3,9 +3,9 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const cheerio_1 = __importDefault(require("cheerio"));
|
|
7
|
+
const parseSpanish = (html) => {
|
|
8
|
+
const $ = cheerio_1.default.load(html);
|
|
9
9
|
$('.verdBold14 + .gris11 + .gris13').remove();
|
|
10
10
|
$('br + .gris13').remove();
|
|
11
11
|
$('.grisItalic13 + .gris13').remove();
|
|
@@ -13,19 +13,19 @@ var parseSpanish = function (html) {
|
|
|
13
13
|
$('font.gris11').remove();
|
|
14
14
|
$('font[class^="grisBold"]').remove();
|
|
15
15
|
$('font[class^="grisItalic"]').remove();
|
|
16
|
-
Array.from($('.gris13')).forEach(
|
|
17
|
-
|
|
16
|
+
Array.from($('.gris13')).forEach((element) => {
|
|
17
|
+
const children = $(element).find('.gris13');
|
|
18
18
|
if (children && children.length > 0) {
|
|
19
19
|
children.remove();
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
const definitions = Array.from($('.dcom-search-result .gris13'));
|
|
23
23
|
return {
|
|
24
24
|
definitions: definitions
|
|
25
|
-
.map(
|
|
25
|
+
.map((definition) => $(definition).text().trim())
|
|
26
26
|
.filter(Boolean)
|
|
27
|
-
.map(
|
|
28
|
-
.map(
|
|
27
|
+
.map((definition) => definition.replace(/\s+\.$/g, ''))
|
|
28
|
+
.map((definition) => (definition.endsWith('.') ? definition : `${definition}.`)),
|
|
29
29
|
isAllowed: definitions.length > 0,
|
|
30
30
|
};
|
|
31
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-definitions",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "Scrabble Solver 2 - Word definitions",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"clean": "rimraf build/ node_modules/ package-lock.json"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@scrabble-solver/types": "^2.8.
|
|
26
|
+
"@scrabble-solver/types": "^2.8.3",
|
|
27
27
|
"cheerio": "^1.0.0-rc.12",
|
|
28
28
|
"follow-redirects": "^1.15.2",
|
|
29
29
|
"striptags": "^3.2.0"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/follow-redirects": "^1.14.1"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "116f214733e7ad071044f556bcf67e867da3d9ca"
|
|
35
35
|
}
|