Search in sources :

Example 1 with NaturalTextFilter

use of org.apache.stanbol.entityhub.model.clerezza.impl.NaturalTextFilter in project stanbol by apache.

the class RdfRepresentation method removeAllNaturalText.

@Override
public void removeAllNaturalText(String field, String... languages) {
    if (field == null) {
        throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
    } else if (field.isEmpty()) {
        throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
    }
    //        if(languages == null || languages.length == 0){
    //            languages = new String []{null};
    //        }
    IRI fieldIRI = new IRI(field);
    //get all the affected Literals
    Collection<Literal> toRemove = new ArrayList<Literal>();
    Iterator<Literal> it = new FilteringIterator<Literal>(graphNode.getLiterals(fieldIRI), new NaturalTextFilter(languages), Literal.class);
    while (it.hasNext()) {
        toRemove.add(it.next());
    }
    for (Literal l : toRemove) {
        graphNode.deleteProperty(fieldIRI, l);
    }
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) NaturalTextFilter(org.apache.stanbol.entityhub.model.clerezza.impl.NaturalTextFilter) Literal(org.apache.clerezza.commons.rdf.Literal) FilteringIterator(org.apache.stanbol.entityhub.servicesapi.util.FilteringIterator) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 Literal (org.apache.clerezza.commons.rdf.Literal)1 NaturalTextFilter (org.apache.stanbol.entityhub.model.clerezza.impl.NaturalTextFilter)1 FilteringIterator (org.apache.stanbol.entityhub.servicesapi.util.FilteringIterator)1