The ModelOperations class is the primary interface for running the language detection model. It takes text content and returns an array of ModelResult objects, sorted by confidence in descending order.
To use it, instantiate ModelOperations (optionally providing configuration) and call runModel(content). Note that the model is loaded lazily upon the first call to runModel.
import { ModelOperations } from '@vscode/vscode-languagedetection';
const modelOps = new ModelOperations();
const results = await modelOps.runModel('some text content');
// results is an array of { languageId: string, confidence: number }
for (const result of results) {
console.log(`Language: ${result.languageId}, Confidence: ${result.confidence}`);
}
// Clean up resources when finished
modelOps.dispose();