use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class EmojiEditController method getEmojisByWordId.
private Map<Long, String> getEmojisByWordId() {
logger.info("getEmojisByWordId");
Map<Long, String> emojisByWordId = new HashMap<>();
for (Word word : wordDao.readAll()) {
String emojiGlyphs = "";
List<Emoji> emojis = emojiDao.readAllLabeled(word);
for (Emoji emoji : emojis) {
emojiGlyphs += emoji.getGlyph();
}
if (StringUtils.isNotBlank(emojiGlyphs)) {
emojisByWordId.put(word.getId(), emojiGlyphs);
}
}
return emojisByWordId;
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class EmojiCsvExportController method handleRequest.
@RequestMapping(value = "/emojis.csv", method = RequestMethod.GET)
public void handleRequest(HttpServletResponse response, OutputStream outputStream) throws IOException {
logger.info("handleRequest");
List<Emoji> emojis = emojiDao.readAllOrdered();
logger.info("emojis.size(): " + emojis.size());
CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader("id", "glyph", "unicode_version", "unicode_emoji_version", "word_ids", "word_texts");
StringWriter stringWriter = new StringWriter();
CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
for (Emoji emoji : emojis) {
logger.info("emoji.getGlyph(): \"" + emoji.getGlyph() + "\"");
JSONArray wordIdsJsonArray = new JSONArray();
int index = 0;
for (Word word : emoji.getWords()) {
wordIdsJsonArray.put(index, word.getId());
index++;
}
JSONArray wordTextsJsonArray = new JSONArray();
index = 0;
for (Word word : emoji.getWords()) {
wordTextsJsonArray.put(index, word.getText());
index++;
}
csvPrinter.printRecord(emoji.getId(), emoji.getGlyph(), emoji.getUnicodeVersion(), emoji.getUnicodeEmojiVersion(), wordIdsJsonArray, wordTextsJsonArray);
csvPrinter.flush();
}
String csvFileContent = stringWriter.toString();
response.setContentType("text/csv");
byte[] bytes = csvFileContent.getBytes();
response.setContentLength(bytes.length);
try {
outputStream.write(bytes);
outputStream.flush();
outputStream.close();
} catch (IOException ex) {
logger.error(ex);
}
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class EmojiCreateController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model) {
logger.info("handleRequest");
Emoji emoji = new Emoji();
model.addAttribute("emoji", emoji);
return "content/emoji/create";
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class NumberEditController method getEmojisByWordId.
private Map<Long, String> getEmojisByWordId() {
logger.info("getEmojisByWordId");
Map<Long, String> emojisByWordId = new HashMap<>();
for (Word word : wordDao.readAll()) {
String emojiGlyphs = "";
List<Emoji> emojis = emojiDao.readAllLabeled(word);
for (Emoji emoji : emojis) {
emojiGlyphs += emoji.getGlyph();
}
if (StringUtils.isNotBlank(emojiGlyphs)) {
emojisByWordId.put(word.getId(), emojiGlyphs);
}
}
return emojisByWordId;
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class StoryBookEditController method getEmojisByWordId.
private Map<Long, String> getEmojisByWordId() {
logger.info("getEmojisByWordId");
Map<Long, String> emojisByWordId = new HashMap<>();
for (Word word : wordDao.readAll()) {
String emojiGlyphs = "";
List<Emoji> emojis = emojiDao.readAllLabeled(word);
for (Emoji emoji : emojis) {
emojiGlyphs += emoji.getGlyph();
}
if (StringUtils.isNotBlank(emojiGlyphs)) {
emojisByWordId.put(word.getId(), emojiGlyphs);
}
}
return emojisByWordId;
}
Aggregations