diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java index 4a9c0bb..4f0dd2f 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/GbtTranslateBatchCommand.java @@ -75,9 +75,12 @@ public Integer call() throws Exception { // ITALIAN PromptGenerator italian = utility.italian(); Utility.outputPromptsInternational(ppktFiles,"it", italian); - + //Turkish PromptGenerator turkish = utility.turkish(); Utility.outputPromptsInternational(ppktFiles,"tr", turkish); + // chinese + PromptGenerator chinese = utility.chinese(); + Utility.outputPromptsInternational(ppktFiles,"zh", chinese); // output original phenopackets PpktCopy pcopy = new PpktCopy(new File(outdirname)); diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/Utility.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/Utility.java index 527cf93..bb8253e 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/Utility.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/cmd/Utility.java @@ -62,6 +62,9 @@ public PromptGenerator italian() { return PromptGenerator.italian(internationalMap.get("it")); } + public PromptGenerator chinese() { + return PromptGenerator.chinese(internationalMap.get("zh")); + } public static String getFileName(String phenopacketID, String languageCode) { diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/Chinese b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/Chinese deleted file mode 100644 index 8b13789..0000000 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/Chinese +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java index 329e347..843a683 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PromptGenerator.java @@ -13,6 +13,7 @@ import org.monarchinitiative.phenopacket2prompt.output.impl.italian.*; import org.monarchinitiative.phenopacket2prompt.output.impl.turkish.PpktPhenotypicfeatureTurkish; import org.monarchinitiative.phenopacket2prompt.output.impl.turkish.TurkishPromptGenerator; +import org.monarchinitiative.phenopacket2prompt.output.impl.chinese.*; import java.util.List; @@ -67,6 +68,11 @@ static PromptGenerator turkish(HpInternational international) { return new TurkishPromptGenerator(pfgen); } + static PromptGenerator chinese(HpInternational international) { + PpktPhenotypicFeatureGenerator pfgen = new PpktPhenotypicfeatureChinese(international); + return new ChinesePromptGenerator(pfgen); + } + /** * The following structure should work for most other languages, but the function diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/ChinesePromptGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/ChinesePromptGenerator.java deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/ChineseBuildingBlocks.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChineseBuildingBlocks.java similarity index 98% rename from src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/ChineseBuildingBlocks.java rename to src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChineseBuildingBlocks.java index f353029..95a34b4 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/ChineseBuildingBlocks.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChineseBuildingBlocks.java @@ -323,4 +323,9 @@ public String asLateOnset() { public String fromIso(Iso8601Age ppktAge) { return ""; } + + @Override + public String duringEmbryonic() { + return ""; + } } \ No newline at end of file diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChinesePromptGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChinesePromptGenerator.java new file mode 100644 index 0000000..c6177cf --- /dev/null +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChinesePromptGenerator.java @@ -0,0 +1,104 @@ +package org.monarchinitiative.phenopacket2prompt.output.impl.chinese; + +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.PPKtIndividualInfoGenerator; +import org.monarchinitiative.phenopacket2prompt.output.PhenopacketTextGenerator; +import org.monarchinitiative.phenopacket2prompt.output.PpktPhenotypicFeatureGenerator; +import org.monarchinitiative.phenopacket2prompt.output.PromptGenerator; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ChinesePromptGenerator implements PromptGenerator { + + private final PPKtIndividualInfoGenerator ppktAgeSexGenerator; + + private final PhenopacketTextGenerator ppktTextGenerator; + + private final PpktPhenotypicFeatureGenerator ppktPhenotypicFeatureGenerator; + + + + public ChinesePromptGenerator(PpktPhenotypicFeatureGenerator pfgen) { + ppktAgeSexGenerator = new PpktIndividualChinese(); + ppktTextGenerator = new PpktTextChinese(); + this.ppktPhenotypicFeatureGenerator = pfgen; + } + + + + + @Override + public String queryHeader() { + return ppktTextGenerator.GPT_PROMPT_HEADER(); + } + + @Override + public String getIndividualInformation(PpktIndividual ppktIndividual) { + return this.ppktAgeSexGenerator.getIndividualDescription(ppktIndividual); + } + + @Override + public String formatFeatures(List ontologyTerms) { + return ppktPhenotypicFeatureGenerator.formatFeatures(ontologyTerms); + } + + @Override + public String getVignetteAtAge(PhenopacketAge page, PhenopacketSex psex, List terms) { + String ageString = this.ppktAgeSexGenerator.atAgeForVignette(page); + String person = switch (psex) { + case MALE -> "er"; + case FEMALE -> "sie"; + default -> "die betroffene Person"; + }; + return this.ppktPhenotypicFeatureGenerator.featuresAtEncounter(person, ageString, terms); + } + + @Override + public String getVignetteAtOnset(PpktIndividual individual){ + String person = switch (individual.getSex()) { + case MALE -> "Er"; + case FEMALE -> "Sie"; + default -> "Die betroffene Person"; + }; + return this.ppktPhenotypicFeatureGenerator.featuresAtOnset(person, individual.getPhenotypicFeaturesAtOnset()); + } + + + + @Override + public Set getMissingTranslations() { + return this.ppktPhenotypicFeatureGenerator.getMissingTranslations(); + } + + /** + * The following structure should work for most other languages, but the function + * can be overridden if necessary. + * @param individual The individual for whom we are creating the prompt + * @return the prompt text + */ + @Override + public String createPrompt(PpktIndividual individual) { + String individualInfo = getIndividualInformation(individual); + // For creating the prompt, we first report the onset and the unspecified terms together, and then + String onsetDescription = getVignetteAtOnset(individual); + Map> pfMap = individual.extractSpecifiedAgePhenotypicFeatures(); + // We then report the rest, one for each specified time + //String onsetFeatures = formatFeatures(onsetTerms); + StringBuilder sb = new StringBuilder(); + sb.append(queryHeader()); + sb.append(individualInfo).append("\n").append(onsetDescription).append("\n"); + for (var entry: pfMap.entrySet()) { + String vignette = getVignetteAtAge(entry.getKey(), individual.getSex(), entry.getValue()); + sb.append(vignette).append("\n"); + } + return sb.toString(); + } + + + +} diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktIndividualChinese.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktIndividualChinese.java similarity index 99% rename from src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktIndividualChinese.java rename to src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktIndividualChinese.java index d3429f0..923fd42 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktIndividualChinese.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktIndividualChinese.java @@ -304,7 +304,7 @@ private String dAlter(Iso8601Age iso8601Age, GrammatikalischesGeschlecht geschle case NEUTRUM -> String.format("%s altes", ymd); }; */ - return String.format("%s时",ymd) + return String.format("%s时",ymd); } diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktPhenotypicfeatureChinese.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktPhenotypicfeatureChinese.java similarity index 98% rename from src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktPhenotypicfeatureChinese.java rename to src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktPhenotypicfeatureChinese.java index 9fda9ef..57b700e 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktPhenotypicfeatureChinese.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktPhenotypicfeatureChinese.java @@ -15,7 +15,7 @@ public class PpktPhenotypicfeatureChinese implements PpktPhenotypicFeatureGenera public PpktPhenotypicfeatureChinese(HpInternational international) { - german = international; + chinese = international; missingTranslations = new HashSet<>(); } @@ -23,7 +23,7 @@ public PpktPhenotypicfeatureChinese(HpInternational international) { private List getTranslations(List ontologyTerms) { List labels = new ArrayList<>(); for (var term: ontologyTerms) { - Optional opt = german.getLabel(term.getTid()); + Optional opt = chinese.getLabel(term.getTid()); if (opt.isPresent()) { labels.add(opt.get()); } else { diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktTextChinese.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktTextChinese.java similarity index 100% rename from src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/PpktTextChinese.java rename to src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/chinese/PpktTextChinese.java