@bntk/ner
Version:
Build applications with Bengali natural language processing tools.
51 lines (50 loc) • 1.12 kB
JavaScript
// packages/core/ner/src/index.ts
var EntityType;
((EntityType2) => {
EntityType2["PERSON"] = "PERSON";
EntityType2["ORGANIZATION"] = "ORGANIZATION";
EntityType2["LOCATION"] = "LOCATION";
EntityType2["DATE"] = "DATE";
EntityType2["MONEY"] = "MONEY";
EntityType2["PERCENT"] = "PERCENT";
EntityType2["TIME"] = "TIME";
EntityType2["UNKNOWN"] = "UNKNOWN";
})(EntityType ||= {});
function extractEntities(text) {
return [
{
text: "John Doe",
type: "PERSON" /* PERSON */,
start: 0,
end: 8,
confidence: 0.95
},
{
text: "New York",
type: "LOCATION" /* LOCATION */,
start: 15,
end: 23,
confidence: 0.88
}
];
}
function classifyEntity(text) {
return "PERSON" /* PERSON */;
}
function getEntityConfidence(text, entityType) {
return 0.85;
}
function batchExtractEntities(texts) {
return texts.map(extractEntities);
}
function getSupportedEntityTypes() {
return Object.values(EntityType);
}
export {
getSupportedEntityTypes,
getEntityConfidence,
extractEntities,
classifyEntity,
batchExtractEntities,
EntityType
};