Skip to content

Commit b2acc13

Browse files
committed
[Import] Fix
1 parent 3eecf0a commit b2acc13

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

src/ts/dataImport/importers/characterBoxes/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ export const characterBoxParsers: Ref<ImportConfig<ImportCharacterBoundingBoxDto
3131
// TODO: Set to -1 as soon as best parser selection is implemented
3232
export const selectedCharacterBoxParserIndex = ref( 1 );
3333

34+
export const currentTextLang: {
35+
'lang': string
36+
} = {
37+
'lang': 'undefined'
38+
};
39+
3440
export const importBoundingBoxes = async ( boundingBoxesCSVElement: HTMLInputElement, textId: string ): Promise<{
3541
'characters': ImportCharacterBoundingBoxDto[],
36-
'words': ImportWordBoundingBoxDto[]
42+
'words': ImportWordBoundingBoxDto[],
43+
'lang': string
3744
}> => {
3845
let cbb: ImportCharacterBoundingBoxDto[] = [];
3946

@@ -45,6 +52,7 @@ export const importBoundingBoxes = async ( boundingBoxesCSVElement: HTMLInputEle
4552

4653
return {
4754
'characters': cbb,
48-
'words': generateWordBoxesFromCharacterBoxes( cbb )
55+
'words': generateWordBoxesFromCharacterBoxes( cbb ),
56+
'lang': currentTextLang.lang
4957
};
5058
};

src/ts/dataImport/importers/characterBoxes/multipleTextsPerFile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import type {
1212
import type {
1313
ImportConfig
1414
} from '@/types/import';
15+
import {
16+
currentTextLang
17+
} from '.';
1518
import {
1619
fileLoaderString
1720
} from '../../util/fileLoader';
@@ -44,6 +47,7 @@ const runParse = async ( data: string, textId: string ): Promise<ImportCharacter
4447
const cols = conf.lines[i]!.split( ',' );
4548

4649
if ( cols[conf.textIndex] === textId ) {
50+
currentTextLang.lang = conf.langIndex > -1 ? cols[conf.langIndex]! : 'undefined';
4751
const x1 = Number( cols[conf.xMinIndex] );
4852
const x2 = Number( cols[conf.xMaxIndex] );
4953
const y1 = Number( cols[conf.yMinIndex] );

src/ts/dataImport/importers/characterBoxes/preprocessor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export const boundingBoxesOpts: ParserOptsList<unknown> = {
1212
'value': 'character',
1313
'input': 'string'
1414
},
15+
'lang': {
16+
'display': 'Language',
17+
'value': 'lang',
18+
'input': 'string'
19+
},
1520
'xMin': {
1621
'display': 'Lower X Coordiante',
1722
'value': 'bbox_x1',
@@ -43,6 +48,7 @@ export const preprocessor = (
4348
.map( h => h.trim() );
4449
const charIndex = header.indexOf( opts.char!.value as string );
4550
const textIndex = opts.textID ? header.indexOf( opts.textID.value as string ) : -1;
51+
const langIndex = header.indexOf( opts.lang!.value as string );
4652
const xMinIndex = header.indexOf( opts.xMin!.value as string );
4753
const xMaxIndex = header.indexOf( opts.xMax!.value as string );
4854
const yMinIndex = header.indexOf( opts.yMin!.value as string );
@@ -63,6 +69,7 @@ export const preprocessor = (
6369
lines,
6470
charIndex,
6571
textIndex,
72+
langIndex,
6673
xMinIndex,
6774
xMaxIndex,
6875
yMinIndex,

src/ts/dataImport/importers/fixations/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export const usePointAdder = (
116116
'textForeignId': Number( textId ),
117117
'readerForeignId': Number( reader ),
118118
'fixations': [],
119-
'preAnnotations': []
119+
'preAnnotations': [],
120+
'language': indices.langIndex > -1 ? cols[ indices.langIndex ]! : 'undefined'
120121
};
121122
}
122123

src/ts/dataImport/importers/text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const importText = async (
2222
return {
2323
'title': textName,
2424
'backgroundImage': uint8ArrayToBase64( await ( await loadFileFromDisk( image ) ).bytes() ),
25-
'language': 'undefined', // TODO: language selection
25+
'language': boundingBoxes.lang,
2626
'characterBoundingBoxes': boundingBoxes.characters,
2727
'wordBoundingBoxes': boundingBoxes.words,
2828
'foreignId': Number( textId )

0 commit comments

Comments
 (0)