@mailwoman/core 3.0.0 → 4.0.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.
Files changed (55) hide show
  1. package/out/classification/Classification.d.ts +2 -2
  2. package/out/decoder/build-tree.d.ts +13 -4
  3. package/out/decoder/build-tree.d.ts.map +1 -1
  4. package/out/decoder/build-tree.js +36 -8
  5. package/out/decoder/build-tree.js.map +1 -1
  6. package/out/decoder/containment.d.ts +31 -2
  7. package/out/decoder/containment.d.ts.map +1 -1
  8. package/out/decoder/containment.js +36 -3
  9. package/out/decoder/containment.js.map +1 -1
  10. package/out/decoder/index.d.ts +1 -0
  11. package/out/decoder/index.d.ts.map +1 -1
  12. package/out/decoder/index.js +1 -0
  13. package/out/decoder/index.js.map +1 -1
  14. package/out/decoder/types.d.ts +21 -0
  15. package/out/decoder/types.d.ts.map +1 -1
  16. package/out/decoder/validate-tree.d.ts +39 -0
  17. package/out/decoder/validate-tree.d.ts.map +1 -0
  18. package/out/decoder/validate-tree.js +79 -0
  19. package/out/decoder/validate-tree.js.map +1 -0
  20. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  21. package/out/pipeline/runtime-pipeline.js +13 -4
  22. package/out/pipeline/runtime-pipeline.js.map +1 -1
  23. package/out/pipeline/span-logit-aggregation.d.ts +3 -2
  24. package/out/pipeline/span-logit-aggregation.d.ts.map +1 -1
  25. package/out/pipeline/span-logit-aggregation.js +3 -2
  26. package/out/pipeline/span-logit-aggregation.js.map +1 -1
  27. package/out/pipeline/types.d.ts +2 -0
  28. package/out/pipeline/types.d.ts.map +1 -1
  29. package/out/resolver/resolve.js +50 -8
  30. package/out/resolver/resolve.js.map +1 -1
  31. package/out/resolver/types.d.ts +30 -0
  32. package/out/resolver/types.d.ts.map +1 -1
  33. package/out/resolver/types.js.map +1 -1
  34. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  35. package/out/resources/whosonfirst/PlacetypeDataSource.js +3 -1
  36. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  37. package/out/resources/whosonfirst/placetypes/graph.d.ts +47 -0
  38. package/out/resources/whosonfirst/placetypes/graph.d.ts.map +1 -0
  39. package/out/resources/whosonfirst/placetypes/graph.js +0 -0
  40. package/out/resources/whosonfirst/placetypes/graph.js.map +1 -0
  41. package/out/resources/whosonfirst/placetypes/index.d.ts +2 -0
  42. package/out/resources/whosonfirst/placetypes/index.d.ts.map +1 -1
  43. package/out/resources/whosonfirst/placetypes/index.js +2 -0
  44. package/out/resources/whosonfirst/placetypes/index.js.map +1 -1
  45. package/out/resources/whosonfirst/placetypes/mermaid.d.ts +35 -3
  46. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  47. package/out/resources/whosonfirst/placetypes/mermaid.js +87 -15
  48. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  49. package/out/resources/whosonfirst/placetypes/tree.d.ts +30 -0
  50. package/out/resources/whosonfirst/placetypes/tree.d.ts.map +1 -0
  51. package/out/resources/whosonfirst/placetypes/tree.js +28 -0
  52. package/out/resources/whosonfirst/placetypes/tree.js.map +1 -0
  53. package/out/solver/SolutionMatch.d.ts +1 -1
  54. package/out/solver/mask.d.ts +1 -1
  55. package/package.json +7 -1
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import { Placetype } from "./Placetype.js";
7
+ /**
8
+ * Build a nested tree of a placetype and its descendants, optionally filtered by role.
9
+ *
10
+ * The traversal mirrors {@linkcode Placetype.findChildren} — direct children only at each level,
11
+ * recursively. The DAG-to-tree projection may repeat descendants under multiple parents; if you
12
+ * need each placetype to appear exactly once, use {@linkcode Placetype.findDescendants} for a flat
13
+ * de-duplicated set instead.
14
+ */
15
+ export function generatePlacetypeTree(placetype, roles) {
16
+ const roleSet = roles ? new Set(roles) : null;
17
+ return buildNode(placetype, roleSet);
18
+ }
19
+ function buildNode(placetype, roles) {
20
+ const children = placetype.findChildren(roles).map((child) => buildNode(child, roles));
21
+ return {
22
+ name: placetype.name,
23
+ id: placetype.id,
24
+ role: placetype.role,
25
+ children,
26
+ };
27
+ }
28
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../../resources/whosonfirst/placetypes/tree.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAgB1C;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAoB,EAAE,KAAsC;IACjG,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAE7C,OAAO,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC;AAED,SAAS,SAAS,CAAC,SAAoB,EAAE,KAAgC;IACxE,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IAEtF,OAAO;QACN,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,QAAQ;KACR,CAAA;AACF,CAAC"}
@@ -32,7 +32,7 @@ export declare class SolutionMatch implements SerializedSolutionMatch {
32
32
  /**
33
33
  * The classification of the match.
34
34
  */
35
- get classification(): "adjacent" | "alpha" | "alphanumeric" | "area" | "chain" | "country" | "dependency" | "directional" | "end_token_single_character" | "end_token" | "given_name" | "house_number" | "intersection" | "level_designator" | "level" | "locality" | "middle_initial" | "multistreet" | "numeric" | "ordinal" | "person" | "personal_suffix" | "personal_title" | "place" | "postcode" | "punctuation" | "region" | "road_type" | "start_token" | "stop_word" | "street_name" | "street_prefix" | "street_proper_name" | "street_suffix" | "street" | "surname" | "toponym" | "unit_designator" | "unit" | "unknown" | "venue";
35
+ get classification(): "country" | "region" | "locality" | "postcode" | "house_number" | "street" | "street_prefix" | "street_suffix" | "unit" | "venue" | "adjacent" | "alpha" | "alphanumeric" | "area" | "chain" | "dependency" | "directional" | "end_token_single_character" | "end_token" | "given_name" | "intersection" | "level_designator" | "level" | "middle_initial" | "multistreet" | "numeric" | "ordinal" | "person" | "personal_suffix" | "personal_title" | "place" | "punctuation" | "road_type" | "start_token" | "stop_word" | "street_name" | "street_proper_name" | "surname" | "toponym" | "unit_designator" | "unknown";
36
36
  /**
37
37
  * The confidence of the match, from 0 to 1.
38
38
  *
@@ -9,7 +9,7 @@ type MaskCode = "V" | "N" | "S" | "P" | "L" | "U" | "A";
9
9
  /**
10
10
  * Mapping of classification labels to mask codes.
11
11
  */
12
- export declare const ClassificationMaskCodeMap: Map<"adjacent" | "alpha" | "alphanumeric" | "area" | "chain" | "country" | "dependency" | "directional" | "end_token_single_character" | "end_token" | "given_name" | "house_number" | "intersection" | "level_designator" | "level" | "locality" | "middle_initial" | "multistreet" | "numeric" | "ordinal" | "person" | "personal_suffix" | "personal_title" | "place" | "postcode" | "punctuation" | "region" | "road_type" | "start_token" | "stop_word" | "street_name" | "street_prefix" | "street_proper_name" | "street_suffix" | "street" | "surname" | "toponym" | "unit_designator" | "unit" | "unknown" | "venue" | "fallback", MaskCode>;
12
+ export declare const ClassificationMaskCodeMap: Map<"country" | "region" | "locality" | "postcode" | "house_number" | "street" | "street_prefix" | "street_suffix" | "unit" | "venue" | "adjacent" | "alpha" | "alphanumeric" | "area" | "chain" | "dependency" | "directional" | "end_token_single_character" | "end_token" | "given_name" | "intersection" | "level_designator" | "level" | "middle_initial" | "multistreet" | "numeric" | "ordinal" | "person" | "personal_suffix" | "personal_title" | "place" | "punctuation" | "road_type" | "start_token" | "stop_word" | "street_name" | "street_proper_name" | "surname" | "toponym" | "unit_designator" | "unknown" | "fallback", MaskCode>;
13
13
  /**
14
14
  * Mask which shows the areas covered by different types of classification
15
15
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/core",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Mailwoman core: tokenization, classification primitives, solver, formatter, resources, filters, solvers, utils.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -51,6 +51,8 @@
51
51
  "dependencies": {
52
52
  "axios": "^1.16.1",
53
53
  "axios-cache-interceptor": "^1.12.0",
54
+ "d3-color": "^3.1.0",
55
+ "d3-scale-chromatic": "^3.1.0",
54
56
  "http-status-codes": "^2.3.0",
55
57
  "json-colorizer": "^3.0.1",
56
58
  "kysely": "^0.29.2",
@@ -58,6 +60,10 @@
58
60
  "pino-pretty": "^13.1.3",
59
61
  "table": "^6.9.0"
60
62
  },
63
+ "devDependencies": {
64
+ "@types/d3-color": "^3.1.3",
65
+ "@types/d3-scale-chromatic": "^3.1.0"
66
+ },
61
67
  "files": [
62
68
  "out/**/*.js",
63
69
  "out/**/*.js.map",