@digigov/text-search 1.2.0-rc.33 → 2.0.0-0b806366

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.
Files changed (52) hide show
  1. package/hook.d.ts +1 -1
  2. package/hook.js +34 -0
  3. package/index.d.ts +2 -2
  4. package/index.js +5 -8
  5. package/package.json +4 -4
  6. package/search/index.d.ts +1 -1
  7. package/search/index.js +3 -6
  8. package/search/lang/gr/encoder.js +8 -0
  9. package/search/lang/gr/normalization-map.js +101 -0
  10. package/search/search-index.d.ts +1 -1
  11. package/search/search-index.js +46 -0
  12. package/search/utils.js +26 -0
  13. package/types.js +0 -0
  14. package/cjs/hook/index.js +0 -58
  15. package/cjs/hook.js.map +0 -7
  16. package/cjs/index.js +0 -42
  17. package/cjs/index.js.map +0 -7
  18. package/cjs/search/index.js +0 -26
  19. package/cjs/search/index.js.map +0 -7
  20. package/cjs/search/lang/gr/encoder/index.js +0 -41
  21. package/cjs/search/lang/gr/encoder.js.map +0 -7
  22. package/cjs/search/lang/gr/normalization-map/index.js +0 -128
  23. package/cjs/search/lang/gr/normalization-map.js.map +0 -7
  24. package/cjs/search/search-index/index.js +0 -106
  25. package/cjs/search/search-index.js.map +0 -7
  26. package/cjs/search/utils/index.js +0 -68
  27. package/cjs/search/utils.js.map +0 -7
  28. package/cjs/types/index.js +0 -17
  29. package/cjs/types.js.map +0 -7
  30. package/hook/index.js +0 -28
  31. package/hook/package.json +0 -6
  32. package/hook.js.map +0 -7
  33. package/hook.spec.d.ts +0 -1
  34. package/index.js.map +0 -7
  35. package/search/__tests__/utils.spec.d.ts +0 -1
  36. package/search/index.js.map +0 -7
  37. package/search/lang/gr/encoder/index.js +0 -17
  38. package/search/lang/gr/encoder/package.json +0 -6
  39. package/search/lang/gr/encoder.js.map +0 -7
  40. package/search/lang/gr/normalization-map/index.js +0 -104
  41. package/search/lang/gr/normalization-map/package.json +0 -6
  42. package/search/lang/gr/normalization-map.js.map +0 -7
  43. package/search/package.json +0 -6
  44. package/search/search-index/index.js +0 -86
  45. package/search/search-index/package.json +0 -6
  46. package/search/search-index.js.map +0 -7
  47. package/search/utils/index.js +0 -42
  48. package/search/utils/package.json +0 -6
  49. package/search/utils.js.map +0 -7
  50. package/types/index.js +0 -1
  51. package/types/package.json +0 -6
  52. package/types.js.map +0 -7
package/hook.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UseSearchOptions } from '@digigov/text-search/types';
1
+ import { UseSearchOptions } from './types.js';
2
2
  /**
3
3
  * Hook for searching through a list of documents
4
4
  *
package/hook.js ADDED
@@ -0,0 +1,34 @@
1
+ import { useCallback, useMemo, useState } from "react";
2
+ import search_0 from "./search/index.js";
3
+ function useSearch(documents, query, options) {
4
+ const [loading, setLoading] = useState(false);
5
+ const [data, setData] = useState(documents);
6
+ const indexing = options?.indexing;
7
+ const index = useMemo(()=>new search_0(documents, indexing), [
8
+ documents,
9
+ indexing
10
+ ]);
11
+ const search = useCallback(()=>{
12
+ if (query) {
13
+ setLoading(true);
14
+ index.searchAsync(documents, query).then((data)=>setData(data)).catch(()=>setData([])).finally(()=>setLoading(false));
15
+ } else setData(documents);
16
+ }, [
17
+ query,
18
+ index,
19
+ documents
20
+ ]);
21
+ const reset = useCallback(()=>{
22
+ setData(documents);
23
+ setLoading(false);
24
+ }, [
25
+ documents
26
+ ]);
27
+ return {
28
+ data,
29
+ loading,
30
+ search,
31
+ reset
32
+ };
33
+ }
34
+ export { useSearch as default };
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import useSearch from '@digigov/text-search/hook';
1
+ import useSearch from './hook.js';
2
2
  export default useSearch;
3
- export * from '@digigov/text-search/search';
3
+ export * from './search/index.js';
package/index.js CHANGED
@@ -1,12 +1,9 @@
1
- /** @license Digigov v1.2.0-rc.33
1
+ /** @license Digigov v2.0.0-0b806366
2
2
  *
3
3
  * This source code is licensed under the BSD-2-Clause license found in the
4
4
  * LICENSE file in the root directory of this source tree.
5
5
  */
6
- import useSearch from "@digigov/text-search/hook";
7
- var src_default = useSearch;
8
- export * from "@digigov/text-search/search";
9
- export {
10
- src_default as default
11
- };
12
- //# sourceMappingURL=index.js.map
6
+ import hook from "./hook.js";
7
+ export * from "./search/index.js";
8
+ const src = hook;
9
+ export { src as default };
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@digigov/text-search",
3
- "version": "1.2.0-rc.33",
3
+ "version": "2.0.0-0b806366",
4
4
  "description": "@digigov text-search",
5
5
  "author": "GRNET Developers <devs@lists.grnet.gr>",
6
6
  "license": "BSD-2-Clause",
7
- "main": "./cjs/index.js",
8
- "module": "./index.js",
7
+ "type": "module",
9
8
  "private": false,
10
9
  "publishConfig": {
11
10
  "access": "public"
@@ -17,5 +16,6 @@
17
16
  "react": "^18.3.0 || ^19.1.0",
18
17
  "react-dom": "^18.3.0 || ^19.1.0"
19
18
  },
20
- "typings": "./index.d.ts"
19
+ "main": "index.js",
20
+ "module": "index.js"
21
21
  }
package/search/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { SearchIndex } from '@digigov/text-search/search/search-index';
1
+ import { SearchIndex } from './search-index.js';
2
2
  export default SearchIndex;
package/search/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import { SearchIndex } from "@digigov/text-search/search/search-index";
2
- var search_default = SearchIndex;
3
- export {
4
- search_default as default
5
- };
6
- //# sourceMappingURL=index.js.map
1
+ import { SearchIndex } from "./search-index.js";
2
+ const search = SearchIndex;
3
+ export { search as default };
@@ -0,0 +1,8 @@
1
+ import { greekToGreeklishMap } from "./normalization-map.js";
2
+ const whitespaceRegex = new RegExp('[p{Z}p{S}p{P}p{C}]+', 'u');
3
+ const diacriticsRegex = new RegExp('[\u0300-\u036f]', 'g');
4
+ const greekCharsRegex = new RegExp(Object.keys(greekToGreeklishMap).join('|'), 'igu');
5
+ function encodeGreek(str) {
6
+ return ('' + str).toLowerCase().normalize('NFD').replace(diacriticsRegex, '').replace(greekCharsRegex, (match)=>match in greekToGreeklishMap ? greekToGreeklishMap[match] : match).split(whitespaceRegex);
7
+ }
8
+ export { encodeGreek };
@@ -0,0 +1,101 @@
1
+ const greekToGreeklishMap = {
2
+ ΓΧ: 'GX',
3
+ γχ: 'gx',
4
+ ΤΘ: 'T8',
5
+ τθ: 't8',
6
+ θη: '8h',
7
+ Θη: '8h',
8
+ ΘΗ: '8H',
9
+ αυ: 'au',
10
+ Αυ: 'Au',
11
+ ΑΥ: 'AY',
12
+ ευ: 'eu',
13
+ εύ: 'eu',
14
+ εϋ: 'ey',
15
+ εΰ: 'ey',
16
+ Ευ: 'Eu',
17
+ Εύ: 'Eu',
18
+ Εϋ: 'Ey',
19
+ Εΰ: 'Ey',
20
+ ΕΥ: 'EY',
21
+ ου: 'ou',
22
+ ού: 'ou',
23
+ οϋ: 'oy',
24
+ οΰ: 'oy',
25
+ Ου: 'Ou',
26
+ Ού: 'Ou',
27
+ Οϋ: 'Oy',
28
+ Οΰ: 'Oy',
29
+ ΟΥ: 'OY',
30
+ Α: 'A',
31
+ α: 'a',
32
+ ά: 'a',
33
+ Ά: 'A',
34
+ Β: 'B',
35
+ β: 'b',
36
+ Γ: 'G',
37
+ γ: 'g',
38
+ Δ: 'D',
39
+ δ: 'd',
40
+ Ε: 'E',
41
+ ε: 'e',
42
+ έ: 'e',
43
+ Έ: 'E',
44
+ Ζ: 'Z',
45
+ ζ: 'z',
46
+ Η: 'H',
47
+ η: 'h',
48
+ ή: 'h',
49
+ Ή: 'H',
50
+ Θ: 'TH',
51
+ θ: 'th',
52
+ Ι: 'I',
53
+ Ϊ: 'I',
54
+ ι: 'i',
55
+ ί: 'i',
56
+ ΐ: 'i',
57
+ ϊ: 'i',
58
+ Ί: 'I',
59
+ Κ: 'K',
60
+ κ: 'k',
61
+ Λ: 'L',
62
+ λ: 'l',
63
+ Μ: 'M',
64
+ μ: 'm',
65
+ Ν: 'N',
66
+ ν: 'n',
67
+ Ξ: 'KS',
68
+ ξ: 'ks',
69
+ Ο: 'O',
70
+ ο: 'o',
71
+ Ό: 'O',
72
+ ό: 'o',
73
+ Π: 'P',
74
+ π: 'p',
75
+ Ρ: 'R',
76
+ ρ: 'r',
77
+ Σ: 'S',
78
+ σ: 's',
79
+ Τ: 'T',
80
+ τ: 't',
81
+ Υ: 'Y',
82
+ Ύ: 'Y',
83
+ Ϋ: 'Y',
84
+ ΰ: 'y',
85
+ ύ: 'y',
86
+ ϋ: 'y',
87
+ υ: 'y',
88
+ Φ: 'F',
89
+ φ: 'f',
90
+ Χ: 'X',
91
+ χ: 'x',
92
+ Ψ: 'Ps',
93
+ ψ: 'ps',
94
+ Ω: 'w',
95
+ ω: 'w',
96
+ Ώ: 'w',
97
+ ώ: 'w',
98
+ ς: 's',
99
+ ';': '?'
100
+ };
101
+ export { greekToGreeklishMap };
@@ -1,4 +1,4 @@
1
- import type { SearchIndexOptions } from '@digigov/text-search/types';
1
+ import type { SearchIndexOptions } from '../types.js';
2
2
  /**
3
3
  * Wrapper class around third party index and search library
4
4
  *
@@ -0,0 +1,46 @@
1
+ import { Document } from "flexsearch";
2
+ import { encodeGreek } from "./lang/gr/encoder.js";
3
+ import { findItemsByIds, getAllItemKeys, getResultIds } from "./utils.js";
4
+ class SearchIndex {
5
+ index;
6
+ idKey;
7
+ constructor(items, options){
8
+ this.idKey = 'id';
9
+ if (options && options.idKey) this.idKey = options.idKey.replace('.', ':');
10
+ else if (!(items[0] && 'id' in items[0])) items = items.map((item, index)=>({
11
+ ...item,
12
+ id: index
13
+ }));
14
+ let fields = [];
15
+ if (options && options.fields) fields = options.fields;
16
+ else if (items[0]) fields = getAllItemKeys(items[0]);
17
+ fields = fields.filter((field)=>field !== this.idKey).map((field)=>field.replace('.', ':'));
18
+ this.index = new Document({
19
+ document: {
20
+ id: this.idKey,
21
+ index: fields
22
+ },
23
+ tokenize: 'forward',
24
+ worker: options?.enableWorker,
25
+ encode: encodeGreek
26
+ });
27
+ this.addAll(items);
28
+ }
29
+ add(item) {
30
+ this.index.add(item);
31
+ return this;
32
+ }
33
+ addAll(items) {
34
+ items.forEach((item)=>this.index.add(item));
35
+ return this;
36
+ }
37
+ search(documents, searchTerm) {
38
+ const res = this.index.search(searchTerm);
39
+ const ids = getResultIds(res);
40
+ return findItemsByIds(documents, ids, this.idKey);
41
+ }
42
+ async searchAsync(documents, searchTerm) {
43
+ return this.index.searchAsync(searchTerm).then((res)=>getResultIds(res)).then((res)=>findItemsByIds(documents, res, this.idKey));
44
+ }
45
+ }
46
+ export { SearchIndex };
@@ -0,0 +1,26 @@
1
+ function getResultIds(result) {
2
+ const set = new Set();
3
+ result.forEach((item)=>{
4
+ item.result.forEach((id)=>set.add(id));
5
+ });
6
+ return Array.from(set);
7
+ }
8
+ function findItemsByIds(items, ids, idKey) {
9
+ return items.filter((item)=>item && ids.includes(getValueFromNestedKey(item, idKey)));
10
+ }
11
+ function getValueFromNestedKey(object, nestedKey) {
12
+ const keys = nestedKey.split(':');
13
+ let result = object;
14
+ for (const keySegment of keys)if (Object.prototype.hasOwnProperty.call(result, keySegment)) result = result[keySegment];
15
+ return result;
16
+ }
17
+ function getAllItemKeys(object, parentKey = '') {
18
+ let keys = [];
19
+ for(const key in object)if (Object.prototype.hasOwnProperty.call(object, key)) {
20
+ const currentKey = parentKey ? `${parentKey}.${key}` : key;
21
+ if ('object' == typeof object[key] && null !== object[key]) keys = keys.concat(getAllItemKeys(object[key], currentKey));
22
+ else keys.push(currentKey);
23
+ }
24
+ return keys;
25
+ }
26
+ export { findItemsByIds, getAllItemKeys, getResultIds };
package/types.js ADDED
File without changes
package/cjs/hook/index.js DELETED
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var hook_exports = {};
30
- __export(hook_exports, {
31
- default: () => useSearch
32
- });
33
- module.exports = __toCommonJS(hook_exports);
34
- var import_react = require("react");
35
- var import_search = __toESM(require("@digigov/text-search/search"));
36
- function useSearch(documents, query, options) {
37
- const [loading, setLoading] = (0, import_react.useState)(false);
38
- const [data, setData] = (0, import_react.useState)(documents);
39
- const indexing = options?.indexing;
40
- const index = (0, import_react.useMemo)(
41
- () => new import_search.default(documents, indexing),
42
- [documents, indexing]
43
- );
44
- const search = (0, import_react.useCallback)(() => {
45
- if (query) {
46
- setLoading(true);
47
- index.searchAsync(documents, query).then((data2) => setData(data2)).catch(() => setData([])).finally(() => setLoading(false));
48
- } else {
49
- setData(documents);
50
- }
51
- }, [query, index, documents]);
52
- const reset = (0, import_react.useCallback)(() => {
53
- setData(documents);
54
- setLoading(false);
55
- }, [documents]);
56
- return { data, loading, search, reset };
57
- }
58
- //# sourceMappingURL=hook.js.map
package/cjs/hook.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hook.ts"],
4
- "sourcesContent": ["import { useCallback, useMemo, useState } from 'react';\nimport SearchIndex from '@digigov/text-search/search';\nimport { UseSearchOptions } from '@digigov/text-search/types';\n\n/**\n * Hook for searching through a list of documents\n *\n * Returns a list of documents that match the search query.\n * If no query is provided, it returns the original list of documents.\n *\n * @param documents - The list of documents to search through\n * @param options - Options for configuring the search index\n * @param query - The search query\n *\n * @typeParam T - The type of the data in the documents list\n */\nexport default function useSearch<T extends Record<string, any>>(\n documents: T[],\n query?: string,\n options?: UseSearchOptions<T>\n) {\n const [loading, setLoading] = useState(false);\n const [data, setData] = useState(documents);\n\n const indexing = options?.indexing;\n\n const index = useMemo(\n () => new SearchIndex(documents, indexing),\n [documents, indexing]\n );\n\n const search = useCallback(() => {\n if (query) {\n setLoading(true);\n index\n .searchAsync(documents, query)\n .then((data) => setData(data))\n .catch(() => setData([]))\n .finally(() => setLoading(false));\n } else {\n setData(documents);\n }\n }, [query, index, documents]);\n\n const reset = useCallback(() => {\n setData(documents);\n setLoading(false);\n }, [documents]);\n\n return { data, loading, search, reset };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+C;AAC/C,oBAAwB;AAeT,SAAR,UACL,WACA,OACA,SACA;AACA,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAC5C,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,SAAS;AAE1C,QAAM,WAAW,SAAS;AAE1B,QAAM,YAAQ;AAAA,IACZ,MAAM,IAAI,cAAAA,QAAY,WAAW,QAAQ;AAAA,IACzC,CAAC,WAAW,QAAQ;AAAA,EACtB;AAEA,QAAM,aAAS,0BAAY,MAAM;AAC/B,QAAI,OAAO;AACT,iBAAW,IAAI;AACf,YACG,YAAY,WAAW,KAAK,EAC5B,KAAK,CAACC,UAAS,QAAQA,KAAI,CAAC,EAC5B,MAAM,MAAM,QAAQ,CAAC,CAAC,CAAC,EACvB,QAAQ,MAAM,WAAW,KAAK,CAAC;AAAA,IACpC,OAAO;AACL,cAAQ,SAAS;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,OAAO,OAAO,SAAS,CAAC;AAE5B,QAAM,YAAQ,0BAAY,MAAM;AAC9B,YAAQ,SAAS;AACjB,eAAW,KAAK;AAAA,EAClB,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO,EAAE,MAAM,SAAS,QAAQ,MAAM;AACxC;",
6
- "names": ["SearchIndex", "data"]
7
- }
package/cjs/index.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var src_exports = {};
31
- __export(src_exports, {
32
- default: () => src_default
33
- });
34
- module.exports = __toCommonJS(src_exports);
35
- var import_hook = __toESM(require("@digigov/text-search/hook"));
36
- __reExport(src_exports, require("@digigov/text-search/search"), module.exports);
37
- var src_default = import_hook.default;
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- ...require("@digigov/text-search/search")
41
- });
42
- //# sourceMappingURL=index.js.map
package/cjs/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import useSearch from '@digigov/text-search/hook';\n\nexport default useSearch;\nexport * from '@digigov/text-search/search';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsB;AAGtB,wBAAc,wCAHd;AAEA,IAAO,cAAQ,YAAAA;",
6
- "names": ["useSearch"]
7
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var search_exports = {};
20
- __export(search_exports, {
21
- default: () => search_default
22
- });
23
- module.exports = __toCommonJS(search_exports);
24
- var import_search_index = require("@digigov/text-search/search/search-index");
25
- var search_default = import_search_index.SearchIndex;
26
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/search/index.ts"],
4
- "sourcesContent": ["import { SearchIndex } from '@digigov/text-search/search/search-index';\n\nexport default SearchIndex;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4B;AAE5B,IAAO,iBAAQ;",
6
- "names": []
7
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var encoder_exports = {};
20
- __export(encoder_exports, {
21
- encodeGreek: () => encodeGreek
22
- });
23
- module.exports = __toCommonJS(encoder_exports);
24
- var import_normalization_map = require("@digigov/text-search/search/lang/gr/normalization-map");
25
- const whitespaceRegex = new RegExp("[p{Z}p{S}p{P}p{C}]+", "u");
26
- const diacriticsRegex = new RegExp("[\u0300-\u036F]", "g");
27
- const greekCharsRegex = new RegExp(
28
- Object.keys(import_normalization_map.greekToGreeklishMap).join("|"),
29
- "igu"
30
- );
31
- function encodeGreek(str) {
32
- return ("" + str).toLowerCase().normalize("NFD").replace(diacriticsRegex, "").replace(
33
- greekCharsRegex,
34
- (match) => match in import_normalization_map.greekToGreeklishMap ? import_normalization_map.greekToGreeklishMap[match] : match
35
- ).split(whitespaceRegex);
36
- }
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- encodeGreek
40
- });
41
- //# sourceMappingURL=encoder.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/search/lang/gr/encoder.ts"],
4
- "sourcesContent": ["import { greekToGreeklishMap } from '@digigov/text-search/search/lang/gr/normalization-map';\n\nconst whitespaceRegex = new RegExp('[p{Z}p{S}p{P}p{C}]+', 'u');\nconst diacriticsRegex = new RegExp('[\\u0300-\\u036f]', 'g');\nconst greekCharsRegex = new RegExp(\n Object.keys(greekToGreeklishMap).join('|'),\n 'igu'\n);\n\n/**\n * Encode a string containing greek characters to greeklish\n *\n * This function is used to encode and tokenize a string containing greek characters.\n * It replaces greek characters with their latin counterparts, while also removing\n * any diacritics.\n *\n * @param str - The string to encode\n * @returns An array of encoded words\n */\nexport function encodeGreek(str: string) {\n return ('' + str)\n .toLowerCase()\n .normalize('NFD')\n .replace(diacriticsRegex, '')\n .replace(greekCharsRegex, (match) =>\n match in greekToGreeklishMap\n ? greekToGreeklishMap[match as keyof typeof greekToGreeklishMap]\n : match\n )\n .split(whitespaceRegex);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoC;AAEpC,MAAM,kBAAkB,IAAI,OAAO,uBAAuB,GAAG;AAC7D,MAAM,kBAAkB,IAAI,OAAO,mBAAmB,GAAG;AACzD,MAAM,kBAAkB,IAAI;AAAA,EAC1B,OAAO,KAAK,4CAAmB,EAAE,KAAK,GAAG;AAAA,EACzC;AACF;AAYO,SAAS,YAAY,KAAa;AACvC,UAAQ,KAAK,KACV,YAAY,EACZ,UAAU,KAAK,EACf,QAAQ,iBAAiB,EAAE,EAC3B;AAAA,IAAQ;AAAA,IAAiB,CAAC,UACzB,SAAS,+CACL,6CAAoB,KAAyC,IAC7D;AAAA,EACN,EACC,MAAM,eAAe;AAC1B;",
6
- "names": []
7
- }
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var normalization_map_exports = {};
20
- __export(normalization_map_exports, {
21
- greekToGreeklishMap: () => greekToGreeklishMap
22
- });
23
- module.exports = __toCommonJS(normalization_map_exports);
24
- const greekToGreeklishMap = {
25
- \u0393\u03A7: "GX",
26
- \u03B3\u03C7: "gx",
27
- \u03A4\u0398: "T8",
28
- \u03C4\u03B8: "t8",
29
- \u03B8\u03B7: "8h",
30
- \u0398\u03B7: "8h",
31
- \u0398\u0397: "8H",
32
- \u03B1\u03C5: "au",
33
- \u0391\u03C5: "Au",
34
- \u0391\u03A5: "AY",
35
- \u03B5\u03C5: "eu",
36
- \u03B5\u03CD: "eu",
37
- \u03B5\u03CB: "ey",
38
- \u03B5\u03B0: "ey",
39
- \u0395\u03C5: "Eu",
40
- \u0395\u03CD: "Eu",
41
- \u0395\u03CB: "Ey",
42
- \u0395\u03B0: "Ey",
43
- \u0395\u03A5: "EY",
44
- \u03BF\u03C5: "ou",
45
- \u03BF\u03CD: "ou",
46
- \u03BF\u03CB: "oy",
47
- \u03BF\u03B0: "oy",
48
- \u039F\u03C5: "Ou",
49
- \u039F\u03CD: "Ou",
50
- \u039F\u03CB: "Oy",
51
- \u039F\u03B0: "Oy",
52
- \u039F\u03A5: "OY",
53
- \u0391: "A",
54
- \u03B1: "a",
55
- \u03AC: "a",
56
- \u0386: "A",
57
- \u0392: "B",
58
- \u03B2: "b",
59
- \u0393: "G",
60
- \u03B3: "g",
61
- \u0394: "D",
62
- \u03B4: "d",
63
- \u0395: "E",
64
- \u03B5: "e",
65
- \u03AD: "e",
66
- \u0388: "E",
67
- \u0396: "Z",
68
- \u03B6: "z",
69
- \u0397: "H",
70
- \u03B7: "h",
71
- \u03AE: "h",
72
- \u0389: "H",
73
- \u0398: "TH",
74
- \u03B8: "th",
75
- \u0399: "I",
76
- \u03AA: "I",
77
- \u03B9: "i",
78
- \u03AF: "i",
79
- \u0390: "i",
80
- \u03CA: "i",
81
- \u038A: "I",
82
- \u039A: "K",
83
- \u03BA: "k",
84
- \u039B: "L",
85
- \u03BB: "l",
86
- \u039C: "M",
87
- \u03BC: "m",
88
- \u039D: "N",
89
- \u03BD: "n",
90
- \u039E: "KS",
91
- \u03BE: "ks",
92
- \u039F: "O",
93
- \u03BF: "o",
94
- \u038C: "O",
95
- \u03CC: "o",
96
- \u03A0: "P",
97
- \u03C0: "p",
98
- \u03A1: "R",
99
- \u03C1: "r",
100
- \u03A3: "S",
101
- \u03C3: "s",
102
- \u03A4: "T",
103
- \u03C4: "t",
104
- \u03A5: "Y",
105
- \u038E: "Y",
106
- \u03AB: "Y",
107
- \u03B0: "y",
108
- \u03CD: "y",
109
- \u03CB: "y",
110
- \u03C5: "y",
111
- \u03A6: "F",
112
- \u03C6: "f",
113
- \u03A7: "X",
114
- \u03C7: "x",
115
- \u03A8: "Ps",
116
- \u03C8: "ps",
117
- \u03A9: "w",
118
- \u03C9: "w",
119
- \u038F: "w",
120
- \u03CE: "w",
121
- \u03C2: "s",
122
- ";": "?"
123
- };
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- greekToGreeklishMap
127
- });
128
- //# sourceMappingURL=normalization-map.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/search/lang/gr/normalization-map.ts"],
4
- "sourcesContent": ["export const greekToGreeklishMap = {\n \u0393\u03A7: 'GX',\n \u03B3\u03C7: 'gx',\n \u03A4\u0398: 'T8',\n \u03C4\u03B8: 't8',\n \u03B8\u03B7: '8h',\n \u0398\u03B7: '8h',\n \u0398\u0397: '8H',\n \u03B1\u03C5: 'au',\n \u0391\u03C5: 'Au',\n \u0391\u03A5: 'AY',\n \u03B5\u03C5: 'eu',\n \u03B5\u03CD: 'eu',\n \u03B5\u03CB: 'ey',\n \u03B5\u03B0: 'ey',\n \u0395\u03C5: 'Eu',\n \u0395\u03CD: 'Eu',\n \u0395\u03CB: 'Ey',\n \u0395\u03B0: 'Ey',\n \u0395\u03A5: 'EY',\n \u03BF\u03C5: 'ou',\n \u03BF\u03CD: 'ou',\n \u03BF\u03CB: 'oy',\n \u03BF\u03B0: 'oy',\n \u039F\u03C5: 'Ou',\n \u039F\u03CD: 'Ou',\n \u039F\u03CB: 'Oy',\n \u039F\u03B0: 'Oy',\n \u039F\u03A5: 'OY',\n \u0391: 'A',\n \u03B1: 'a',\n \u03AC: 'a',\n \u0386: 'A',\n \u0392: 'B',\n \u03B2: 'b',\n \u0393: 'G',\n \u03B3: 'g',\n \u0394: 'D',\n \u03B4: 'd',\n \u0395: 'E',\n \u03B5: 'e',\n \u03AD: 'e',\n \u0388: 'E',\n \u0396: 'Z',\n \u03B6: 'z',\n \u0397: 'H',\n \u03B7: 'h',\n \u03AE: 'h',\n \u0389: 'H',\n \u0398: 'TH',\n \u03B8: 'th',\n \u0399: 'I',\n \u03AA: 'I',\n \u03B9: 'i',\n \u03AF: 'i',\n \u0390: 'i',\n \u03CA: 'i',\n \u038A: 'I',\n \u039A: 'K',\n \u03BA: 'k',\n \u039B: 'L',\n \u03BB: 'l',\n \u039C: 'M',\n \u03BC: 'm',\n \u039D: 'N',\n \u03BD: 'n',\n \u039E: 'KS',\n \u03BE: 'ks',\n \u039F: 'O',\n \u03BF: 'o',\n \u038C: 'O',\n \u03CC: 'o',\n \u03A0: 'P',\n \u03C0: 'p',\n \u03A1: 'R',\n \u03C1: 'r',\n \u03A3: 'S',\n \u03C3: 's',\n \u03A4: 'T',\n \u03C4: 't',\n \u03A5: 'Y',\n \u038E: 'Y',\n \u03AB: 'Y',\n \u03B0: 'y',\n \u03CD: 'y',\n \u03CB: 'y',\n \u03C5: 'y',\n \u03A6: 'F',\n \u03C6: 'f',\n \u03A7: 'X',\n \u03C7: 'x',\n \u03A8: 'Ps',\n \u03C8: 'ps',\n \u03A9: 'w',\n \u03C9: 'w',\n \u038F: 'w',\n \u03CE: 'w',\n \u03C2: 's',\n ';': '?',\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,sBAAsB;AAAA,EACjC,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,cAAI;AAAA,EACJ,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,QAAG;AAAA,EACH,KAAK;AACP;",
6
- "names": []
7
- }