Package org.apache.stanbol.entityhub.servicesapi.model

Examples of org.apache.stanbol.entityhub.servicesapi.model.Text


     */
    public final String getLabel() {
        String label = getLabel(defaultLanguage);
        if(label == null){ //no label for the default language
            //search labels in other languages
            Text altLabel = metadata.getFirst(LABEL, ALT_LABEL_LANGUAGES);
            if(altLabel == null){
                Iterator<Text> labels = metadata.getText(LABEL);
                if(labels.hasNext()){
                    altLabel = labels.next();
                }
            }
            return altLabel!=null?altLabel.getText():null;
        } else {
            return label;
        }
    }
View Full Code Here


     * @param lang the language
     * @return The preferred label of this Symbol in the given language or
     * <code>null</code> if no label for this language is defined
     */
    public final String getLabel(String lang) {
        Text label = metadata.getFirst(LABEL, lang);
        return label!=null?label.getText():null;
    }
View Full Code Here

                    entity = referencedSiteManager.getEntity(topic.conceptUri);
                }
                if (entity != null) {
                    Representation representation = entity.getRepresentation();
                    // TODO: extract all languages based on some configuration instead of hardcoding English
                    Text label = representation.getFirst(NamespaceEnum.skos + "prefLabel", "en", "en-US",
                        "en-GB");
                    if (label == null) {
                        label = representation.getFirst(NamespaceEnum.rdfs + "label", "en", "en-US", "en-GB");
                    }
                    if (label != null) {
                        metadata.add(new TripleImpl(enhancement,
                                org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_LABEL,
                                new PlainLiteralImpl(label.getText())));
                    }
                }
            }
        } catch (ClassifierException e) {
            throw new EngineException(e);
View Full Code Here

        if(values instanceof Collection<?>){
            int removed = 0;
            for(Iterator<Text> it = new TextIterator(valueFactory,
                    ((Collection<Object>)values).iterator(),
                    languages);it.hasNext();){
                Text label = it.next();//go to the next element
                if(text.equals(label.getText())){
                    it.remove();//and remove it
                    removed++;
                }
            }
            if(removed>0){ //if some elements where removed
View Full Code Here

        Collection<Object> values = getValuesAsCollection(field);
        return new TypeSafeIterator<Reference>(values.iterator(), Reference.class);
    }
    protected static String getNaturalLanguageValue(Object check,Set<String> langSet,boolean isNullLanguage){
        if(check instanceof Text){
            Text text = (Text)check;
            if(langSet == null || langSet.contains(text.getLanguage())){
                return text.getText();
            } // else empty arrey -> filter
        } else if(isNullLanguage && check instanceof String){
            return (String)check;
        } //type does not fit -> ignore
        return null; //no label found
View Full Code Here

        for(Iterator<String> fields = rep.getFieldNames();fields.hasNext();){
            String field = fields.next();
            Iterator<Text> values = rep.getText(field);
//            assertTrue(values.hasNext());
            while(values.hasNext()){
                Text text = values.next();
                assertNotNull(text);
                String lang = text.getLanguage();
                //log.info(text.getText()+" | "+text.getLanguage()+" | "+text.getText().endsWith("@"+lang));
                //this texts that the text does not contain the @{lang} as added by
                //the toString method of the RDF Literal java class
                assertFalse("Labels MUST NOT end with the Language! value="+text.getText(),
                    text.getText().endsWith("@"+lang));
            }
        }
    }
View Full Code Here

        // test multiple language query
        Iterator<Text> allDeTexts = rep.get(field, "de", "de-AT");
        assertNotNull(allDeTexts);
        Set<String> textSet = new HashSet<String>(Arrays.asList(NL_TEST_de, NL_TEST_de_AT));
        while (allDeTexts.hasNext()) {
            Text text = allDeTexts.next();
            assertTrue(text.getLanguage().equals("de") || text.getLanguage().equals("de-AT"));
            assertTrue(textSet.remove(text.getText())); // remove the found
        }
        assertTrue(textSet.isEmpty()); // all texts found
    }
View Full Code Here

        String[] languageArray = new String[] {"en", "de", null};
        rep.addNaturalText(field, NL_TEST_noLang, languageArray);
        Set<String> languages = new HashSet<String>(Arrays.asList(languageArray));
        Iterator<Text> texts = rep.get(field, (String[]) null);
        while (texts.hasNext()) {
            Text text = texts.next();
            assertTrue(languages.remove(text.getLanguage()));
            assertEquals(NL_TEST_noLang, text.getText());
        }
        assertTrue(languages.isEmpty());
    }
View Full Code Here

        // add the same label for multiple languages
        rep.addNaturalText(field, NL_TEST_noLang, "en", "de", null);
        rep.removeNaturalText(field, NL_TEST_noLang, "en", null);
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertTrue(texts.hasNext());
        Text text = texts.next();
        assertFalse(texts.hasNext());
        assertEquals("de", text.getLanguage());
        assertEquals(NL_TEST_noLang, text.getText());
    }
View Full Code Here

     */
    public final String getLabel() {
        String label = getLabel(defaultLanguage);
        if(label == null){ //no label for the default language
            //search labels in other languages
            Text altLabel = metadata.getFirst(LABEL, ALT_LABEL_LANGUAGES);
            if(altLabel == null){
                Iterator<Text> labels = metadata.getText(LABEL);
                if(labels.hasNext()){
                    altLabel = labels.next();
                }
            }
            return altLabel!=null?altLabel.getText():null;
        } else {
            return label;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.model.Text

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.