@@ -2,16 +2,6 @@ import {
22 fileLoaderString ,
33 loadAllFilesOfElementAsStringWithCallback
44} from '../../util/fileLoader' ;
5- import {
6- boundingBoxesOpts
7-
8- } from './util' ;
9- import {
10- createUidLookupMap
11- } from '../../util/char_text_map' ;
12- import {
13- determineCorrectParserSettings
14- } from '../../util/parserSettingsGenerator' ;
155import type {
166 ImportCharacterBoundingBoxDto
177} from '@/types/dtos/ImportCharacterBoundingBoxDto' ;
@@ -21,8 +11,17 @@ import type {
2111import {
2212 MissingFilesError
2313} from '../../util/errors' ;
14+ import {
15+ boundingBoxesOpts
16+ } from './util' ;
17+ import {
18+ createUidLookupMap
19+ } from '../../util/char_text_map' ;
20+ import {
21+ determineCorrectParserSettings
22+ } from '../../util/parserSettingsGenerator' ;
2423
25- export const boundingBoxImporter : ImportConfig < ImportCharacterBoundingBoxDto [ ] > = {
24+ export const uidBasedCharacterBoundingBoxImporter : ImportConfig < ImportCharacterBoundingBoxDto [ ] > = {
2625 'display' : 'Text UID based Bounding Box Creation ' ,
2726 'options' : {
2827 ...boundingBoxesOpts ,
@@ -49,19 +48,14 @@ export const boundingBoxImporter: ImportConfig<ImportCharacterBoundingBoxDto[]>
4948 'display' : 'Text ID' , // TODO: Update name, this is for texts.csv file
5049 'value' : 'text_id' ,
5150 'input' : 'string'
52- } ,
53- 'assLang' : {
54- 'display' : 'Language' , // TODO: Update name, this is for texts.csv file
55- 'value' : 'lang' ,
56- 'input' : 'string'
5751 }
5852 } ,
5953 'parse' : async ( inputElement : HTMLInputElement , _textId : string , lang : string ) : Promise < ImportCharacterBoundingBoxDto [ ] > => {
6054 if ( ! inputElement . files || ! inputElement . files [ 0 ] ) throw new MissingFilesError ( ) ;
6155
62- const assocFile = boundingBoxImporter . options . association ?. value as File | null ;
63- const uidCol = boundingBoxImporter . options . assTextUID ?. value as string | undefined ;
64- const idCol = boundingBoxImporter . options . assTextID ?. value as string | undefined ;
56+ const assocFile = uidBasedCharacterBoundingBoxImporter . options . association ?. value as File | null ;
57+ const uidCol = uidBasedCharacterBoundingBoxImporter . options . assTextUID ?. value as string | undefined ;
58+ const idCol = uidBasedCharacterBoundingBoxImporter . options . assTextID ?. value as string | undefined ;
6559
6660 if ( ! assocFile || ! uidCol || ! idCol ) {
6761 throw new MissingFilesError ( ) ;
@@ -78,7 +72,7 @@ export const boundingBoxImporter: ImportConfig<ImportCharacterBoundingBoxDto[]>
7872 await loadAllFilesOfElementAsStringWithCallback ( inputElement , async ( data : string ) => {
7973 const lines = data . split ( / \r ? \n / ) . filter ( l => l . trim ( ) !== '' ) ;
8074 const header = lines . shift ( ) ! . split ( ',' ) . map ( h => h . trim ( ) ) ;
81- const textUidIndex = header . indexOf ( boundingBoxImporter . options . textuid ! . value as string ) ;
75+ const textUidIndex = header . indexOf ( uidBasedCharacterBoundingBoxImporter . options . textuid ! . value as string ) ;
8276 const charIndex = header . indexOf ( boundingBoxesOpts . char ! . value as string ) ;
8377 const xMinIndex = header . indexOf ( boundingBoxesOpts . xMin ! . value as string ) ;
8478 const xMaxIndex = header . indexOf ( boundingBoxesOpts . xMax ! . value as string ) ;
@@ -124,6 +118,6 @@ export const boundingBoxImporter: ImportConfig<ImportCharacterBoundingBoxDto[]>
124118 return boundingBoxStore ;
125119 } ,
126120 'canParse' : ( header : string [ ] ) => {
127- return determineCorrectParserSettings ( header , boundingBoxImporter ) ;
121+ return determineCorrectParserSettings ( header , uidBasedCharacterBoundingBoxImporter ) ;
128122 }
129- } ;
123+ } ;
0 commit comments