-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added chinese, compiles and runs, fixes needed
- Loading branch information
Showing
10 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/java/org/monarchinitiative/phenopacket2prompt/output/Chinese
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
.../org/monarchinitiative/phenopacket2prompt/output/impl/chinese/ChinesePromptGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OntologyTerm> ontologyTerms) { | ||
return ppktPhenotypicFeatureGenerator.formatFeatures(ontologyTerms); | ||
} | ||
|
||
@Override | ||
public String getVignetteAtAge(PhenopacketAge page, PhenopacketSex psex, List<OntologyTerm> 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<String> 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<PhenopacketAge, List<OntologyTerm>> 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(); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.