Search in sources :

Example 11 with ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader in project webapp by elimu-ai.

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_HIN_SW_141016_ch8.

@Test
public void testExtractParagraphsFromChapterFile_HIN_SW_141016_ch8() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("hin-sw-141016-tumi-ke-park-ka-din.epub_8.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(1));
    assertThat(storyBookParagraphs.get(0), is("\"देखो माँ, मैं बंदर की तरह झूल रही हूँ।\""));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 12 with ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader in project webapp by elimu-ai.

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_HIN_GDL_1287_ch3.

// TODO: handle &#xa0; interpreted as white space: "कुत्ता &#xa0;सैर"
@Ignore
@Test
public void testExtractParagraphsFromChapterFile_HIN_GDL_1287_ch3() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("hin-gdl-1287.epub_chapter-3.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(1));
    assertThat(storyBookParagraphs.get(0), is("उस मोटे राजा के पास एक पतला कुत्ता था । एक दिन मोटा राजा और उसका पतला कुत्ता सैर करने गए।"));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader in project webapp by elimu-ai.

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_FIL_LRA_faa0d66e.

@Test
public void testExtractParagraphsFromChapterFile_FIL_LRA_faa0d66e() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("fil-lra-faa0d66e-564f-4d72-a1d3-ec46fb754205.epub_Page_3.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(3));
    assertThat(storyBookParagraphs.get(0), is("WAAAAHHHH!"));
    assertThat(storyBookParagraphs.get(1), is("Ang ibong Brahminy ay umiiyak tulad ng isang gutom na sanggol."));
    assertThat(storyBookParagraphs.get(2), is("WAAAAHHHH!"));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 14 with ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader in project webapp by elimu-ai.

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_HIN_GDL_1296_ch3.

@Test
public void testExtractParagraphsFromChapterFile_HIN_GDL_1296_ch3() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("hin-gdl-1296.epub_chapter-3.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(2));
    assertThat(storyBookParagraphs.get(0), is("साथ में चिड़िया भी उड़ती"));
    assertThat(storyBookParagraphs.get(1), is("हुई चली."));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 15 with ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader in project webapp by elimu-ai.

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_BEN_SW_11791.

@Test
public void testExtractParagraphsFromChapterFile_BEN_SW_11791() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-sw-11791-ghumkature-bhim.epub_2.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(2));
    assertThat(storyBookParagraphs.get(0), is("ভীমের শুধু ঘুম আর ঘুম। সকালে উঠতেই পারে না।"));
    assertThat(storyBookParagraphs.get(1), is("ধোপা রামু সুযোগ পেলেই ভীমকে বকা দেয়।"));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Aggregations

ClassRelativeResourceLoader (org.springframework.core.io.ClassRelativeResourceLoader)41 Resource (org.springframework.core.io.Resource)34 ResourceLoader (org.springframework.core.io.ResourceLoader)34 Test (org.junit.Test)33 File (java.io.File)32 Before (org.junit.Before)5 StreamSource (javax.xml.transform.stream.StreamSource)4 ResourceLoaderURIResolver (org.apereo.portal.xml.ResourceLoaderURIResolver)4 SimpleTransformErrorListener (org.springframework.util.xml.SimpleTransformErrorListener)4 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 MessagingException (javax.mail.MessagingException)2 MimeMessage (javax.mail.internet.MimeMessage)2 JavaMailSenderImpl (org.springframework.mail.javamail.JavaMailSenderImpl)2 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)2 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1