Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3b38176

Browse files
Refinery-ui-react (#6)
* Enums and enum functions * Updated date parser helper functions * Added enum and enum function for data slices types * Enums for data browser filters * Enums and enum functions * Added option to enum * Enum type added * Project overview filters and label distribution graph * Type change for nameFunction * Console log error in jsonFetchWrapper * Download byte data without stringifying it * Added category as part of the enum * Enum for manual gold * Removed unused enum type
1 parent 85dd4d6 commit 3b38176

File tree

6 files changed

+120
-2
lines changed

6 files changed

+120
-2
lines changed

‎basic-fetch.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export function jsonFetchWrapper(url: string, fetchType: FetchType, onResult?: (
2121
hasError = true;
2222
}
2323
else return response.json();
24+
}, (error) => {
25+
console.log("Error in request at " + url);
2426
});
2527

2628
if (onResult && !hasError) myFetch.then(result => onResult(result));

‎date-parser.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ export function isValidDate(date: string) {
2828
if (isNaN(Date.parse(date))) return false;
2929
const d = new Date(date);
3030
return d.getFullYear() < 2100;
31+
}
32+
33+
export function timeDiffCalc(dateA: any, dateB: any = Date.now()) {
34+
return new Date(Math.abs(dateB - dateA)).toISOString().substring(11, 19);
3135
}

‎enums/enum-functions.ts‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { InformationSourceType } from "./enums";
1+
import { DisplayGraphs,InformationSourceType,LabelSource,SearchGroup,Slice,StaticOrderByKeys } from "./enums";
22

33
export function informationSourceTypeToString(source: InformationSourceType, short: boolean, forDisplay: boolean = true) {
44
if (forDisplay) {
@@ -13,3 +13,66 @@ export function informationSourceTypeToString(source: InformationSourceType, sho
1313
}
1414
return source;
1515
}
16+
17+
export function displayGraphsTypeToString(source: DisplayGraphs) {
18+
switch (source) {
19+
20+
case DisplayGraphs.CONFUSION_MATRIX: return "Confusion Matrix";
21+
case DisplayGraphs.INTER_ANNOTATOR: return "Inter Annotator";
22+
case DisplayGraphs.LABEL_DISTRIBUTION: return "Label Distribution";
23+
case DisplayGraphs.CONFIDENCE_DISTRIBUTION: return "Confidence Distribution";
24+
case DisplayGraphs.ALL: return "All";
25+
default: return source;
26+
}
27+
}
28+
29+
export function labelSourceToString(source: LabelSource, forDisplay: boolean = true) {
30+
if (forDisplay) {
31+
switch (source) {
32+
case LabelSource.MANUAL: return "Manual";
33+
case LabelSource.WEAK_SUPERVISION: return "Weak Supervision";
34+
case LabelSource.MODEL_CALLBACK: return "Model Callback";
35+
case LabelSource.INFORMATION_SOURCE: return "Information Source";
36+
default: return source;
37+
}
38+
}
39+
return source;
40+
}
41+
42+
43+
export function sliceTypeToString(sliceType: string): string {
44+
switch (sliceType) {
45+
case Slice.STATIC_DEFAULT:
46+
return 'Static Slice';
47+
case Slice.STATIC_OUTLIER:
48+
return 'Outlier Slice';
49+
case Slice.DYNAMIC_DEFAULT:
50+
return 'Dynamic Slice';
51+
default: return sliceType;
52+
}
53+
}
54+
55+
export function nameForGroupKeyToString(group: SearchGroup): string {
56+
switch (group) {
57+
case SearchGroup.ATTRIBUTES:
58+
return 'Attributes';
59+
case SearchGroup.USER_FILTER:
60+
return 'Users';
61+
case SearchGroup.LABELING_TASKS:
62+
return 'Labeling task:';
63+
case SearchGroup.ORDER_STATEMENTS:
64+
return 'Result Order';
65+
case SearchGroup.COMMENTS:
66+
return 'Comments';
67+
default: return group;
68+
}
69+
}
70+
71+
export function getOrderByDisplayName(orderByKey: string) {
72+
switch (orderByKey) {
73+
case StaticOrderByKeys.RANDOM: return "Random";
74+
case StaticOrderByKeys.WEAK_SUPERVISION_CONFIDENCE: return "Weak Supervision Confidence";
75+
case StaticOrderByKeys.MODEL_CALLBACK_CONFIDENCE: return "Model Callback Confidence";
76+
default: return orderByKey; //attributes
77+
}
78+
}

‎enums/enums.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,46 @@ export enum InformationSourceType {
44
PRE_COMPUTED = "PRE_COMPUTED",
55
ZERO_SHOT = "ZERO_SHOT",
66
CROWD_LABELER = "CROWD_LABELER"
7+
}
8+
9+
export enum DisplayGraphs {
10+
ALL = "ALL",
11+
CONFUSION_MATRIX = "CONFUSION_MATRIX",
12+
INTER_ANNOTATOR = "INTER_ANNOTATOR",
13+
LABEL_DISTRIBUTION = "LABEL_DISTRIBUTION",
14+
CONFIDENCE_DISTRIBUTION = "CONFIDENCE_DISTRIBUTION",
15+
}
16+
17+
export enum LabelSource {
18+
MANUAL = "MANUAL",
19+
WEAK_SUPERVISION = "WEAK_SUPERVISION",
20+
INFORMATION_SOURCE = "INFORMATION_SOURCE",
21+
MODEL_CALLBACK = "MODEL_CALLBACK",
22+
}
23+
24+
export enum Slice {
25+
STATIC_DEFAULT = "STATIC_DEFAULT",
26+
STATIC_OUTLIER = "STATIC_OUTLIER",
27+
DYNAMIC_DEFAULT = "DYNAMIC_DEFAULT",
28+
}
29+
30+
export enum SearchGroup {
31+
ATTRIBUTES = 'ATTRIBUTES',
32+
LABELING_TASKS = 'LABELING_TASKS',
33+
ORDER_STATEMENTS = 'ORDER_STATEMENTS',
34+
USER_FILTER = 'USER_FILTER',
35+
COMMENTS = 'COMMENTS',
36+
DRILL_DOWN = 'DRILL_DOWN',
37+
CATEGORY = 'CATEGORY',
38+
}
39+
40+
export enum StaticOrderByKeys {
41+
MODEL_CALLBACK_CONFIDENCE = "MODEL_CALLBACK_CONFIDENCE",
42+
WEAK_SUPERVISION_CONFIDENCE = 'WEAK_SUPERVISION_CONFIDENCE',
43+
RANDOM = 'RANDOM'
44+
}
45+
46+
export enum InformationSourceReturnType {
47+
RETURN = "RETURN",
48+
YIELD = "YIELD"
749
}

‎export.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ export function downloadByteData(byteData: any, filename = 'file.zip', type = 'a
3131
download(blob, filename);
3232
}
3333

34+
export function downloadByteDataNoStringify(byteData: any, filename = 'file.zip', type = 'application/octet-stream') {
35+
const blob = new Blob([byteData], {
36+
type: type
37+
});
38+
download(blob, filename);
39+
}
40+
3441
export function downloadJsonData(jsonData: any, filename = 'file.json', type = 'application/json') {
3542
const blob = new Blob([JSON.stringify(jsonData)], {
3643
type: type

‎general.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function formatBytes(bytes: number, decimals = 2) {
117117
export type enumToArrayOptions = {
118118
caseType?: caseType;
119119
prefix?: string;
120-
nameFunction?: (name: string) => string;
120+
nameFunction?: (name: any) => string;
121121
}
122122

123123
export function enumToArray(e: Object, options: enumToArrayOptions | null = null): any[] {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /