-
Notifications
You must be signed in to change notification settings - Fork 27.9k
/
languageDetectionWorkerService.ts
69 lines (55 loc) · 3.06 KB
/
languageDetectionWorkerService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const ILanguageDetectionService = createDecorator<ILanguageDetectionService>('ILanguageDetectionService');
export interface ILanguageDetectionService {
readonly _serviceBrand: undefined;
/**
* @param languageId The languageId to check if language detection is currently enabled.
* @returns whether or not language detection is on for this language.
*/
isEnabledForLanguage(languageId: string): boolean;
/**
* @param resource The resource to detect the language for.
* @param supportedLangs Optional. When populated, the model will only return languages from the provided list
* @returns the language id for the given resource or undefined if the model is not confident enough.
*/
detectLanguage(resource: URI, supportedLangs?: string[]): Promise<string | undefined>;
}
export type LanguageDetectionHintConfig = {
untitledEditors: boolean;
notebookEditors: boolean;
};
//#region Telemetry events
export const AutomaticLanguageDetectionLikelyWrongId = 'automaticlanguagedetection.likelywrong';
export interface IAutomaticLanguageDetectionLikelyWrongData {
currentLanguageId: string;
nextLanguageId: string;
lineCount: number;
modelPreference: string;
}
export type AutomaticLanguageDetectionLikelyWrongClassification = {
owner: 'TylerLeonhardt,JacksonKearl';
comment: 'Used to determine how often language detection is likely wrong.';
currentLanguageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language id we guessed.' };
nextLanguageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language id the user chose.' };
lineCount: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'The number of lines in the file.' };
modelPreference: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'What the user\'s model preference is.' };
};
export const LanguageDetectionStatsId = 'automaticlanguagedetection.stats';
export interface ILanguageDetectionStats {
languages: string;
confidences: string;
timeSpent: number;
}
export type LanguageDetectionStatsClassification = {
owner: 'TylerLeonhardt,JacksonKearl';
comment: 'Used to determine how definitive language detection is and how long it takes.';
languages: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The languages the model supports.' };
confidences: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The confidences of those languages.' };
timeSpent: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'How long the operation took.' };
};
//#endregion