From fe01eb46c37e9c91842bfd092f761eb97e75e162 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 6 Jun 2024 11:09:20 +0200 Subject: [PATCH] more testing --- .../cmd/GbtTranslateBatchCommand.java | 4 ++-- .../cmd/GptTranslateCommand.java | 2 +- .../output/PromptGenerator.java | 8 +++---- .../impl/german/GermanPromptGenerator.java | 7 +----- .../impl/spanish/PpktIndividualSpanish.java | 22 +++++++++++-------- .../german/GermanPromptGeneratorTest.java | 2 +- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java index 61604fd..438eb16 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java @@ -78,12 +78,12 @@ public Integer call() throws Exception { outputPromptsInternational(ppktFiles, hpo, "nl", dutch); // GERMAN resetOutput("de"); - PromptGenerator german = PromptGenerator.german(hpo, internationalMap.get("de")); + PromptGenerator german = PromptGenerator.german(internationalMap.get("de")); outputPromptsInternational(ppktFiles, hpo, "de", german); // ITALIAN resetOutput("it"); - PromptGenerator italian = PromptGenerator.italian(hpo, internationalMap.get("it")); + PromptGenerator italian = PromptGenerator.italian(internationalMap.get("it")); outputPromptsInternational(ppktFiles, hpo, "it", italian); resetOutput("finished"); diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GptTranslateCommand.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GptTranslateCommand.java index c8ff10f..542d166 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GptTranslateCommand.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GptTranslateCommand.java @@ -63,7 +63,7 @@ public Integer call() throws Exception { System.out.println(prompt); switch (languageCode) { case "de" -> { - PromptGenerator german = PromptGenerator.german(hpo, internationalMap.get("de")); + PromptGenerator german = PromptGenerator.german(internationalMap.get("de")); prompt = german.createPrompt(individual); } case "es" -> { diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java index cc42783..a000fca 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java @@ -45,13 +45,13 @@ static PromptGenerator dutch(Ontology hpo, HpInternational international) { return new DutchPromptGenerator(hpo, pfgen); } - static PromptGenerator german(Ontology hpo, HpInternational international) { + static PromptGenerator german(HpInternational international) { PpktPhenotypicFeatureGenerator pfgen = new PpktPhenotypicfeatureGerman(international); - return new GermanPromptGenerator(hpo, pfgen); + return new GermanPromptGenerator(pfgen); } - static PromptGenerator italian(Ontology hpo, HpInternational international) { + static PromptGenerator italian(HpInternational international) { PpktPhenotypicFeatureGenerator pfgen = new PpktPhenotypicfeatureItalian(international); - return new ItalianPromptGenerator(hpo, pfgen); + return new ItalianPromptGenerator(pfgen); } diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java index 48ce39c..74c700c 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java @@ -1,6 +1,5 @@ package org.monarchinitiative.phenopacket2prompt.output.impl.german; -import org.monarchinitiative.phenol.ontology.data.Ontology; import org.monarchinitiative.phenopacket2prompt.model.OntologyTerm; import org.monarchinitiative.phenopacket2prompt.model.PhenopacketAge; import org.monarchinitiative.phenopacket2prompt.model.PhenopacketSex; @@ -15,9 +14,6 @@ public class GermanPromptGenerator implements PromptGenerator { - private final Ontology hpo; - - private final PPKtIndividualInfoGenerator ppktAgeSexGenerator; private final PhenopacketTextGenerator ppktTextGenerator; @@ -26,8 +22,7 @@ public class GermanPromptGenerator implements PromptGenerator { - public GermanPromptGenerator(Ontology hpo, PpktPhenotypicFeatureGenerator pfgen) { - this.hpo = hpo; + public GermanPromptGenerator(PpktPhenotypicFeatureGenerator pfgen) { ppktAgeSexGenerator = new PpktIndividualGerman(); ppktTextGenerator = new PpktTextGerman(); this.ppktPhenotypicFeatureGenerator = pfgen; diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/spanish/PpktIndividualSpanish.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/spanish/PpktIndividualSpanish.java index 0f91cfe..383cec3 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/spanish/PpktIndividualSpanish.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/spanish/PpktIndividualSpanish.java @@ -321,7 +321,7 @@ private String hpoOnsetIndividualDescription(PhenopacketSex psex, HpoOnsetAge hp /** * A sentence such as The proband was a 39-year old woman who presented at the age of 12 years with * HPO1, HPO2, and HPO3. HPO4 and HPO5 were excluded. This method returns the phrase that ends with "with" - * El sujeto era un niño de 1 año y 10 meses que se presentaba como recién nacido con un filtrum largo. + * El sujeto era un niño de 1 año y 10 meses que se presentó como recién nacido con un filtrum largo. * @param psex * @param lastExamAge * @param onsetAge @@ -351,9 +351,9 @@ private String onsetAndLastEncounterAvailable(PhenopacketSex psex, PhenopacketAg throw new PhenolRuntimeException("Did not recognize onset age type " + onsetAge.ageType()); } return switch (psex){ - case FEMALE -> String.format("La paciente era %s que se presentaba %s con", individualDescription, onsetDescription); - case MALE -> String.format("El paciente era %s que se presentaba %s con", individualDescription, onsetDescription); - default -> String.format("El paciente era %s que se presentaba %s con", individualDescription, onsetDescription); + case FEMALE -> String.format("La paciente era %s que se presentó %s con", individualDescription, onsetDescription); + case MALE -> String.format("El paciente era %s que se presentó %s con", individualDescription, onsetDescription); + default -> String.format("El paciente era %s que se presentó %s con", individualDescription, onsetDescription); }; } @@ -379,7 +379,11 @@ private String lastEncounterAvailable(PhenopacketSex psex, PhenopacketAge lastEx // should never happen throw new PhenolRuntimeException("Did not recognize last exam age type " + lastExamAge.ageType()); } - return String.format("El paciente era %s quien se presentaba con", individualDescription); + if (psex.equals(PhenopacketSex.FEMALE)) { + return String.format("La paciente era %s que se presentó con", individualDescription); + } else { + return String.format("El paciente era %s qui se presentó con", individualDescription); + } } /** @@ -401,14 +405,14 @@ private String onsetAvailable(PhenopacketSex psex, PhenopacketAge onsetAge) { // should never happen throw new PhenolRuntimeException("Did not recognize onset age type " + onsetAge.ageType()); } - return String.format("El paciente se presentaba %s con", onsetDescription); + return String.format("El paciente se presentó %s con", onsetDescription); } private String ageNotAvailable(PhenopacketSex psex) { return switch (psex) { - case FEMALE -> "La paciente se presentaba con"; - case MALE -> "El paciente se presentaba con"; - default -> "El paciente se presentaba con"; + case FEMALE -> "La paciente se presentó con"; + case MALE -> "El paciente se presentó con"; + default -> "El paciente se presentó con"; }; } diff --git a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java index afde6be..4363a91 100644 --- a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java +++ b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java @@ -33,7 +33,7 @@ public void testCase() { } HpInternationalOboParser oboParser = new HpInternationalOboParser(translationsFile); Map internationalMap = oboParser.getLanguageToInternationalMap(); - PromptGenerator german = PromptGenerator.german(hpo, internationalMap.get("de")); + PromptGenerator german = PromptGenerator.german(internationalMap.get("de")); String prompt = german.createPrompt(twoYears());