Search in sources :

Example 21 with LetterSoundCorrespondence

use of ai.elimu.model.content.LetterSoundCorrespondence in project webapp by elimu-ai.

the class LetterSoundCorrespondenceDaoJpa method read.

@Override
public LetterSoundCorrespondence read(List<Letter> letters, List<Sound> sounds) throws DataAccessException {
    // TODO: implement usage of CriteriaQuery/CriteriaQuery
    String letterSoundCorrespondenceLetters = letters.stream().map(Letter::getText).collect(Collectors.joining());
    String letterSoundCorrespondenceSounds = sounds.stream().map(Sound::getValueIpa).collect(Collectors.joining());
    for (LetterSoundCorrespondence letterSoundCorrespondence : readAllOrderedByUsage()) {
        String lettersAsString = letterSoundCorrespondence.getLetters().stream().map(Letter::getText).collect(Collectors.joining());
        String soundsAsString = letterSoundCorrespondence.getSounds().stream().map(Sound::getValueIpa).collect(Collectors.joining());
        if (lettersAsString.equals(letterSoundCorrespondenceLetters) && soundsAsString.equals(letterSoundCorrespondenceSounds)) {
            return letterSoundCorrespondence;
        }
    }
    return null;
}
Also used : LetterSoundCorrespondence(ai.elimu.model.content.LetterSoundCorrespondence)

Aggregations

LetterSoundCorrespondence (ai.elimu.model.content.LetterSoundCorrespondence)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 Letter (ai.elimu.model.content.Letter)10 Sound (ai.elimu.model.content.Sound)10 Word (ai.elimu.model.content.Word)7 ArrayList (java.util.ArrayList)7 JSONArray (org.json.JSONArray)6 JSONObject (org.json.JSONObject)5 LetterSoundCorrespondenceContributionEvent (ai.elimu.model.contributor.LetterSoundCorrespondenceContributionEvent)4 LetterSoundCorrespondenceGson (ai.elimu.model.v2.gson.content.LetterSoundCorrespondenceGson)4 IOException (java.io.IOException)4 CSVFormat (org.apache.commons.csv.CSVFormat)4 Contributor (ai.elimu.model.contributor.Contributor)3 WordGson (ai.elimu.model.v2.gson.content.WordGson)3 Gson (com.google.gson.Gson)3 WordContributionEvent (ai.elimu.model.contributor.WordContributionEvent)2 WordContributionEventGson (ai.elimu.model.v2.gson.crowdsource.WordContributionEventGson)2 Reader (java.io.Reader)2 StringWriter (java.io.StringWriter)2 Path (java.nio.file.Path)2