Skip to content

Commit 02c9d86

Browse files
Joan GinerJoan Giner
authored andcommitted
Improved hints, by implementing the hover service
1 parent cc7a518 commit 02c9d86

File tree

2 files changed

+169
-0
lines changed

2 files changed

+169
-0
lines changed

src/extension.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
} from 'vscode-languageclient/node';
77
import { DocumentationGenerator } from './generator-service/dataset-descriptor-documentation';
88
import { DatasetUploader } from './uploader-service/dataset-descriptor-uploader';
9+
import { HintsService } from './hints-service/hints-service';
10+
911

1012

1113
let client: LanguageClient;
@@ -29,6 +31,18 @@ export function activate(context: vscode.ExtensionContext): void {
2931
});
3032
}));
3133

34+
context.subscriptions.push(
35+
vscode.languages.registerHoverProvider(
36+
'dataset-descriptor', {
37+
provideHover(document, position, token) {
38+
let hints = new HintsService();
39+
let content = hints.populateHints(document, position);
40+
41+
if (content != "empty") return new vscode.Hover(new vscode.MarkdownString(content));
42+
return null;
43+
}
44+
}));
45+
3246
// Here we register the HTML generation service
3347
context.subscriptions.push(vscode.commands.registerCommand('datadesc.generateDocumentation', async () => {
3448
await generatorHTMLService(context);

src/hints-service/hints-service.ts

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/******************************************************************************
2+
* Copyright 2022 SOM Research
3+
* This program and the accompanying materials are made available under the
4+
* terms of the MIT License, which is available in the project root.
5+
******************************************************************************/
6+
import { TextDocument } from 'vscode';
7+
8+
9+
10+
11+
export interface Hints {
12+
// Load the Abstract Syntax Tree of the .descML active file
13+
populateHints(Declaration : string | TextDocument, position: any) : string | undefined;
14+
}
15+
16+
/**
17+
*/
18+
export class HintsService implements Hints {
19+
20+
21+
constructor() {
22+
23+
}
24+
25+
populateHints(document : TextDocument, position: any) : string {
26+
const wordRange = document.getWordRangeAtPosition(position);
27+
const word = document.getText(wordRange);
28+
switch (word) {
29+
case "Metadata":
30+
return `## Metadata
31+
In this section authors are expected to provide the metadata of the dataset
32+
`
33+
case "Dates":
34+
return "Set the release, published and last updated date in DD-MM-YYYY format";
35+
case "Citation":
36+
return "Set the citations of the dataset";
37+
// Description
38+
case "Description":
39+
return `### Description
40+
In this section authors are expected to provide a description of the dataset
41+
42+
#### Purposes:
43+
For what propose was the dataser created?
44+
45+
#### Tasks:
46+
For what tasks this dataset is inteded for
47+
48+
#### Gaps:
49+
Was there specific gap that needed to be filled? Please provide a description
50+
`;
51+
case "Purposes":
52+
return "For what propose was the dataser created?";
53+
case "Tasks":
54+
return "For what tasks this dataset is inteded for";
55+
case "Gaps":
56+
return "Was there specific gap that needed to be filled?\nPlease provide a description";
57+
case "Tags":
58+
return "Set the tags separated by a whitespace";
59+
case "Areas":
60+
return "Set the areas separated by a whitespace";
61+
// Distribution
62+
case "Distribution":
63+
return `## Distribution
64+
In this section authors are expected to indicate the distribution of the dataset
65+
66+
### Licenses:
67+
Set the licence of the dataset.
68+
69+
## Rights stand-alone:
70+
Choose the level of distribution of the stand-alone data.
71+
72+
## Rights of the models:
73+
Choose the level of distribution of the models trained with the data.
74+
`;
75+
case "Licenses":
76+
return "Indicate in 'others:' if any other policy is applied to the data";
77+
// Applications
78+
case "Applications":
79+
return `## Applications
80+
In this section authors are expected to indicate the recommneded and non-recommneded uses of the dataset
81+
82+
### Benchmarking
83+
If the dataset have been used in the past, authors are expected to indicate the benchmarking results
84+
Models names, and results should be provided (accuracy, precision, recall, F1-score)
85+
`;
86+
// Authoring
87+
case "Authoring":
88+
return `## Authoring
89+
In this section authors are expected to indicate who created the dataset and who funded the dataset
90+
Please provide information about the organization grating the work
91+
92+
### Maintenance
93+
Who maintains the dataset, but also the contribution policies, if theere is any erratum, and the data life cycle should be informed in this chapter
94+
`;
95+
case "Funders":
96+
return "Who founded the creation of the dataset?\n2 - If is there any associated grant, please provide the number and the name of the grantor and the gran name and number \n Set a `_` or a `-` as a white spaces in the name e.g: 'John_Smith'? ";
97+
case "Authors":
98+
return "Who is the author of the dataset?";
99+
case "Maintainers":
100+
return "Who maintan the dataset? How can be contacted?";
101+
// Composition
102+
case "Composition":
103+
return `## Composition
104+
Please provide information about the composition of the dataset. The type of files (data instances), it's number, and information regarding attributes
105+
106+
### Statistics
107+
A set of statistics can be provided for each attribute and at a data instance level. Please provide only the statistics that are relevant for the specific dataset use case.
108+
109+
### Consistency rules
110+
The Consistency rules can be expressed following OCL. OCL is a language for expressing constraints on models. It is based on the Object Constraint Language (OCL) defined by OMG. OCL is a language for expressing constraints on models. It is based on the Object Constraint Language (OCL) defined by OMG. \n
111+
112+
`;
113+
// Provenance
114+
case "Provenance":
115+
return `## Provenance
116+
In this section authors are expected to fill information about the process applied to create the dataset
117+
118+
### Curation Rationale
119+
This explanation intend to be a shor and comprhensive enumartion of the processes applied over the data, and to provide specific use-case details for this dataset
120+
121+
### Gathering
122+
How the dataset has been gathered? Who gathered the dataset? Which are the sources of the data?
123+
124+
### Annotation
125+
How the dataset has been annotated? Who annotated the dataset? Which are the infrastructure used to annotate the data?
126+
127+
### Data preparation
128+
Indicate the process done to prepare the data, and it's type
129+
130+
`;
131+
// Social Concers
132+
case "Concerns":
133+
return `
134+
## Social Concerns
135+
In this section authors are expected to fill information about the social concerns of the data. Is expected to inform 4 types of social concerns \n
136+
137+
### Bias concers
138+
Whether the dataset may be biased against a specific social group
139+
140+
### Representativeness concerns
141+
Whether the dataset could misrepresent any specific social group
142+
143+
### Sensitivity concerns
144+
Does the dataset contains data that can offend a social group?
145+
146+
### Privacy Concerns
147+
Is there any privacy concerns on the data?
148+
149+
`;
150+
default:
151+
return "empty"
152+
}
153+
}
154+
}
155+

0 commit comments

Comments
 (0)