Skip to content

Commit

Permalink
more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pnrobinson committed Jun 6, 2024
1 parent f1376cd commit fe01eb4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,9 +14,6 @@

public class GermanPromptGenerator implements PromptGenerator {

private final Ontology hpo;


private final PPKtIndividualInfoGenerator ppktAgeSexGenerator;

private final PhenopacketTextGenerator ppktTextGenerator;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
};
}

Expand All @@ -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);
}
}

/**
Expand All @@ -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";
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void testCase() {
}
HpInternationalOboParser oboParser = new HpInternationalOboParser(translationsFile);
Map<String, HpInternational> internationalMap = oboParser.getLanguageToInternationalMap();
PromptGenerator german = PromptGenerator.german(hpo, internationalMap.get("de"));
PromptGenerator german = PromptGenerator.german(internationalMap.get("de"));
String prompt = german.createPrompt(twoYears());


Expand Down

0 comments on commit fe01eb4

Please sign in to comment.