entity-predictor 1.2.1 → 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 +2 -2
- package/package.json +1 -1
- package/src/predictor.js +3 -3
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ console.log(result);
|
|
|
78
78
|
Output:
|
|
79
79
|
{
|
|
80
80
|
entity: "ICICI BANK",
|
|
81
|
-
confidence: 0.
|
|
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
|
|
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
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
|
|
149
|
+
const sortedMatches = (matches?.ratings || [])
|
|
150
150
|
.map((rating, index) => ({
|
|
151
151
|
entity: this.candidateToEntity[index],
|
|
152
|
-
confidence: rating
|
|
153
|
-
confidenceLevel: this._getConfidenceLevel(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);
|