Skip to content

Commit 383aa39

Browse files
authored
fix: Fix #64, #66, #67 (#72)
* fix #64 * fixes #66 * fix for #67
1 parent 31cebea commit 383aa39

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"fast-json-patch": "^3.0.0-1",
7474
"ffmpeg-static": "^4.0.1",
7575
"in-browser-download": "^2.0.0",
76-
"jac-format": "^1.0.7",
76+
"jac-format": "^1.1.0",
7777
"js-md5": "^0.7.3",
7878
"moment": "^2.24.0",
7979
"posthog-js": "^1.0.4",

src/components/ImageClassification/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default ({
139139
if (iface.allowMultiple) {
140140
newOutput = currentOutput.concat([label.id])
141141
} else {
142-
newOutput = [label.id]
142+
newOutput = label.id
143143
}
144144
}
145145

src/components/PasteUrlsDialog/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export default ({ open, onClose, onAddSamples }) => {
2525
.map((l) => l.trim())
2626
.filter(Boolean)
2727
.map((s) => {
28-
const extension = s.split(".").slice(-1)[0]
28+
const extension = s
29+
.replace(/\?.*/g, "")
30+
.split(".")
31+
.slice(-1)[0]
2932
switch (extension.toLowerCase()) {
3033
case "png":
3134
case "jpg":

src/utils/from-udt-csv.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
11
import JAC from "jac-format"
22

3+
const alternativeSpellings = {
4+
imageUrl: [
5+
"image_url",
6+
"image_urls",
7+
"image",
8+
"image_src",
9+
"img_url",
10+
"img",
11+
"img_src",
12+
],
13+
document: ["text"],
14+
}
15+
const badSpellingMap = {}
16+
for (const [correct, badSpellings] of Object.entries(alternativeSpellings)) {
17+
for (const badSpelling of badSpellings) {
18+
badSpellingMap[badSpelling] = correct
19+
}
20+
}
21+
22+
const convertTaskDatumMistakes = (sample) => {
23+
for (const key in sample) {
24+
const normalizedKey = key.toLowerCase().replace(/ /g, "_")
25+
const correction = badSpellingMap[normalizedKey]
26+
if (correction) {
27+
sample[correction] = sample[key]
28+
delete sample[key]
29+
}
30+
}
31+
return sample
32+
}
33+
334
export default (csv) => {
4-
const json = JAC.fromCSV(csv)
35+
const json = JAC.fromCSV(csv, { derivePath: () => "samples.*" })
36+
if (!json.samples) throw new Error("No samples")
537
return {
638
interface: json.interface,
739
taskOutput: json.samples.map((sample) => sample.output),
8-
taskData: json.samples.map((sample) => {
40+
taskData: json.samples.map(convertTaskDatumMistakes).map((sample) => {
941
delete sample.output
1042
return sample
1143
}),

0 commit comments

Comments
 (0)