@scrabble-solver/word-definitions 2.14.0 → 2.15.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.js CHANGED
@@ -12,6 +12,7 @@ const crawlPerLocale = {
12
12
  [types_1.Locale.FR_FR]: languages_1.french.crawl,
13
13
  [types_1.Locale.PL_PL]: languages_1.polish.crawl,
14
14
  [types_1.Locale.RO_RO]: languages_1.romanian.crawl,
15
+ [types_1.Locale.TR_TR]: languages_1.turkish.crawl,
15
16
  };
16
17
  const crawl = (locale, word) => {
17
18
  return crawlPerLocale[locale](word);
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { getWordDefinition } from './getWordDefinition';
2
1
  export * from './crawl';
2
+ export * from './getWordDefinition';
3
3
  export * from './languages';
4
4
  export * from './lib';
5
5
  export * from './parse';
package/build/index.js CHANGED
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getWordDefinition = void 0;
18
- var getWordDefinition_1 = require("./getWordDefinition");
19
- Object.defineProperty(exports, "getWordDefinition", { enumerable: true, get: function () { return getWordDefinition_1.getWordDefinition; } });
20
17
  __exportStar(require("./crawl"), exports);
18
+ __exportStar(require("./getWordDefinition"), exports);
21
19
  __exportStar(require("./languages"), exports);
22
20
  __exportStar(require("./lib"), exports);
23
21
  __exportStar(require("./parse"), exports);
@@ -5,3 +5,4 @@ export * as persian from './persian';
5
5
  export * as polish from './polish';
6
6
  export * as romanian from './romanian';
7
7
  export * as spanish from './spanish';
8
+ export * as turkish from './turkish';
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.spanish = exports.romanian = exports.polish = exports.persian = exports.french = exports.german = exports.english = void 0;
26
+ exports.turkish = exports.spanish = exports.romanian = exports.polish = exports.persian = exports.french = exports.german = exports.english = void 0;
27
27
  exports.english = __importStar(require("./english"));
28
28
  exports.german = __importStar(require("./german"));
29
29
  exports.french = __importStar(require("./french"));
@@ -31,3 +31,4 @@ exports.persian = __importStar(require("./persian"));
31
31
  exports.polish = __importStar(require("./polish"));
32
32
  exports.romanian = __importStar(require("./romanian"));
33
33
  exports.spanish = __importStar(require("./spanish"));
34
+ exports.turkish = __importStar(require("./turkish"));
@@ -0,0 +1,3 @@
1
+ import { ParsingResult } from '../types';
2
+ export declare const crawl: (word: string) => Promise<string>;
3
+ export declare const parse: (json: string) => ParsingResult;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.crawl = void 0;
4
+ const lib_1 = require("../lib");
5
+ const crawl = (word) => {
6
+ return (0, lib_1.request)({
7
+ protocol: 'https',
8
+ hostname: 'sozluk.gov.tr',
9
+ path: `/gts?ara=${encodeURIComponent(word)}`,
10
+ headers: {
11
+ 'content-type': 'text/json',
12
+ },
13
+ });
14
+ };
15
+ exports.crawl = crawl;
16
+ const parse = (json) => {
17
+ const response = JSON.parse(json);
18
+ if (response.error) {
19
+ return {
20
+ definitions: [],
21
+ exists: false,
22
+ };
23
+ }
24
+ const [wordInfo] = response;
25
+ const definitions = wordInfo.anlamlarListe.map((entry) => entry.anlam.replace('►', '').trim());
26
+ return {
27
+ definitions,
28
+ exists: definitions.length > 0,
29
+ };
30
+ };
31
+ exports.parse = parse;
@@ -1,3 +1,3 @@
1
- export { normalizeDefinition } from './normalizeDefinition';
2
- export { request } from './request';
3
- export { unique } from './unique';
1
+ export * from './normalizeDefinition';
2
+ export * from './request';
3
+ export * from './unique';
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unique = exports.request = exports.normalizeDefinition = void 0;
4
- var normalizeDefinition_1 = require("./normalizeDefinition");
5
- Object.defineProperty(exports, "normalizeDefinition", { enumerable: true, get: function () { return normalizeDefinition_1.normalizeDefinition; } });
6
- var request_1 = require("./request");
7
- Object.defineProperty(exports, "request", { enumerable: true, get: function () { return request_1.request; } });
8
- var unique_1 = require("./unique");
9
- Object.defineProperty(exports, "unique", { enumerable: true, get: function () { return unique_1.unique; } });
17
+ __exportStar(require("./normalizeDefinition"), exports);
18
+ __exportStar(require("./request"), exports);
19
+ __exportStar(require("./unique"), exports);
package/build/parse.js CHANGED
@@ -13,6 +13,7 @@ const parsePerLocale = {
13
13
  [types_1.Locale.FR_FR]: languages_1.french.parse,
14
14
  [types_1.Locale.PL_PL]: languages_1.polish.parse,
15
15
  [types_1.Locale.RO_RO]: languages_1.romanian.parse,
16
+ [types_1.Locale.TR_TR]: languages_1.turkish.parse,
16
17
  };
17
18
  const parse = (locale, html) => {
18
19
  const { definitions, exists } = parsePerLocale[locale](html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/word-definitions",
3
- "version": "2.14.0",
3
+ "version": "2.15.1",
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/"
24
24
  },
25
25
  "dependencies": {
26
- "@scrabble-solver/types": "^2.14.0",
26
+ "@scrabble-solver/types": "^2.15.1",
27
27
  "cheerio": "^1.0.0-rc.12",
28
28
  "follow-redirects": "^1.15.6",
29
29
  "striptags": "^3.2.0"
@@ -31,5 +31,5 @@
31
31
  "devDependencies": {
32
32
  "@types/follow-redirects": "^1.14.4"
33
33
  },
34
- "gitHead": "013ecd9af1dcd04b1426358221c8131cdafd7331"
34
+ "gitHead": "87368a417385a1757e05d1a165bf0e644d94f425"
35
35
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "definitions": ["Mantıkla ilgili", "mantıklı", "mantık"],
3
+ "exists": true
4
+ }
@@ -0,0 +1 @@
1
+ [{"madde_id":"44658","kac":"0","kelime_no":"33889","cesit":"0","anlam_gor":"0","on_taki":null,"on_taki_html":null,"madde":"lojik","madde_html":"<strong>lojik<\/strong>","cesit_say":"0","anlam_say":"3","taki":"ği","cogul_mu":"0","ozel_mi":"0","egik_mi":"0","lisan_kodu":"13","lisan":"Fransızca logique","telaffuz_html":null,"lisan_html":null,"telaffuz":"l ince okunur","birlesikler":null,"font":null,"madde_duz":"lojik","gosterim_tarihi":null,"anlamlarListe":[{"anlam_id":"58622","madde_id":"44658","anlam_sira":"1","fiil":"0","tipkes":"0","anlam":"Mantıkla ilgili","anlam_html":null,"gos":"0","gos_kelime":"0","gos_kultur":"0","ozelliklerListe":[{"ozellik_id":"20","tur":"3","tam_adi":"sıfat","kisa_adi":"sf.","ekno":"31"}]},{"anlam_id":"58623","madde_id":"44658","anlam_sira":"2","fiil":"0","tipkes":"0","anlam":"► mantıklı","anlam_html":"<p>► mantıklı<\/p>\n","gos":"0","gos_kelime":"0","gos_kultur":"0","orneklerListe":[{"ornek_id":"54500","anlam_id":"58623","ornek_sira":"1","ornek":"Osman mekanik araçları, bu araçların işleyişini göz önüne alarak aslına uymayı gözden kaçırmayan lojik bir sorumlulukla tasvir etmiştir.","kac":"1","yazar_id":"2221","yazar_vd":"","yazar":[{"yazar_id":"2221","tam_adi":"Sezer Tansuğ","kisa_adi":"S. Tansuğ","ekno":"2454"}]}]},{"anlam_id":"58624","madde_id":"44658","anlam_sira":"3","fiil":"0","tipkes":"0","anlam":"► mantık","anlam_html":"<p>► mantık<\/p>\n","gos":"1","gos_kelime":"0","gos_kultur":"0","ozelliklerListe":[{"ozellik_id":"19","tur":"3","tam_adi":"isim","kisa_adi":"a.","ekno":"30"},{"ozellik_id":"57","tur":"1","tam_adi":"felsefe","kisa_adi":"fel.","ekno":"106"}]}]}]
package/src/crawl.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Locale } from '@scrabble-solver/types';
2
2
 
3
- import { english, french, german, persian, polish, romanian, spanish } from './languages';
3
+ import { english, french, german, persian, polish, romanian, spanish, turkish } from './languages';
4
4
 
5
5
  const crawlPerLocale: Record<Locale, (word: string) => Promise<string>> = {
6
6
  [Locale.DE_DE]: german.crawl,
@@ -11,6 +11,7 @@ const crawlPerLocale: Record<Locale, (word: string) => Promise<string>> = {
11
11
  [Locale.FR_FR]: french.crawl,
12
12
  [Locale.PL_PL]: polish.crawl,
13
13
  [Locale.RO_RO]: romanian.crawl,
14
+ [Locale.TR_TR]: turkish.crawl,
14
15
  };
15
16
 
16
17
  export const crawl = (locale: Locale, word: string): Promise<string> => {
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
- export { getWordDefinition } from './getWordDefinition';
2
-
3
1
  export * from './crawl';
2
+ export * from './getWordDefinition';
4
3
  export * from './languages';
5
4
  export * from './lib';
6
5
  export * from './parse';
@@ -5,3 +5,4 @@ export * as persian from './persian';
5
5
  export * as polish from './polish';
6
6
  export * as romanian from './romanian';
7
7
  export * as spanish from './spanish';
8
+ export * as turkish from './turkish';
@@ -0,0 +1,32 @@
1
+ import { request } from '../lib';
2
+ import { ParsingResult } from '../types';
3
+
4
+ export const crawl = (word: string): Promise<string> => {
5
+ return request({
6
+ protocol: 'https',
7
+ hostname: 'sozluk.gov.tr',
8
+ path: `/gts?ara=${encodeURIComponent(word)}`,
9
+ headers: {
10
+ 'content-type': 'text/json',
11
+ },
12
+ });
13
+ };
14
+
15
+ export const parse = (json: string): ParsingResult => {
16
+ const response = JSON.parse(json);
17
+
18
+ if (response.error) {
19
+ return {
20
+ definitions: [],
21
+ exists: false,
22
+ };
23
+ }
24
+
25
+ const [wordInfo] = response;
26
+ const definitions = wordInfo.anlamlarListe.map((entry: { anlam: string }) => entry.anlam.replace('►', '').trim());
27
+
28
+ return {
29
+ definitions,
30
+ exists: definitions.length > 0,
31
+ };
32
+ };
package/src/lib/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { normalizeDefinition } from './normalizeDefinition';
2
- export { request } from './request';
3
- export { unique } from './unique';
1
+ export * from './normalizeDefinition';
2
+ export * from './request';
3
+ export * from './unique';
package/src/parse.test.ts CHANGED
@@ -23,6 +23,7 @@ const tests = [
23
23
  { locale: Locale.ES_ES, word: 'corma' },
24
24
  { locale: Locale.ES_ES, word: 'portero' },
25
25
  { locale: Locale.RO_RO, word: 'aciua' },
26
+ { locale: Locale.TR_TR, word: 'lojik' },
26
27
  ];
27
28
 
28
29
  describe('parse', () => {
package/src/parse.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Locale } from '@scrabble-solver/types';
2
2
 
3
- import { english, french, german, persian, polish, romanian, spanish } from './languages';
3
+ import { english, french, german, persian, polish, romanian, spanish, turkish } from './languages';
4
4
  import { normalizeDefinition, unique } from './lib';
5
5
  import { ParsingResult } from './types';
6
6
 
@@ -13,6 +13,7 @@ const parsePerLocale: Record<Locale, (html: string) => ParsingResult> = {
13
13
  [Locale.FR_FR]: french.parse,
14
14
  [Locale.PL_PL]: polish.parse,
15
15
  [Locale.RO_RO]: romanian.parse,
16
+ [Locale.TR_TR]: turkish.parse,
16
17
  };
17
18
 
18
19
  export const parse = (locale: Locale, html: string): ParsingResult => {