@scrabble-solver/word-definitions 2.6.1 → 2.7.2
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/crawlGerman.d.ts +2 -0
- package/build/crawl/crawlGerman.js +11 -0
- package/build/crawl/index.d.ts +1 -0
- package/build/crawl/index.js +3 -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/parseGerman.d.ts +3 -0
- package/build/parse/parseGerman.js +22 -0
- package/package.json +4 -4
- package/src/crawl/crawl.ts +2 -0
- package/src/crawl/crawlGerman.ts +11 -0
- package/src/crawl/index.ts +1 -0
- package/src/parse/index.ts +1 -0
- package/src/parse/parse.ts +2 -0
- package/src/parse/parseGerman.ts +21 -0
package/build/crawl/crawl.js
CHANGED
|
@@ -7,9 +7,11 @@ 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"));
|
|
11
12
|
var crawlSpanish_1 = __importDefault(require("./crawlSpanish"));
|
|
12
13
|
var crawlPerLocale = (_a = {},
|
|
14
|
+
_a[types_1.Locale.DE_DE] = crawlGerman_1.default,
|
|
13
15
|
_a[types_1.Locale.EN_GB] = crawlEnglish_1.default,
|
|
14
16
|
_a[types_1.Locale.EN_US] = crawlEnglish_1.default,
|
|
15
17
|
_a[types_1.Locale.ES_ES] = crawlSpanish_1.default,
|
|
@@ -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;
|
package/build/crawl/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { default as crawlEnglish } from './crawlEnglish';
|
|
|
3
3
|
export { default as crawlFrench } from './crawlFrench';
|
|
4
4
|
export { default as crawlPolish } from './crawlPolish';
|
|
5
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.crawlSpanish = 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");
|
|
@@ -14,3 +14,5 @@ var crawlPolish_1 = require("./crawlPolish");
|
|
|
14
14
|
Object.defineProperty(exports, "crawlPolish", { enumerable: true, get: function () { return __importDefault(crawlPolish_1).default; } });
|
|
15
15
|
var crawlSpanish_1 = require("./crawlSpanish");
|
|
16
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,5 +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';
|
|
5
6
|
export { default as parseSpanish } from './parseSpanish';
|
package/build/parse/index.js
CHANGED
|
@@ -3,13 +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
|
-
exports.parseSpanish = 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; } });
|
|
15
17
|
var parseSpanish_1 = require("./parseSpanish");
|
package/build/parse/parse.js
CHANGED
|
@@ -8,9 +8,11 @@ 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"));
|
|
12
13
|
var parseSpanish_1 = __importDefault(require("./parseSpanish"));
|
|
13
14
|
var parsePerLocale = (_a = {},
|
|
15
|
+
_a[types_1.Locale.DE_DE] = parseGerman_1.default,
|
|
14
16
|
_a[types_1.Locale.EN_GB] = parseEnglish_1.default,
|
|
15
17
|
_a[types_1.Locale.EN_US] = parseEnglish_1.default,
|
|
16
18
|
_a[types_1.Locale.ES_ES] = parseSpanish_1.default,
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-definitions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.2",
|
|
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.2",
|
|
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": "f1a2823c32eedaeff30cf8315e20427574fc97b7"
|
|
35
35
|
}
|
package/src/crawl/crawl.ts
CHANGED
|
@@ -2,10 +2,12 @@ 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';
|
|
6
7
|
import crawlSpanish from './crawlSpanish';
|
|
7
8
|
|
|
8
9
|
const crawlPerLocale: Record<Locale, (word: string) => Promise<string>> = {
|
|
10
|
+
[Locale.DE_DE]: crawlGerman,
|
|
9
11
|
[Locale.EN_GB]: crawlEnglish,
|
|
10
12
|
[Locale.EN_US]: crawlEnglish,
|
|
11
13
|
[Locale.ES_ES]: crawlSpanish,
|
package/src/crawl/index.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { default as crawlEnglish } from './crawlEnglish';
|
|
|
3
3
|
export { default as crawlFrench } from './crawlFrench';
|
|
4
4
|
export { default as crawlPolish } from './crawlPolish';
|
|
5
5
|
export { default as crawlSpanish } from './crawlSpanish';
|
|
6
|
+
export { default as crawlGerman } from './crawlGerman';
|
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
3
|
export { default as parseFrench } from './parseFrench';
|
|
4
|
+
export { default as parseGerman } from './parseGerman';
|
|
4
5
|
export { default as parsePolish } from './parsePolish';
|
|
5
6
|
export { default as parseSpanish } from './parseSpanish';
|
package/src/parse/parse.ts
CHANGED
|
@@ -5,10 +5,12 @@ import { ParseResult } from '../types';
|
|
|
5
5
|
|
|
6
6
|
import parseEnglish from './parseEnglish';
|
|
7
7
|
import parseFrench from './parseFrench';
|
|
8
|
+
import parseGerman from './parseGerman';
|
|
8
9
|
import parsePolish from './parsePolish';
|
|
9
10
|
import parseSpanish from './parseSpanish';
|
|
10
11
|
|
|
11
12
|
const parsePerLocale: Record<Locale, (html: string) => ParseResult> = {
|
|
13
|
+
[Locale.DE_DE]: parseGerman,
|
|
12
14
|
[Locale.EN_GB]: parseEnglish,
|
|
13
15
|
[Locale.EN_US]: parseEnglish,
|
|
14
16
|
[Locale.ES_ES]: parseSpanish,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import cheerio from 'cheerio';
|
|
2
|
+
|
|
3
|
+
import { ParseResult } from '../types';
|
|
4
|
+
|
|
5
|
+
const parseGerman = (html: string): ParseResult => {
|
|
6
|
+
const $ = cheerio.load(html);
|
|
7
|
+
const $meaningOverview = $('.bedeutungsuebersicht');
|
|
8
|
+
let $definitions;
|
|
9
|
+
if ($meaningOverview.length > 0) {
|
|
10
|
+
$definitions = $('.bedeutungsuebersicht > ol > li > a');
|
|
11
|
+
} else {
|
|
12
|
+
$definitions = $('.dwdswb-lesart .dwdswb-definition');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
definitions: Array.from($definitions).map((definition) => $(definition).text().replace('/\n/', '')),
|
|
17
|
+
isAllowed: $definitions.length > 0,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default parseGerman;
|