Skip to content

Commit

Permalink
Merge pull request #13 from monarch-initiative/nl-translation
Browse files Browse the repository at this point in the history
NL Translation
  • Loading branch information
leokim-l authored May 17, 2024
2 parents 96f2b6b + a226a60 commit 47da699
Show file tree
Hide file tree
Showing 8 changed files with 718 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ public Integer call() throws Exception {
// output all non-English languages here
PromptGenerator spanish = PromptGenerator.spanish(hpo, internationalMap.get("es"));
outputPromptsInternational(ppktFiles, hpo, "es", spanish);

PromptGenerator dutch = PromptGenerator.dutch(hpo, internationalMap.get("nl"));
outputPromptsInternational(ppktFiles, hpo, "nl", dutch);

PromptGenerator german = PromptGenerator.german(hpo, internationalMap.get("de"));
outputPromptsInternational(ppktFiles, hpo, "de", german);

// output file with correct diagnosis list
outputCorrectResults(correctResultList);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,22 @@ public Integer call() throws Exception {
PpktIndividual individual = new PpktIndividual(new File(ppkt));
String prompt = generator.createPrompt(individual);
System.out.println(prompt);
// SPANISH
System.out.println("SPANISH");
PromptGenerator spanish = PromptGenerator.spanish(hpo, internationalMap.get("es"));
prompt = spanish.createPrompt(individual);
System.out.println(prompt);

// DUTCH
System.out.println("DUTCH");
PromptGenerator dutch = PromptGenerator.dutch(hpo, internationalMap.get("nl"));
prompt = dutch.createPrompt(individual);

// GERMAN
System.out.println("GERMAN");
PromptGenerator german = PromptGenerator.spanish(hpo, internationalMap.get("de"));
prompt = german.createPrompt(individual);

System.out.println(prompt);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.monarchinitiative.phenopacket2prompt.output.impl.german.GermanPromptGenerator;
import org.monarchinitiative.phenopacket2prompt.output.impl.german.PpktPhenotypicfeatureGerman;
import org.monarchinitiative.phenopacket2prompt.output.impl.spanish.*;
import org.monarchinitiative.phenopacket2prompt.output.impl.dutch.*;

import java.util.List;
import java.util.Map;
Expand All @@ -35,11 +36,18 @@ static PromptGenerator spanish(Ontology hpo, HpInternational international) {
return new SpanishPromptGenerator(hpo, pfgen);
}


static PromptGenerator dutch(Ontology hpo, HpInternational international) {
PpktPhenotypicFeatureGenerator pfgen = new PpktPhenotypicfeatureDutch(international);
return new DutchPromptGenerator(hpo, pfgen);
}

static PromptGenerator german(Ontology hpo, HpInternational international) {
PpktPhenotypicFeatureGenerator pfgen = new PpktPhenotypicfeatureGerman(international);
return new GermanPromptGenerator(hpo, pfgen);
}


/**
* The following structure should work for most other languages, but the function
* can be overridden if necessary.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.monarchinitiative.phenopacket2prompt.output.impl.dutch;

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;
import org.monarchinitiative.phenopacket2prompt.model.PpktIndividual;
import org.monarchinitiative.phenopacket2prompt.output.PhenopacketIndividualInformationGenerator;
import org.monarchinitiative.phenopacket2prompt.output.PhenopacketTextGenerator;
import org.monarchinitiative.phenopacket2prompt.output.PpktPhenotypicFeatureGenerator;
import org.monarchinitiative.phenopacket2prompt.output.PromptGenerator;
import org.monarchinitiative.phenopacket2prompt.output.impl.dutch.PpktIndividualDutch;
import org.monarchinitiative.phenopacket2prompt.output.impl.dutch.PpktTextDutch;

import java.util.List;

public class DutchPromptGenerator implements PromptGenerator {

private final Ontology hpo;


private final PhenopacketIndividualInformationGenerator ppktAgeSexGenerator;

private final PhenopacketTextGenerator ppktTextGenerator;

private final PpktPhenotypicFeatureGenerator ppktPhenotypicFeatureGenerator;



public DutchPromptGenerator(Ontology hpo, PpktPhenotypicFeatureGenerator pfgen) {
this.hpo = hpo;
ppktAgeSexGenerator = new PpktIndividualDutch();
ppktTextGenerator = new PpktTextDutch();
this.ppktPhenotypicFeatureGenerator = pfgen;
}

@Override
public String queryHeader() {
return ppktTextGenerator.QUERY_HEADER();
}

@Override
public String getIndividualInformation(PpktIndividual ppktIndividual) {
return this.ppktAgeSexGenerator.getIndividualDescription(ppktIndividual);
}

@Override
public String formatFeatures(List<OntologyTerm> ontologyTerms) {
return ppktPhenotypicFeatureGenerator.formatFeatures(ontologyTerms);
}

@Override
public String getVignetteAtAge(PhenopacketAge page, PhenopacketSex psex, List<OntologyTerm> terms) {
String ageString = this.ppktAgeSexGenerator.atAge(page);
String features = formatFeatures(terms);
return String.format("%s, %s presenteerde met %s", ageString, ppktAgeSexGenerator.heSheIndividual(psex), features);
}

}
Loading

0 comments on commit 47da699

Please sign in to comment.