Package org.apache.stanbol.enhancer.servicesapi.impl

Examples of org.apache.stanbol.enhancer.servicesapi.impl.StringSource


    public List<String> tokenizeEntities(String queryTerm) {
        // obtain entities about query term through Enhancer
        ContentItem ci = null;
        boolean error = false;
        try {
            ci = ciFactory.createContentItem(new StringSource(queryTerm));
            enhancementJobManager.enhanceContent(ci);
        } catch (UnsupportedEncodingException e) {
            log.error("Failed to get bytes of query term: {}", queryTerm, e);
            error = true;
        } catch (EnhancementException e) {
View Full Code Here


    @Test
    public void testString() throws IOException{
        String test = "Exámplê";

        //first via a StringSource
        ContentSource cs = new StringSource(test);
        Blob blob = createBlob(cs);
        Assert.assertEquals("text/plain", blob.getMimeType());
        Assert.assertTrue(blob.getParameter().containsKey("charset"));
        Assert.assertEquals(UTF8.name(), blob.getParameter().get("charset"));
View Full Code Here

    @Test
    public void testStringWithCustomCharset() throws IOException{
        String test = "Exámplê";
        Charset ISO8859_4 = Charset.forName("ISO-8859-4");
        //first via a StringSource
        ContentSource cs = new StringSource(test,ISO8859_4,"text/plain");
        Blob blob = createBlob(cs);
        Assert.assertEquals("text/plain", blob.getMimeType());
        Assert.assertTrue(blob.getParameter().containsKey("charset"));
        Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
        //2nd via a ByteArray
View Full Code Here

    }
    /**
     * @throws IOException
     */
    private static AnalysedText createAnalysedText() throws IOException {
        ci = ciFactory.createContentItem(new StringSource(text));
        Entry<UriRef,Blob> textBlob = ContentItemHelper.getBlob(ci, Collections.singleton("text/plain"));
        return  atFactory.createAnalysedText(ci, textBlob.getValue());
    }
View Full Code Here

    private static Entry<UriRef,Blob> textBlob;
   
    @BeforeClass
    public static final void setup() throws IOException {
        ci = ciFactory.createContentItem(new StringSource(text));
        textBlob = ContentItemHelper.getBlob(ci, Collections.singleton("text/plain"));
        analysedTextWithData = createAnalysedText();
        int sentence = text.indexOf('.')+1;
        Sentence sent1 = analysedTextWithData.addSentence(0, sentence);
        expectedSentences.put(sent1, "The Stanbol enhancer can detect famous " +
View Full Code Here

     * @return
     */
    @BeforeClass
    public static void createTestContentItem() throws IOException {
        contentItem = ciFactory.createContentItem(new UriRef("urn:test"),
            new StringSource(
                "<html>\n" +
                "  <body>\n" +
                "    This is a <b>ContentItem</b> to <i>Mime Multipart</i> test!\n" +
                "  </body>\n" +
                "</html>","text/html"));
        contentItem.addPart(new UriRef("run:text:text"),
            ciFactory.createBlob(new StringSource(
            "This is a ContentItem to Mime Multipart test!")));
        contentItem.getMetadata().add(new TripleImpl(
            new UriRef("urn:test"), RDF.type, new UriRef("urn:types:Document")));
        //mark the main content as parsed and also that all
        //contents and contentparts should be included
View Full Code Here

    public Graph getGraph(EnhancementJobManager jobManager,
                          ContentItemFactory ciFactory) throws EnhancementException {
        if(graph == null) {
            ContentItem ci;
            try {
                ci = ciFactory.createContentItem(new StringSource(inputText));
            } catch (IOException e) {
                throw new IllegalStateException("Unable to create a ContentItem" +
                    "using '"+ciFactory.getClass().getSimpleName()+"'!",e);
            }
            if(chain == null){
View Full Code Here

        assertTrue("The custom dir '"+customDir+"'MUST exist",
            customDir.exists());
        assertTrue("The custom dir '"+customDir+"'MUST be an directory",
            customDir.isDirectory());
        int numFiles = customDir.list().length;
        Blob blob = contentItemFactory.createBlob(new StringSource("ensure a file exist"));
        assertNotNull(blob);
        Assert.assertEquals("Creating a new Blob has not increased the " +
            "number of files by one!",numFiles, customDir.list().length-1);
    }
View Full Code Here

    private static ContentItem ci;

    private static Entry<UriRef,Blob> textBlob;
 
  protected static void setupAnalysedText(String text) throws IOException {
    ci = ciFactory.createContentItem(new StringSource(text));
        textBlob = ContentItemHelper.getBlob(ci, Collections.singleton("text/plain"));
        at = atFactory.createAnalysedText(textBlob.getValue());
  }
View Full Code Here

    public List<String> tokenizeEntities(String queryTerm) {
        // obtain entities about query term through Enhancer
        ContentItem ci = null;
        boolean error = false;
        try {
            ci = ciFactory.createContentItem(new StringSource(queryTerm));
            enhancementJobManager.enhanceContent(ci);
        } catch (UnsupportedEncodingException e) {
            log.error("Failed to get bytes of query term: {}", queryTerm, e);
            error = true;
        } catch (EnhancementException e) {
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.servicesapi.impl.StringSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.