Skip to content

Commit 2334941

Browse files
committed
Fixed schemaless prints
1 parent b25532e commit 2334941

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

translate.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,9 +1852,7 @@ func Translate(ctx context.Context, inputStandard string, inputValue []byte, inp
18521852
return []byte{}, err
18531853
}
18541854

1855-
//log.Printf("\n\nFOUND SUBSTANDARD (%s): %v\n\n", standardName, string(subStandard))
18561855
// FIXME: Find the list in the inputdata. Map each item to the substandard, and then return the list
1857-
18581856
foundConfig := ""
18591857
if len(inputConfig) > 0 {
18601858
foundConfig = inputConfig[0]
@@ -1884,7 +1882,6 @@ func Translate(ctx context.Context, inputStandard string, inputValue []byte, inp
18841882
return []byte{}, err
18851883
}
18861884

1887-
//log.Printf("\n\n[DEBUG] GPT translated: %v. Should save this to file in folder 'examples' with filename %s\n\n", string(gptTranslated), keyTokenFile)
18881885
err = SaveTranslation(keyTokenFile, gptTranslated, shuffleConfig)
18891886
if err != nil {
18901887
log.Printf("[ERROR] Schemaless: Problem in SaveTranslation (3): %v", err)
@@ -1899,41 +1896,28 @@ func Translate(ctx context.Context, inputStandard string, inputValue []byte, inp
18991896
err = SetStructureCache(ctx, keyToken, inputStructure)
19001897
if err != nil {
19011898
log.Printf("[WARNING] Schemaless: problem in SetStructureCache for keyToken %#v with inputStructure %#v: %v", keyToken, inputStructure, err)
1902-
//return []byte{}, err
19031899
}
19041900

1905-
// This has a failure condition of cache being unavailable
1906-
// More complex possibilities for failure (:
19071901
returnStructure, cacheErr := GetStructureFromCache(ctx, keyToken)
19081902
if cacheErr != nil {
19091903
log.Printf("[WARNING] Schemaless: problem in return structure for keyToken %#v. Should run ai and set cache!", keyToken)
19101904

19111905
returnStructure = map[string]interface{}{}
1912-
err = json.Unmarshal(inputStructure, &returnStructure)
1906+
fixedCache := FixTranslationStructure(string(inputStructure))
1907+
err = json.Unmarshal([]byte(fixedCache), &returnStructure)
19131908
if err != nil {
19141909
log.Printf("[ERROR] Schemaless: Error in unmarshal of returnStructure from cache for keyToken (2) %#v: %v", keyToken, err)
19151910
//return []byte{}, err
19161911
}
19171912
}
19181913

1919-
//marshalledReturn, err := json.MarshalIndent(returnStructure, "", "\t")
1920-
//if err == nil {
1921-
// log.Printf("MarshalledRet: %s", string(marshalledReturn))
1922-
//}
1923-
//log.Printf("[DEBUG] Structure received: %v", returnStructure)
1924-
//log.Printf("Startvalue (len(%d)): %s", len(startValue), string(startValue))
19251914
translation, modifiedInput, err := runJsonTranslation(ctx, []byte(startValue), returnStructure, keepOriginal)
19261915
if err != nil {
19271916
log.Printf("[ERROR] Error in runJsonTranslation: %v", err)
19281917
return translation, err
19291918
}
19301919

1931-
//log.Printf("[DEBUG] Schemaless: Final translation output: %s", string(translation))
1932-
//os.Exit(3)
1933-
19341920
_ = modifiedInput
1935-
//log.Printf("translation: %v", string(translation))
1936-
//log.Printf("modifiedInput: %v", string(modifiedInput))
19371921

19381922
return translation, nil
19391923
}

0 commit comments

Comments
 (0)