entity-predictor 1.2.0 → 1.2.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/README.md CHANGED
@@ -78,7 +78,7 @@ console.log(result);
78
78
  Output:
79
79
  {
80
80
  entity: "ICICI BANK",
81
- confidence: 0.714...,
81
+ confidence: 0.71,
82
82
  confidenceLevel: "Moderate Confidence"
83
83
  }
84
84
  */
@@ -141,7 +141,7 @@ predictor.addEntity("PUNJAB NATIONAL BANK", ["PNB"]);
141
141
 
142
142
  - `input`: String to search for.
143
143
  - `threshold`: (Optional) Minimum confidence score (default `0.6`).
144
- - **Returns**: Best match object or `{ entity: "UNKNOWN", ... }`.
144
+ - **Returns**: Best match object, `{ entity: "UNKNOWN", ... }` if no match found, or `null` if input is invalid.
145
145
 
146
146
  ### `predictTop(input, limit, threshold)`
147
147
 
package/package.json CHANGED
@@ -1,17 +1,27 @@
1
1
  {
2
2
  "name": "entity-predictor",
3
- "version": "1.2.0",
4
- "description": "Lightweight entity prediction with fuzzy matching, aliases, and confidence scoring.",
3
+ "version": "1.2.2",
4
+ "description": "Lightweight, Zero Dependency Node.js library for entity name prediction and normalization.",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
7
  "main": "src/index.js",
8
+ "author": "Sahil <dev.sahilkumar02@gmail.com> (github.com/Sahilkr02)",
8
9
  "keywords": [
9
10
  "nlp",
10
11
  "entity",
11
12
  "prediction",
12
- "nodejs"
13
+ "nodejs",
14
+ "fuzzy-matching",
15
+ "string-similarity",
16
+ "entity-normalization",
17
+ "entity-prediction"
18
+ ],
19
+ "files": [
20
+ "src/index.js",
21
+ "src/predictor.js",
22
+ "src/string-similarity.js",
23
+ "index.d.ts",
24
+ "package.json"
13
25
  ],
14
- "author": "Sahil",
15
- "email": "dev.sahilkumar02@gmail.com",
16
26
  "license": "MIT"
17
27
  }
package/src/predictor.js CHANGED
@@ -146,11 +146,11 @@ export class EntityPredictor {
146
146
  const matches = findBestMatch(normalizedInput, this.searchCandidates);
147
147
 
148
148
  // Map all ratings to our format and sort
149
- const sortedMatches = matches.ratings
149
+ const sortedMatches = (matches?.ratings || [])
150
150
  .map((rating, index) => ({
151
151
  entity: this.candidateToEntity[index],
152
- confidence: rating.rating,
153
- confidenceLevel: this._getConfidenceLevel(rating.rating),
152
+ confidence: Number(rating?.rating?.toFixed(2)),
153
+ confidenceLevel: this._getConfidenceLevel(rating?.rating),
154
154
  }))
155
155
  .filter((m) => m.confidence >= threshold)
156
156
  .sort((a, b) => b.confidence - a.confidence);