@@ -460,27 +460,15 @@ bool inference
460460 ) ;
461461 }
462462
463- var sourceFileConfig = new List < TranslationCorpusFileConfig > ( ) ;
464-
465- if ( sourceLanguage == targetLanguage && ! inference )
466- {
467- // if it's the same language, and we are not pretranslating, do nothing (echo for suggestions)
468- // if pretranslating, we need to upload the source separately
469- // if different languages, we are not echoing.
470- }
471- else
472- {
473- sourceFileConfig . AddRange (
474- sourceFiles . Select ( ( s , i ) => new TranslationCorpusFileConfig { FileId = s . Id , TextId = filesToAdd [ i ] } )
475- ) ;
476- }
477-
478463 TranslationCorpus response = await TranslationEnginesClient . AddCorpusAsync (
479464 id : engineId ,
480465 new TranslationCorpusConfig
481466 {
482467 Name = "None" ,
483- SourceFiles = sourceFileConfig ,
468+ SourceFiles =
469+ [
470+ .. sourceFiles . Select ( ( s , i ) => new TranslationCorpusFileConfig { FileId = s . Id , TextId = filesToAdd [ i ] } )
471+ ] ,
484472 SourceLanguage = sourceLanguage ,
485473 TargetFiles = targetFileConfig ,
486474 TargetLanguage = targetLanguage
@@ -526,29 +514,17 @@ bool inference
526514 Corpus ? targetCorpus =
527515 targetCorpusConfig . Files . Count > 0 ? await CorporaClient . CreateAsync ( targetCorpusConfig ) : null ;
528516
529- var sourceFileConfig = new List < CorpusFileConfig > ( ) ;
530-
531- if ( sourceLanguage == targetLanguage && ! inference )
532- {
533- // if it's the same language, and we are not pretranslating, do nothing (echo for suggestions)
534- // if pretranslating, we need to upload the source separately
535- // if different languages, we are not echoing.
536- }
537- else
538- {
539- DataFile sourceFile = await DataFilesClient . CreateAsync (
540- file : new FileParameter ( data : File . OpenRead ( sourceZipFile ) , fileName : Path . GetFileName ( sourceZipFile ) ) ,
541- format : FileFormat . Paratext ,
542- name : $ "{ _prefix } { sourceLanguage } _zip"
543- ) ;
544- sourceFileConfig . Add ( new CorpusFileConfig { FileId = sourceFile . Id , TextId = "test_data" } ) ;
545- }
517+ DataFile sourceFile = await DataFilesClient . CreateAsync (
518+ file : new FileParameter ( data : File . OpenRead ( sourceZipFile ) , fileName : Path . GetFileName ( sourceZipFile ) ) ,
519+ format : FileFormat . Paratext ,
520+ name : $ "{ _prefix } { sourceLanguage } _zip"
521+ ) ;
546522
547523 var sourceCorpusConfig = new CorpusConfig ( )
548524 {
549525 Name = $ "{ _prefix } Source",
550526 Language = sourceLanguage ,
551- Files = sourceFileConfig
527+ Files = [ new CorpusFileConfig { FileId = sourceFile . Id , TextId = "test_data" } ]
552528 } ;
553529
554530 Corpus sourceCorpus = await CorporaClient . CreateAsync ( sourceCorpusConfig ) ;
@@ -588,26 +564,11 @@ bool inference
588564 Corpus ? targetCorpus =
589565 targetCorpusConfig . Files . Count > 0 ? await CorporaClient . CreateAsync ( targetCorpusConfig ) : null ;
590566
591- var sourceFileConfig = new List < CorpusFileConfig > ( ) ;
592-
593- if ( sourceLanguage == targetLanguage && ! inference )
594- {
595- // if it's the same language, and we are not pretranslating, do nothing (echo for suggestions)
596- // if pretranslating, we need to upload the source separately
597- // if different languages, we are not echoing.
598- }
599- else
600- {
601- sourceFileConfig . AddRange (
602- sourceFiles . Select ( ( s , i ) => new CorpusFileConfig { FileId = s . Id , TextId = filesToAdd [ i ] } )
603- ) ;
604- }
605-
606567 var sourceCorpusConfig = new CorpusConfig ( )
607568 {
608569 Name = $ "{ _prefix } Source",
609570 Language = sourceLanguage ,
610- Files = sourceFileConfig
571+ Files = [ .. sourceFiles . Select ( ( s , i ) => new CorpusFileConfig { FileId = s . Id , TextId = filesToAdd [ i ] } ) ]
611572 } ;
612573
613574 Corpus sourceCorpus = await CorporaClient . CreateAsync ( sourceCorpusConfig ) ;
0 commit comments