Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/EntityLinker.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/EntityLinker.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/EntityLinker.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/EntityLinker.java Tue May 17 22:20:49 2016 @@ -31,11 +31,11 @@ import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.commons.lang.StringUtils; import org.apache.stanbol.enhancer.engines.entitylinking.Entity; import org.apache.stanbol.enhancer.engines.entitylinking.EntitySearcher; @@ -496,22 +496,22 @@ public class EntityLinker { * @param conceptTypes The list of suggestions * @return the types values for the {@link LinkedEntity} */ - private Set<UriRef> getLinkedEntityTypes(Collection<Suggestion> suggestions){ - Collection<UriRef> conceptTypes = new HashSet<UriRef>(); + private Set<IRI> getLinkedEntityTypes(Collection<Suggestion> suggestions){ + Collection<IRI> conceptTypes = new HashSet<IRI>(); double score = -1; //only consider types of the best ranked Entities for(Suggestion suggestion : suggestions){ double actScore = suggestion.getScore(); if(actScore < score){ break; } - for(Iterator<UriRef> types = + for(Iterator<IRI> types = suggestion.getEntity().getReferences(linkerConfig.getTypeField()); types.hasNext();conceptTypes.add(types.next())); } - Map<UriRef,UriRef> typeMappings = linkerConfig.getTypeMappings(); - Set<UriRef> dcTypes = new HashSet<UriRef>(); - for(UriRef conceptType : conceptTypes){ - UriRef dcType = typeMappings.get(conceptType); + Map<IRI,IRI> typeMappings = linkerConfig.getTypeMappings(); + Set<IRI> dcTypes = new HashSet<IRI>(); + for(IRI conceptType : conceptTypes){ + IRI dcType = typeMappings.get(conceptType); if(dcType != null){ dcTypes.add(dcType); } @@ -541,13 +541,13 @@ public class EntityLinker { return; //Redirects for ResultMatch are already processed ... ignore } Entity result = suggestion.getResult(); - Iterator<UriRef> redirects = result.getReferences(linkerConfig.getRedirectField()); + Iterator<IRI> redirects = result.getReferences(linkerConfig.getRedirectField()); switch (linkerConfig.getRedirectProcessingMode()) { case ADD_VALUES: - TripleCollection entityData = result.getData(); - UriRef entityUri = result.getUri(); + Graph entityData = result.getData(); + IRI entityUri = result.getUri(); while(redirects.hasNext()){ - UriRef redirect = redirects.next(); + IRI redirect = redirects.next(); if(redirect != null){ Entity redirectedEntity = entitySearcher.get(redirect, linkerConfig.getSelectedFields()); @@ -564,7 +564,7 @@ public class EntityLinker { } case FOLLOW: while(redirects.hasNext()){ - UriRef redirect = redirects.next(); + IRI redirect = redirects.next(); if(redirect != null){ Entity redirectedEntity = entitySearcher.get(redirect, linkerConfig.getSelectedFields()); @@ -734,13 +734,13 @@ public class EntityLinker { } } - public boolean filterEntity(Iterator<UriRef> entityTypes){ - Map<UriRef, Integer> whiteList = linkerConfig.getWhitelistedTypes(); - Map<UriRef, Integer> blackList = linkerConfig.getBlacklistedTypes(); + public boolean filterEntity(Iterator<IRI> entityTypes){ + Map<IRI, Integer> whiteList = linkerConfig.getWhitelistedTypes(); + Map<IRI, Integer> blackList = linkerConfig.getBlacklistedTypes(); Integer w = null; Integer b = null; while(entityTypes.hasNext()){ - UriRef type = entityTypes.next(); + IRI type = entityTypes.next(); Integer act = whiteList.get(type); if(act != null){ if(w == null || act.compareTo(w) < 0){ @@ -789,22 +789,22 @@ public class EntityLinker { String curLang = documentLang; //language of the current sentence String defLang = defaultLang; //configured default language String mainLang = documentMainLang; - Collection<PlainLiteral> mainLangLabels; + Collection<Literal> mainLangLabels; if(documentMainLang != null){ mainLang = documentMainLang; - mainLangLabels = new ArrayList<PlainLiteral>(); + mainLangLabels = new ArrayList<Literal>(); } else { mainLang = documentLang; mainLangLabels = Collections.emptyList(); } - Iterator<PlainLiteral> labels = entity.getText(linkerConfig.getNameField()); + Iterator<Literal> labels = entity.getText(linkerConfig.getNameField()); Suggestion match = new Suggestion(entity); - Collection<PlainLiteral> defaultLabels = new ArrayList<PlainLiteral>(); + Collection<Literal> defaultLabels = new ArrayList<Literal>(); boolean matchedLangLabel = false; //avoid matching multiple labels with the exact same lexical. Set<String> matchedLabels = new HashSet<String>(); while(labels.hasNext()){ - PlainLiteral label = labels.next(); + Literal label = labels.next(); //numLabels++; String lang = label.getLanguage() != null ? label.getLanguage().toString() : null; String text = label.getLexicalForm(); @@ -831,7 +831,7 @@ public class EntityLinker { } //try to match main language labels if(!matchedLangLabel || match.getMatch() == MATCH.NONE){ - for(PlainLiteral mainLangLabel : mainLangLabels){ + for(Literal mainLangLabel : mainLangLabels){ if(!matchedLabels.contains(mainLangLabel.getLexicalForm())){ matchLabel(searchTokens, match, mainLangLabel); matchedLabels.add(mainLangLabel.getLexicalForm()); @@ -843,7 +843,7 @@ public class EntityLinker { // * no label in the current language or // * no MATCH was found in the current language if(!matchedLangLabel || match.getMatch() == MATCH.NONE){ - for(PlainLiteral defaultLangLabel : defaultLabels){ + for(Literal defaultLangLabel : defaultLabels){ if(!matchedLabels.contains(defaultLangLabel.getLexicalForm())){ matchLabel(searchTokens, match, defaultLangLabel); matchedLabels.add(defaultLangLabel.getLexicalForm()); @@ -857,7 +857,7 @@ public class EntityLinker { * @param suggestion * @param label */ - private void matchLabel(List<TokenData> searchTokens, Suggestion suggestion, PlainLiteral label) { + private void matchLabel(List<TokenData> searchTokens, Suggestion suggestion, Literal label) { // test.begin(); String text = label.getLexicalForm(); String lang = label.getLanguage() == null ? null : label.getLanguage().toString();
Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LabelMatch.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LabelMatch.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LabelMatch.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LabelMatch.java Tue May 17 22:20:49 2016 @@ -17,8 +17,8 @@ package org.apache.stanbol.enhancer.engines.entitylinking.impl; import java.util.Comparator; +import org.apache.clerezza.commons.rdf.Literal; -import org.apache.clerezza.rdf.core.PlainLiteral; import org.apache.stanbol.enhancer.engines.entitylinking.impl.Suggestion.MATCH; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ public class LabelMatch { private int start = 0; private int span = 0; private int processableMatchCount = 0; - private PlainLiteral label; + private Literal label; private int labelTokenCount = 0; private double score; /** @@ -56,11 +56,11 @@ public class LabelMatch { * @param start * @param span */ - protected LabelMatch(int start, int span, PlainLiteral label){ + protected LabelMatch(int start, int span, Literal label){ this(start,span,span,span,1f,label,span,span); } - protected LabelMatch(int start, int span,int processableMatchCount, int matchCount, float tokenMatchScore,PlainLiteral label,int labelTokenCount, int coveredLabelTokenCount){ + protected LabelMatch(int start, int span,int processableMatchCount, int matchCount, float tokenMatchScore,Literal label,int labelTokenCount, int coveredLabelTokenCount){ if(start < 0){ throw new IllegalArgumentException("parsed start position MUST BE >= 0!"); } @@ -136,7 +136,7 @@ public class LabelMatch { * based match for the given search tokens. * @return the label */ - public PlainLiteral getMatchedLabel() { + public Literal getMatchedLabel() { return label; } /** Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LinkedEntity.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LinkedEntity.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LinkedEntity.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/LinkedEntity.java Tue May 17 22:20:49 2016 @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.Set; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.stanbol.enhancer.nlp.model.Section; import org.apache.stanbol.enhancer.nlp.model.Token; @@ -128,7 +128,7 @@ public class LinkedEntity { } } private final String selectedText; - private final Set<UriRef> types; + private final Set<IRI> types; private final List<Suggestion> suggestions; private final Collection<Occurrence> occurrences = new ArrayList<Occurrence>(); private final Collection<Occurrence> unmodOccurrences = Collections.unmodifiableCollection(occurrences); @@ -138,7 +138,7 @@ public class LinkedEntity { * @param suggestions the entity suggestions * @param types the types of the linked entity. */ - protected LinkedEntity(String selectedText, List<Suggestion> suggestions, Set<UriRef> types) { + protected LinkedEntity(String selectedText, List<Suggestion> suggestions, Set<IRI> types) { this.suggestions = Collections.unmodifiableList(suggestions); this.selectedText = selectedText; this.types = Collections.unmodifiableSet(types); @@ -152,7 +152,7 @@ public class LinkedEntity { * @param types the types of the linked entity. */ protected LinkedEntity(Section section,Token startToken,Token endToken, - List<Suggestion> suggestions, Set<UriRef> types) { + List<Suggestion> suggestions, Set<IRI> types) { this(startToken.getSpan().substring(startToken.getStart(), endToken.getEnd()), suggestions,types); addOccurrence(section, startToken,endToken); @@ -169,7 +169,7 @@ public class LinkedEntity { * Getter for read only list of types * @return the types */ - public Set<UriRef> getTypes() { + public Set<IRI> getTypes() { return types; } /** Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/Suggestion.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/Suggestion.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/Suggestion.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/Suggestion.java Tue May 17 22:20:49 2016 @@ -27,9 +27,9 @@ import java.util.Comparator; import java.util.Iterator; import java.util.List; -import org.apache.clerezza.rdf.core.Language; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Language; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.stanbol.enhancer.engines.entitylinking.Entity; import org.apache.stanbol.enhancer.engines.entitylinking.EntitySearcher; @@ -106,18 +106,18 @@ public class Suggestion { * @param language the language * @return the best match or {@link Suggestion#getMatchedLabel()} if non is found */ - public PlainLiteral getBestLabel(UriRef nameField, String language){ + public Literal getBestLabel(IRI nameField, String language){ Entity rep = getEntity(); //start with the matched label -> so if we do not find a better one //we will use the matched! - PlainLiteral matchedLabel = getMatchedLabel(); - PlainLiteral label = matchedLabel; + Literal matchedLabel = getMatchedLabel(); + Literal label = matchedLabel; // 1. check if the returned Entity does has a label -> if not return null // add labels (set only a single label. Use "en" if available! - Iterator<PlainLiteral> labels = rep.getText(nameField); + Iterator<Literal> labels = rep.getText(nameField); boolean matchFound = false; while (labels.hasNext() && !matchFound) { - PlainLiteral actLabel = labels.next(); + Literal actLabel = labels.next(); if(label == null){ label = actLabel; } @@ -142,7 +142,7 @@ public class Suggestion { * Shorthand for {@link #getLabelMatch()}.getMatchedLabel() * @return the label or <code>null</code> if {@link MATCH#NONE} */ - public PlainLiteral getMatchedLabel() { + public Literal getMatchedLabel() { return getLabelMatch().getMatchedLabel(); } protected void setMatch(MATCH matchType) { Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngineTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngineTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngineTest.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngineTest.java Tue May 17 22:20:49 2016 @@ -40,15 +40,15 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TripleImpl; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory; import org.apache.stanbol.enhancer.engines.entitylinking.Entity; import org.apache.stanbol.enhancer.engines.entitylinking.LabelTokenizer; @@ -119,58 +119,58 @@ public class EntityLinkingEngineTest { static TestSearcherImpl searcher; - public static final UriRef NAME = new UriRef(NamespaceEnum.rdfs+"label"); - public static final UriRef TYPE = new UriRef(NamespaceEnum.rdf+"type"); - public static final UriRef REDIRECT = new UriRef(NamespaceEnum.rdfs+"seeAlso"); + public static final IRI NAME = new IRI(NamespaceEnum.rdfs+"label"); + public static final IRI TYPE = new IRI(NamespaceEnum.rdf+"type"); + public static final IRI REDIRECT = new IRI(NamespaceEnum.rdfs+"seeAlso"); @BeforeClass public static void setUpServices() throws IOException { searcher = new TestSearcherImpl(TEST_REFERENCED_SITE_NAME,NAME,new SimpleLabelTokenizer()); //add some terms to the searcher - MGraph graph = new IndexedMGraph(); - UriRef uri = new UriRef("urn:test:PatrickMarshall"); + Graph graph = new IndexedGraph(); + IRI uri = new IRI("urn:test:PatrickMarshall"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Patrick Marshall"))); graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PERSON)); searcher.addEntity(new Entity(uri, graph)); - uri = new UriRef("urn:test:Geologist"); + uri = new IRI("urn:test:Geologist"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Geologist"))); - graph.add(new TripleImpl(uri, TYPE, new UriRef(NamespaceEnum.skos+"Concept"))); - graph.add(new TripleImpl(uri, REDIRECT, new UriRef("urn:test:redirect:Geologist"))); + graph.add(new TripleImpl(uri, TYPE, new IRI(NamespaceEnum.skos+"Concept"))); + graph.add(new TripleImpl(uri, REDIRECT, new IRI("urn:test:redirect:Geologist"))); searcher.addEntity(new Entity(uri, graph)); //a redirect - uri = new UriRef("urn:test:redirect:Geologist"); + uri = new IRI("urn:test:redirect:Geologist"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Geologe (redirect)"))); - graph.add(new TripleImpl(uri, TYPE, new UriRef(NamespaceEnum.skos+"Concept"))); + graph.add(new TripleImpl(uri, TYPE, new IRI(NamespaceEnum.skos+"Concept"))); searcher.addEntity(new Entity(uri, graph)); - uri = new UriRef("urn:test:NewZealand"); + uri = new IRI("urn:test:NewZealand"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("New Zealand"))); graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PLACE)); searcher.addEntity(new Entity(uri, graph)); - uri = new UriRef("urn:test:UniversityOfOtago"); + uri = new IRI("urn:test:UniversityOfOtago"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("University of Otago"))); graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_ORGANISATION)); searcher.addEntity(new Entity(uri, graph)); - uri = new UriRef("urn:test:University"); + uri = new IRI("urn:test:University"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("University"))); - graph.add(new TripleImpl(uri, TYPE, new UriRef(NamespaceEnum.skos+"Concept"))); + graph.add(new TripleImpl(uri, TYPE, new IRI(NamespaceEnum.skos+"Concept"))); searcher.addEntity(new Entity(uri, graph)); - uri = new UriRef("urn:test:Otago"); + uri = new IRI("urn:test:Otago"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Otago"))); graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PLACE)); searcher.addEntity(new Entity(uri, graph)); //add a 2nd Otago (Place and University - uri = new UriRef("urn:test:Otago_Texas"); + uri = new IRI("urn:test:Otago_Texas"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Otago (Texas)"))); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("Otago"))); graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_PLACE)); searcher.addEntity(new Entity(uri, graph)); - uri = new UriRef("urn:test:UniversityOfOtago_Texas"); + uri = new IRI("urn:test:UniversityOfOtago_Texas"); graph.add(new TripleImpl(uri, NAME, new PlainLiteralImpl("University of Otago (Texas)"))); graph.add(new TripleImpl(uri, TYPE, OntologicalClasses.DBPEDIA_ORGANISATION)); searcher.addEntity(new Entity(uri, graph)); @@ -254,7 +254,7 @@ public class EntityLinkingEngineTest { } public static ContentItem getContentItem(final String id, final String text) throws IOException { - return ciFactory.createContentItem(new UriRef(id),new StringSource(text)); + return ciFactory.createContentItem(new IRI(id),new StringSource(text)); } /** * This tests the EntityLinker functionality (if the expected Entities @@ -396,7 +396,7 @@ public class EntityLinkingEngineTest { //compute the enhancements engine.computeEnhancements(ci); //validate the enhancement results - Map<UriRef,Resource> expectedValues = new HashMap<UriRef,Resource>(); + Map<IRI,RDFTerm> expectedValues = new HashMap<IRI,RDFTerm>(); expectedValues.put(ENHANCER_EXTRACTED_FROM, ci.getUri()); expectedValues.put(DC_CREATOR,LiteralFactory.getInstance().createTypedLiteral( engine.getClass().getName())); @@ -410,18 +410,18 @@ public class EntityLinkingEngineTest { assertEquals("Five fise:EntityAnnotations are expected by this Test", 5, numEntityAnnotations); } /** - * Similar to {@link EnhancementStructureHelper#validateAllEntityAnnotations(org.apache.clerezza.rdf.core.TripleCollection, Map)} + * Similar to {@link EnhancementStructureHelper#validateAllEntityAnnotations(org.apache.clerezza.commons.rdf.Graph, Map)} * but in addition checks fise:confidence [0..1] and entityhub:site properties * @param ci * @param expectedValues * @return */ - private static int validateAllEntityAnnotations(ContentItem ci, Map<UriRef,Resource> expectedValues){ + private static int validateAllEntityAnnotations(ContentItem ci, Map<IRI,RDFTerm> expectedValues){ Iterator<Triple> entityAnnotationIterator = ci.getMetadata().filter(null, RDF_TYPE, ENHANCER_ENTITYANNOTATION); int entityAnnotationCount = 0; while (entityAnnotationIterator.hasNext()) { - UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject(); + IRI entityAnnotation = (IRI) entityAnnotationIterator.next().getSubject(); // test if selected Text is added validateEntityAnnotation(ci.getMetadata(), entityAnnotation, expectedValues); //validate also that the confidence is between [0..1] @@ -438,12 +438,12 @@ public class EntityLinkingEngineTest { // +"',entityAnnotation "+entityAnnotation+")", // 0.0 <= confidence.doubleValue()); //Test the entityhub:site property (STANBOL-625) - UriRef ENTITYHUB_SITE = new UriRef(NamespaceEnum.entityhub+"site"); + IRI ENTITYHUB_SITE = new IRI(NamespaceEnum.entityhub+"site"); Iterator<Triple> entitySiteIterator = ci.getMetadata().filter(entityAnnotation, ENTITYHUB_SITE, null); assertTrue("Expected entityhub:site value is missing (entityAnnotation " +entityAnnotation+")",entitySiteIterator.hasNext()); - Resource siteResource = entitySiteIterator.next().getObject(); + RDFTerm siteResource = entitySiteIterator.next().getObject(); assertTrue("entityhub:site values MUST BE Literals", siteResource instanceof Literal); assertEquals("'"+TEST_REFERENCED_SITE_NAME+"' is expected as " + "entityhub:site value", TEST_REFERENCED_SITE_NAME, Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/TestSearcherImpl.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/TestSearcherImpl.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/TestSearcherImpl.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/impl/TestSearcherImpl.java Tue May 17 22:20:49 2016 @@ -29,10 +29,10 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.stanbol.enhancer.engines.entitylinking.Entity; import org.apache.stanbol.enhancer.engines.entitylinking.EntitySearcher; import org.apache.stanbol.enhancer.engines.entitylinking.LabelTokenizer; @@ -40,29 +40,29 @@ import org.apache.stanbol.enhancer.servi public class TestSearcherImpl implements EntitySearcher { - private final UriRef nameField; + private final IRI nameField; private final LabelTokenizer tokenizer; private SortedMap<String,Collection<Entity>> data = new TreeMap<String,Collection<Entity>>(String.CASE_INSENSITIVE_ORDER); - private Map<UriRef,Entity> entities = new HashMap<UriRef,Entity>(); - private Map<UriRef,Collection<Resource>> originInfo; + private Map<IRI,Entity> entities = new HashMap<IRI,Entity>(); + private Map<IRI,Collection<RDFTerm>> originInfo; - public TestSearcherImpl(String siteId,UriRef nameField, LabelTokenizer tokenizer) { + public TestSearcherImpl(String siteId,IRI nameField, LabelTokenizer tokenizer) { this.nameField = nameField; this.tokenizer = tokenizer; this.originInfo = Collections.singletonMap( - new UriRef(NamespaceEnum.entityhub+"site"), - (Collection<Resource>)Collections.singleton( - (Resource)new PlainLiteralImpl(siteId))); + new IRI(NamespaceEnum.entityhub+"site"), + (Collection<RDFTerm>)Collections.singleton( + (RDFTerm)new PlainLiteralImpl(siteId))); } public void addEntity(Entity rep){ entities.put(rep.getUri(), rep); - Iterator<PlainLiteral> labels = rep.getText(nameField); + Iterator<Literal> labels = rep.getText(nameField); while(labels.hasNext()){ - PlainLiteral label = labels.next(); + Literal label = labels.next(); for(String token : tokenizer.tokenize(label.getLexicalForm(),null)){ Collection<Entity> values = data.get(token); if(values == null){ @@ -76,13 +76,13 @@ public class TestSearcherImpl implements } @Override - public Entity get(UriRef id, Set<UriRef> includeFields, String...lanuages) throws IllegalStateException { + public Entity get(IRI id, Set<IRI> includeFields, String...lanuages) throws IllegalStateException { return entities.get(id); } @Override - public Collection<? extends Entity> lookup(UriRef field, - Set<UriRef> includeFields, + public Collection<? extends Entity> lookup(IRI field, + Set<IRI> includeFields, List<String> search, String[] languages,Integer numResults, Integer offset) throws IllegalStateException { if(field.equals(nameField)){ @@ -124,7 +124,7 @@ public class TestSearcherImpl implements } @Override - public Map<UriRef,Collection<Resource>> getOriginInformation() { + public Map<IRI,Collection<RDFTerm>> getOriginInformation() { return originInfo; } } Modified: stanbol/trunk/enhancement-engines/entitylinking/labeltokenizer-opennlp/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/opennlp/ClasspathDataFileProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/labeltokenizer-opennlp/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/opennlp/ClasspathDataFileProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitylinking/labeltokenizer-opennlp/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/opennlp/ClasspathDataFileProvider.java (original) +++ stanbol/trunk/enhancement-engines/entitylinking/labeltokenizer-opennlp/src/test/java/org/apache/stanbol/enhancer/engines/entitylinking/labeltokenizer/opennlp/ClasspathDataFileProvider.java Tue May 17 22:20:49 2016 @@ -69,7 +69,7 @@ public class ClasspathDataFileProvider i // load default OpenNLP models from classpath (embedded in the defaultdata bundle) final String resourcePath = RESOURCE_BASE_PATH + filename; final URL dataFile = getClass().getClassLoader().getResource(resourcePath); - //log.debug("Resource {} found: {}", (in == null ? "NOT" : ""), resourcePath); + //log.debug("RDFTerm {} found: {}", (in == null ? "NOT" : ""), resourcePath); return dataFile; } } Modified: stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java (original) +++ stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/EnhancementRDFUtils.java Tue May 17 22:20:49 2016 @@ -26,14 +26,14 @@ import static org.apache.stanbol.enhance import java.util.Collection; import java.util.Iterator; -import org.apache.clerezza.rdf.core.Language; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Language; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine; import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper; import org.apache.stanbol.entityhub.servicesapi.model.Reference; @@ -59,7 +59,7 @@ public final class EnhancementRDFUtils { * @param literalFactory * the LiteralFactory to use * @param graph - * the MGraph to use + * the Graph to use * @param contentItemId * the contentItemId the enhancement is extracted from * @param relatedEnhancements @@ -69,11 +69,11 @@ public final class EnhancementRDFUtils { * @param nameField the field used to extract the name * @param lang the preferred language to include or <code>null</code> if none */ - public static UriRef writeEntityAnnotation(EnhancementEngine engine, + public static IRI writeEntityAnnotation(EnhancementEngine engine, LiteralFactory literalFactory, - MGraph graph, - UriRef contentItemId, - Collection<NonLiteral> relatedEnhancements, + Graph graph, + IRI contentItemId, + Collection<BlankNodeOrIRI> relatedEnhancements, Suggestion suggestion, String nameField, String lang) { @@ -104,13 +104,13 @@ public final class EnhancementRDFUtils { literal = new PlainLiteralImpl(label.getText(), new Language(label.getLanguage())); } // Now create the entityAnnotation - UriRef entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(graph, engine, + IRI entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(graph, engine, contentItemId); // first relate this entity annotation to the text annotation(s) - for (NonLiteral enhancement : relatedEnhancements) { + for (BlankNodeOrIRI enhancement : relatedEnhancements) { graph.add(new TripleImpl(entityAnnotation, DC_RELATION, enhancement)); } - UriRef entityUri = new UriRef(rep.getId()); + IRI entityUri = new IRI(rep.getId()); // add the link to the referred entity graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_REFERENCE, entityUri)); // add the label parsed above @@ -122,13 +122,13 @@ public final class EnhancementRDFUtils { Iterator<Reference> types = rep.getReferences(RDF_TYPE.getUnicodeString()); while (types.hasNext()) { - graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_TYPE, new UriRef(types.next() + graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_TYPE, new IRI(types.next() .getReference()))); } //add the name of the ReferencedSite that manages the Entity if(suggestion.getEntity().getSite() != null){ graph.add(new TripleImpl(entityAnnotation, - new UriRef(RdfResourceEnum.site.getUri()), + new IRI(RdfResourceEnum.site.getUri()), new PlainLiteralImpl(suggestion.getEntity().getSite()))); } Modified: stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java (original) +++ stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntity.java Tue May 17 22:20:49 2016 @@ -19,9 +19,9 @@ package org.apache.stanbol.enhancer.engi import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_TYPE; import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_SELECTED_TEXT; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.commons.lang.StringUtils; import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper; import org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses; @@ -30,10 +30,10 @@ import org.slf4j.LoggerFactory; public final class NamedEntity { private static final Logger log = LoggerFactory.getLogger(NamedEntity.class); - private final NonLiteral entity; + private final BlankNodeOrIRI entity; private final String name; - private final UriRef type; - private NamedEntity(NonLiteral entity, String name, UriRef type) { + private final IRI type; + private NamedEntity(BlankNodeOrIRI entity, String name, IRI type) { this.entity = entity; this.name = name; this.type = type; @@ -42,7 +42,7 @@ public final class NamedEntity { * Getter for the Node providing the information about that entity * @return the entity */ - public final NonLiteral getEntity() { + public final BlankNodeOrIRI getEntity() { return entity; } /** @@ -56,7 +56,7 @@ public final class NamedEntity { * Getter for the type * @return the type */ - public final UriRef getType() { + public final IRI getType() { return type; } @Override @@ -79,7 +79,7 @@ public final class NamedEntity { * @return the {@link NamedEntity} or <code>null</code> if the parsed * text annotation is missing required information. */ - public static NamedEntity createFromTextAnnotation(TripleCollection graph, NonLiteral textAnnotation){ + public static NamedEntity createFromTextAnnotation(Graph graph, BlankNodeOrIRI textAnnotation){ String selected = EnhancementEngineHelper.getString(graph, textAnnotation, ENHANCER_SELECTED_TEXT); if (selected == null) { log.debug("Unable to create NamedEntity for TextAnnotation {} " @@ -100,7 +100,7 @@ public final class NamedEntity { textAnnotation, selected); return null; } - UriRef type = EnhancementEngineHelper.getReference(graph, textAnnotation, DC_TYPE); + IRI type = EnhancementEngineHelper.getReference(graph, textAnnotation, DC_TYPE); if (type == null) { log.warn("Unable to process TextAnnotation {} because property {}" + " is not present!",textAnnotation, DC_TYPE); Modified: stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntityTaggingEngine.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntityTaggingEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntityTaggingEngine.java (original) +++ stanbol/trunk/enhancement-engines/entitytagging/src/main/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/NamedEntityTaggingEngine.java Tue May 17 22:20:49 2016 @@ -30,10 +30,10 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.commons.lang.StringUtils; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; @@ -338,10 +338,10 @@ public class NamedEntityTaggingEngine ex } else { // null indicates to use the Entityhub to lookup Entities site = null; } - MGraph graph = ci.getMetadata(); + Graph graph = ci.getMetadata(); LiteralFactory literalFactory = LiteralFactory.getInstance(); // Retrieve the existing text annotations (requires read lock) - Map<NamedEntity,List<UriRef>> textAnnotations = new HashMap<NamedEntity,List<UriRef>>(); + Map<NamedEntity,List<IRI>> textAnnotations = new HashMap<NamedEntity,List<IRI>>(); // the language extracted for the parsed content or NULL if not // available String contentLangauge; @@ -350,7 +350,7 @@ public class NamedEntityTaggingEngine ex contentLangauge = EnhancementEngineHelper.getLanguage(ci); for (Iterator<Triple> it = graph.filter(null, RDF_TYPE, TechnicalClasses.ENHANCER_TEXTANNOTATION); it .hasNext();) { - UriRef uri = (UriRef) it.next().getSubject(); + IRI uri = (IRI) it.next().getSubject(); if (graph.filter(uri, Properties.DC_RELATION, null).hasNext()) { // this is not the most specific occurrence of this name: // skip @@ -360,10 +360,10 @@ public class NamedEntityTaggingEngine ex if (namedEntity != null) { // This is a first occurrence, collect any subsumed // annotations - List<UriRef> subsumed = new ArrayList<UriRef>(); + List<IRI> subsumed = new ArrayList<IRI>(); for (Iterator<Triple> it2 = graph.filter(null, Properties.DC_RELATION, uri); it2 .hasNext();) { - subsumed.add((UriRef) it2.next().getSubject()); + subsumed.add((IRI) it2.next().getSubject()); } textAnnotations.put(namedEntity, subsumed); } @@ -374,7 +374,7 @@ public class NamedEntityTaggingEngine ex // search the suggestions Map<NamedEntity,List<Suggestion>> suggestions = new HashMap<NamedEntity,List<Suggestion>>( textAnnotations.size()); - for (Entry<NamedEntity,List<UriRef>> entry : textAnnotations.entrySet()) { + for (Entry<NamedEntity,List<IRI>> entry : textAnnotations.entrySet()) { try { List<Suggestion> entitySuggestions = computeEntityRecommentations(site, entry.getKey(), entry.getValue(), contentLangauge); @@ -391,8 +391,8 @@ public class NamedEntityTaggingEngine ex RdfValueFactory factory = RdfValueFactory.getInstance(); Map<String,Representation> entityData = new HashMap<String,Representation>(); for (Entry<NamedEntity,List<Suggestion>> entitySuggestions : suggestions.entrySet()) { - List<UriRef> subsumed = textAnnotations.get(entitySuggestions.getKey()); - List<NonLiteral> annotationsToRelate = new ArrayList<NonLiteral>(subsumed); + List<IRI> subsumed = textAnnotations.get(entitySuggestions.getKey()); + List<BlankNodeOrIRI> annotationsToRelate = new ArrayList<BlankNodeOrIRI>(subsumed); annotationsToRelate.add(entitySuggestions.getKey().getEntity()); for (Suggestion suggestion : entitySuggestions.getValue()) { log.debug("Add Suggestion {} for {}", suggestion.getEntity().getId(), @@ -443,7 +443,7 @@ public class NamedEntityTaggingEngine ex */ protected final List<Suggestion> computeEntityRecommentations(Site site, NamedEntity namedEntity, - List<UriRef> subsumedAnnotations, + List<IRI> subsumedAnnotations, String language) throws EntityhubException { // First get the required properties for the parsed textAnnotation // ... and check the values Modified: stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/DbPediaDataFileProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/DbPediaDataFileProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/DbPediaDataFileProvider.java (original) +++ stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/DbPediaDataFileProvider.java Tue May 17 22:20:49 2016 @@ -45,7 +45,7 @@ public class DbPediaDataFileProvider imp if(resourceUri != null){ return resourceUri.openStream(); } else { - throw new IOException("Resource '"+resource+"' not found"); + throw new IOException("RDFTerm '"+resource+"' not found"); } } Modified: stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/TestEntityLinkingEnhancementEngine.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/TestEntityLinkingEnhancementEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/TestEntityLinkingEnhancementEngine.java (original) +++ stanbol/trunk/enhancement-engines/entitytagging/src/test/java/org/apache/stanbol/enhancer/engines/entitytagging/impl/TestEntityLinkingEnhancementEngine.java Tue May 17 22:20:49 2016 @@ -43,15 +43,14 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.commons.io.IOUtils; import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory; import org.apache.stanbol.enhancer.rdfentities.RdfEntityFactory; @@ -148,7 +147,7 @@ public class TestEntityLinkingEnhancemen */ private ContentItem initContentItem() throws IOException { ContentItem ci = ciFactory.createContentItem( - new UriRef("urn:iks-project:enhancer:text:content-item:person"), + new IRI("urn:iks-project:enhancer:text:content-item:person"), new StringSource(CONTEXT)); //add three text annotations to be consumed by this test getTextAnnotation(ci, PERSON, CONTEXT, DBPEDIA_PERSON); @@ -159,7 +158,7 @@ public class TestEntityLinkingEnhancemen return ci; } - public static void getTextAnnotation(ContentItem ci, String name,String context,UriRef type){ + public static void getTextAnnotation(ContentItem ci, String name,String context,IRI type){ String content; try { content = IOUtils.toString(ci.getStream(),"UTF-8"); @@ -169,8 +168,8 @@ public class TestEntityLinkingEnhancemen } RdfEntityFactory factory = RdfEntityFactory.createInstance(ci.getMetadata()); TextAnnotation textAnnotation = factory.getProxy( - new UriRef("urn:iks-project:enhancer:test:text-annotation:"+randomUUID()), TextAnnotation.class); - textAnnotation.setCreator(new UriRef("urn:iks-project:enhancer:test:dummyEngine")); + new IRI("urn:iks-project:enhancer:test:text-annotation:"+randomUUID()), TextAnnotation.class); + textAnnotation.setCreator(new IRI("urn:iks-project:enhancer:test:dummyEngine")); textAnnotation.setCreated(new Date()); textAnnotation.setSelectedText(name); textAnnotation.setSelectionContext(context); @@ -229,7 +228,7 @@ public class TestEntityLinkingEnhancemen } private static int validateAllEntityAnnotations(NamedEntityTaggingEngine entityLinkingEngine, ContentItem ci){ - Map<UriRef,Resource> expectedValues = new HashMap<UriRef,Resource>(); + Map<IRI,RDFTerm> expectedValues = new HashMap<IRI,RDFTerm>(); expectedValues.put(ENHANCER_EXTRACTED_FROM, ci.getUri()); expectedValues.put(DC_CREATOR,LiteralFactory.getInstance().createTypedLiteral( entityLinkingEngine.getClass().getName())); @@ -239,7 +238,7 @@ public class TestEntityLinkingEnhancemen expectedValues.put(Properties.ENHANCER_CONFIDENCE, null); int entityAnnotationCount = 0; while (entityAnnotationIterator.hasNext()) { - UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject(); + IRI entityAnnotation = (IRI) entityAnnotationIterator.next().getSubject(); // test if selected Text is added validateEntityAnnotation(ci.getMetadata(), entityAnnotation, expectedValues); //fise:confidence now checked by EnhancementStructureHelper (STANBOL-630) @@ -255,12 +254,12 @@ public class TestEntityLinkingEnhancemen // +"',entityAnnotation "+entityAnnotation+")", // 0.0 <= confidence.doubleValue()); //Test the entityhub:site property (STANBOL-625) - UriRef ENTITYHUB_SITE = new UriRef(RdfResourceEnum.site.getUri()); + IRI ENTITYHUB_SITE = new IRI(RdfResourceEnum.site.getUri()); Iterator<Triple> entitySiteIterator = ci.getMetadata().filter(entityAnnotation, ENTITYHUB_SITE, null); assertTrue("Expected entityhub:site value is missing (entityAnnotation " +entityAnnotation+")",entitySiteIterator.hasNext()); - Resource siteResource = entitySiteIterator.next().getObject(); + RDFTerm siteResource = entitySiteIterator.next().getObject(); assertTrue("entityhub:site values MUST BE Literals", siteResource instanceof Literal); assertEquals("'dbpedia' is expected as entityhub:site value", "dbpedia", ((Literal)siteResource).getLexicalForm()); assertFalse("entityhub:site MUST HAVE only a single value", entitySiteIterator.hasNext()); Modified: stanbol/trunk/enhancement-engines/geonames/src/main/java/org/apache/stanbol/enhancer/engines/geonames/impl/LocationEnhancementEngine.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/geonames/src/main/java/org/apache/stanbol/enhancer/engines/geonames/impl/LocationEnhancementEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/geonames/src/main/java/org/apache/stanbol/enhancer/engines/geonames/impl/LocationEnhancementEngine.java (original) +++ stanbol/trunk/enhancement-engines/geonames/src/main/java/org/apache/stanbol/enhancer/engines/geonames/impl/LocationEnhancementEngine.java Tue May 17 22:20:49 2016 @@ -44,12 +44,12 @@ import java.util.Map; import java.util.Set; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; @@ -96,9 +96,9 @@ public class LocationEnhancementEngine /** * This maps geonames.org feature classes to dbpedia.org ontology classes */ - public static final Map<FeatureClass, Collection<UriRef>> FEATURE_CLASS_CONCEPT_MAPPINGS; + public static final Map<FeatureClass, Collection<IRI>> FEATURE_CLASS_CONCEPT_MAPPINGS; - public static final Map<String, Collection<UriRef>> FEATURE_TYPE_CONCEPT_MAPPINGS; + public static final Map<String, Collection<IRI>> FEATURE_TYPE_CONCEPT_MAPPINGS; private static final Logger log = LoggerFactory.getLogger(LocationEnhancementEngine.class); @@ -129,7 +129,7 @@ public class LocationEnhancementEngine @Property(doubleValue = DEFAULT_MIN_HIERARCHY_SCORE) public static final String MIN_HIERARCHY_SCORE = "org.apache.stanbol.enhancer.engines.geonames.locationEnhancementEngine.min-hierarchy-score"; - public static final UriRef CONCEPT_GEONAMES_FEATURE = new UriRef(NamespaceEnum.geonames.toString() + "Feature"); + public static final IRI CONCEPT_GEONAMES_FEATURE = new IRI(NamespaceEnum.geonames.toString() + "Feature"); @Property(value = GeonamesAPIWrapper.DEFAULT_GEONAMES_ORG_WEBSERVICE_URL) public static final String GEONAMES_SERVER_URL = "org.apache.stanbol.enhancer.engines.geonames.locationEnhancementEngine.serverURL"; /** @@ -156,28 +156,28 @@ public class LocationEnhancementEngine protected GeonamesAPIWrapper geonamesService; static { - Map<FeatureClass, Collection<UriRef>> mappings = new EnumMap<FeatureClass, Collection<UriRef>>(FeatureClass.class); + Map<FeatureClass, Collection<IRI>> mappings = new EnumMap<FeatureClass, Collection<IRI>>(FeatureClass.class); //first add the concepts of the geonames ontology for (FeatureClass fc : FeatureClass.values()) { - List<UriRef> conceptMappings = new ArrayList<UriRef>(); + List<IRI> conceptMappings = new ArrayList<IRI>(); conceptMappings.add(CONCEPT_GEONAMES_FEATURE); //all things are features conceptMappings.add(DBPEDIA_PLACE); //all things are dbpedia places mappings.put(fc, conceptMappings); } //now add additional mappings to the dbpedia Ontology - UriRef populatedPlace = new UriRef(dbpedia_ont + "PopulatedPlace"); - mappings.get(FeatureClass.P).addAll(Arrays.asList(populatedPlace, new UriRef(dbpedia_ont + "Settlement"))); - mappings.get(FeatureClass.A).addAll(Arrays.asList(populatedPlace, new UriRef(dbpedia_ont + "AdministrativeRegion"))); - mappings.get(FeatureClass.H).add(new UriRef(dbpedia_ont + "BodyOfWater")); - mappings.get(FeatureClass.R).add(new UriRef(dbpedia_ont + "Infrastructure")); - mappings.get(FeatureClass.S).add(new UriRef(dbpedia_ont + "Building")); - mappings.get(FeatureClass.T).add(new UriRef(dbpedia_ont + "Mountain")); + IRI populatedPlace = new IRI(dbpedia_ont + "PopulatedPlace"); + mappings.get(FeatureClass.P).addAll(Arrays.asList(populatedPlace, new IRI(dbpedia_ont + "Settlement"))); + mappings.get(FeatureClass.A).addAll(Arrays.asList(populatedPlace, new IRI(dbpedia_ont + "AdministrativeRegion"))); + mappings.get(FeatureClass.H).add(new IRI(dbpedia_ont + "BodyOfWater")); + mappings.get(FeatureClass.R).add(new IRI(dbpedia_ont + "Infrastructure")); + mappings.get(FeatureClass.S).add(new IRI(dbpedia_ont + "Building")); + mappings.get(FeatureClass.T).add(new IRI(dbpedia_ont + "Mountain")); //now write the unmodifiable static final constant FEATURE_CLASS_CONCEPT_MAPPINGS = Collections.unmodifiableMap(mappings); //Mappings for known FeatureTypes - Map<String, Collection<UriRef>> typeMappings = new HashMap<String, Collection<UriRef>>(); - Collection<UriRef> lakeTypes = Arrays.asList(new UriRef(dbpedia_ont + "Lake")); + Map<String, Collection<IRI>> typeMappings = new HashMap<String, Collection<IRI>>(); + Collection<IRI> lakeTypes = Arrays.asList(new IRI(dbpedia_ont + "Lake")); typeMappings.put("H.LK", lakeTypes); typeMappings.put("H.LKS", lakeTypes); typeMappings.put("H.LKI", lakeTypes); @@ -195,8 +195,8 @@ public class LocationEnhancementEngine typeMappings.put("H.LKSNI", lakeTypes); typeMappings.put("H.RSV", lakeTypes); - UriRef stream = new UriRef(dbpedia_ont + " Stream"); - Collection<UriRef> canalTypes = Arrays.asList(stream, new UriRef(dbpedia_ont + "Canal")); + IRI stream = new IRI(dbpedia_ont + " Stream"); + Collection<IRI> canalTypes = Arrays.asList(stream, new IRI(dbpedia_ont + "Canal")); typeMappings.put("H.CNL", canalTypes); typeMappings.put("H.CNLA", canalTypes); typeMappings.put("H.CNLB", canalTypes); @@ -207,7 +207,7 @@ public class LocationEnhancementEngine typeMappings.put("H.CNLQ", canalTypes); typeMappings.put("H.CNLX", canalTypes); - Collection<UriRef> riverTypes = Arrays.asList(stream, new UriRef(dbpedia_ont + "River")); + Collection<IRI> riverTypes = Arrays.asList(stream, new IRI(dbpedia_ont + "River")); typeMappings.put("H.STM", riverTypes); typeMappings.put("H.STMI", riverTypes); typeMappings.put("H.STMB", riverTypes); @@ -225,18 +225,18 @@ public class LocationEnhancementEngine typeMappings.put("H.STM", riverTypes); typeMappings.put("H.STM", riverTypes); - Collection<UriRef> caveTypes = Arrays.asList(new UriRef(dbpedia_ont + "Cave")); + Collection<IRI> caveTypes = Arrays.asList(new IRI(dbpedia_ont + "Cave")); typeMappings.put("H.LKSB", caveTypes); typeMappings.put("R.TNLN", caveTypes); typeMappings.put("S.CAVE", caveTypes); typeMappings.put("S.BUR", caveTypes); - Collection<UriRef> countryTypes = Arrays.asList(new UriRef(dbpedia_ont + "Country")); + Collection<IRI> countryTypes = Arrays.asList(new IRI(dbpedia_ont + "Country")); typeMappings.put("A.PCLI", countryTypes); - UriRef settlement = new UriRef(dbpedia_ont + "Settlement"); - Collection<UriRef> cityTypes = Arrays.asList(settlement, new UriRef(dbpedia_ont + "City")); - Collection<UriRef> villageTypes = Arrays.asList(settlement, new UriRef(dbpedia_ont + "Village")); + IRI settlement = new IRI(dbpedia_ont + "Settlement"); + Collection<IRI> cityTypes = Arrays.asList(settlement, new IRI(dbpedia_ont + "City")); + Collection<IRI> villageTypes = Arrays.asList(settlement, new IRI(dbpedia_ont + "Village")); typeMappings.put("P.PPLG", cityTypes); typeMappings.put("P.PPLC", cityTypes); typeMappings.put("P.PPLF", villageTypes); @@ -314,8 +314,8 @@ public class LocationEnhancementEngine @Override public void computeEnhancements(ContentItem ci) throws EngineException { - UriRef contentItemId = ci.getUri(); - MGraph graph = ci.getMetadata(); + IRI contentItemId = ci.getUri(); + Graph graph = ci.getMetadata(); LiteralFactory literalFactory = LiteralFactory.getInstance(); //get all the textAnnotations /* @@ -324,10 +324,10 @@ public class LocationEnhancementEngine * this map is used to avoid multiple lookups for text annotations * selecting the same name. */ - Map<String, Collection<NonLiteral>> name2placeEnhancementMap = new HashMap<String, Collection<NonLiteral>>(); + Map<String, Collection<BlankNodeOrIRI>> name2placeEnhancementMap = new HashMap<String, Collection<BlankNodeOrIRI>>(); Iterator<Triple> iterator = graph.filter(null, DC_TYPE, DBPEDIA_PLACE); while (iterator.hasNext()) { - NonLiteral placeEnhancement = iterator.next().getSubject(); //the enhancement annotating an place + BlankNodeOrIRI placeEnhancement = iterator.next().getSubject(); //the enhancement annotating an place //this can still be an TextAnnotation of an EntityAnnotation //so we need to filter TextAnnotation Triple isTextAnnotation = new TripleImpl(placeEnhancement, RDF_TYPE, ENHANCER_TEXTANNOTATION); @@ -338,9 +338,9 @@ public class LocationEnhancementEngine log.warn("Unable to process TextAnnotation " + placeEnhancement + " because property" + ENHANCER_SELECTED_TEXT + " is not present"); } else { - Collection<NonLiteral> placeEnhancements = name2placeEnhancementMap.get(name); + Collection<BlankNodeOrIRI> placeEnhancements = name2placeEnhancementMap.get(name); if (placeEnhancements == null) { - placeEnhancements = new ArrayList<NonLiteral>(); + placeEnhancements = new ArrayList<BlankNodeOrIRI>(); name2placeEnhancementMap.put(name, placeEnhancements); } placeEnhancements.add(placeEnhancement); @@ -355,7 +355,7 @@ public class LocationEnhancementEngine if (getMaxLocationEnhancements() != null) { requestParams.put(SearchRequestPropertyEnum.maxRows, Collections.singleton(getMaxLocationEnhancements().toString())); } - for (Map.Entry<String, Collection<NonLiteral>> entry : name2placeEnhancementMap.entrySet()) { + for (Map.Entry<String, Collection<BlankNodeOrIRI>> entry : name2placeEnhancementMap.entrySet()) { List<Toponym> results; try { requestParams.put(SearchRequestPropertyEnum.name, Collections.singleton(entry.getKey())); @@ -391,7 +391,7 @@ public class LocationEnhancementEngine */ } //write the enhancement! - NonLiteral locationEnhancement = writeEntityEnhancement( + BlankNodeOrIRI locationEnhancement = writeEntityEnhancement( contentItemId, graph, literalFactory, result, entry.getValue(), null, score); log.debug(" > {} >= {}",score,minHierarchyScore); if (score != null && score >= minHierarchyScore) { @@ -475,24 +475,24 @@ public class LocationEnhancementEngine * used to parse the score of the Toponym if this method is used to add a * parent Toponym. * - * @return The UriRef of the created entity enhancement + * @return The IRI of the created entity enhancement */ - private UriRef writeEntityEnhancement(UriRef contentItemId, MGraph graph, + private IRI writeEntityEnhancement(IRI contentItemId, Graph graph, LiteralFactory literalFactory, Toponym toponym, - Collection<NonLiteral> relatedEnhancements, Collection<NonLiteral> requiresEnhancements, + Collection<BlankNodeOrIRI> relatedEnhancements, Collection<BlankNodeOrIRI> requiresEnhancements, Double score) { - UriRef entityRef = new UriRef("http://sws.geonames.org/" + toponym.getGeoNameId() + '/'); + IRI entityRef = new IRI("http://sws.geonames.org/" + toponym.getGeoNameId() + '/'); FeatureClass featureClass = toponym.getFeatureClass(); log.debug(" > featureClass " + featureClass); - UriRef entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(graph, this, contentItemId); + IRI entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(graph, this, contentItemId); // first relate this entity annotation to the text annotation(s) if (relatedEnhancements != null) { - for (NonLiteral related : relatedEnhancements) { + for (BlankNodeOrIRI related : relatedEnhancements) { graph.add(new TripleImpl(entityAnnotation, DC_RELATION, related)); } } if (requiresEnhancements != null) { - for (NonLiteral requires : requiresEnhancements) { + for (BlankNodeOrIRI requires : requiresEnhancements) { graph.add(new TripleImpl(entityAnnotation, DC_REQUIRES, requires)); //STANBOL-767: also add dc:relation link graph.add(new TripleImpl(entityAnnotation, DC_RELATION, requires)); @@ -505,22 +505,22 @@ public class LocationEnhancementEngine graph.add(new TripleImpl(entityAnnotation, ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(score))); } //now get all the entity types for the results - Set<UriRef> entityTypes = new HashSet<UriRef>(); + Set<IRI> entityTypes = new HashSet<IRI>(); //first based on the feature class - Collection<UriRef> featureClassTypes = FEATURE_CLASS_CONCEPT_MAPPINGS.get(featureClass); + Collection<IRI> featureClassTypes = FEATURE_CLASS_CONCEPT_MAPPINGS.get(featureClass); if (featureClassTypes != null) { entityTypes.addAll(featureClassTypes); } //second for the feature Code String featureCode = toponym.getFeatureCode(); - Collection<UriRef> featureCodeTypes = FEATURE_TYPE_CONCEPT_MAPPINGS.get(featureCode); + Collection<IRI> featureCodeTypes = FEATURE_TYPE_CONCEPT_MAPPINGS.get(featureCode); if (featureCodeTypes != null) { entityTypes.addAll(featureCodeTypes); } //third add the feature Code as additional type - entityTypes.add(new UriRef(NamespaceEnum.geonames + featureClass.name() + '.' + featureCode)); + entityTypes.add(new IRI(NamespaceEnum.geonames + featureClass.name() + '.' + featureCode)); //finally add the type triples to the enhancement - for (UriRef entityType : entityTypes) { + for (IRI entityType : entityTypes) { graph.add(new TripleImpl(entityAnnotation, ENHANCER_ENTITY_TYPE, entityType)); } return entityAnnotation; Modified: stanbol/trunk/enhancement-engines/geonames/src/test/java/org/apache/stanbol/enhancer/engines/geonames/impl/TestLocationEnhancementEngine.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/geonames/src/test/java/org/apache/stanbol/enhancer/engines/geonames/impl/TestLocationEnhancementEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/geonames/src/test/java/org/apache/stanbol/enhancer/engines/geonames/impl/TestLocationEnhancementEngine.java (original) +++ stanbol/trunk/enhancement-engines/geonames/src/test/java/org/apache/stanbol/enhancer/engines/geonames/impl/TestLocationEnhancementEngine.java Tue May 17 22:20:49 2016 @@ -33,8 +33,8 @@ import java.util.Hashtable; import java.util.Map; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.commons.io.IOUtils; import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory; import org.apache.stanbol.enhancer.rdfentities.RdfEntityFactory; @@ -102,10 +102,10 @@ public class TestLocationEnhancementEngi public static ContentItem getContentItem(final String id, final String text) throws IOException { - return ciFactory.createContentItem(new UriRef(id), new StringSource(text)); + return ciFactory.createContentItem(new IRI(id), new StringSource(text)); } - public static void getTextAnnotation(ContentItem ci, String name, String context, UriRef type) { + public static void getTextAnnotation(ContentItem ci, String name, String context, IRI type) { String content; try { content = IOUtils.toString(ci.getStream(),"UTF-8"); @@ -114,8 +114,8 @@ public class TestLocationEnhancementEngi content = ""; } RdfEntityFactory factory = RdfEntityFactory.createInstance(ci.getMetadata()); - TextAnnotation testAnnotation = factory.getProxy(new UriRef("urn:org.apache:stanbol.enhancer:test:text-annotation:person"), TextAnnotation.class); - testAnnotation.setCreator(new UriRef("urn:org.apache:stanbol.enhancer:test:dummyEngine")); + TextAnnotation testAnnotation = factory.getProxy(new IRI("urn:org.apache:stanbol.enhancer:test:text-annotation:person"), TextAnnotation.class); + testAnnotation.setCreator(new IRI("urn:org.apache:stanbol.enhancer:test:dummyEngine")); testAnnotation.setCreated(new Date()); testAnnotation.setSelectedText(name); testAnnotation.setSelectionContext(context); @@ -144,7 +144,7 @@ public class TestLocationEnhancementEngi RemoteServiceHelper.checkServiceUnavailable(e, "overloaded with requests"); return; } - Map<UriRef,Resource> expectedValues = new HashMap<UriRef,Resource>(); + Map<IRI,RDFTerm> expectedValues = new HashMap<IRI,RDFTerm>(); expectedValues.put(Properties.ENHANCER_EXTRACTED_FROM, ci.getUri()); expectedValues.put(Properties.DC_CREATOR, LiteralFactory.getInstance().createTypedLiteral( locationEnhancementEngine.getClass().getName())); Modified: stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/HtmlExtractorEngine.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/HtmlExtractorEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/HtmlExtractorEngine.java (original) +++ stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/HtmlExtractorEngine.java Tue May 17 22:20:49 2016 @@ -25,9 +25,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Reference; @@ -153,7 +153,7 @@ public class HtmlExtractorEngine extends @Override public void computeEnhancements(ContentItem ci) throws EngineException { HtmlExtractor extractor = new HtmlExtractor(htmlExtractorRegistry, htmlParser); - MGraph model = new SimpleMGraph(); + Graph model = new SimpleGraph(); ci.getLock().readLock().lock(); try { extractor.extract(ci.getUri().getUnicodeString(), ci.getStream(),null, ci.getMimeType(), model); @@ -166,7 +166,7 @@ public class HtmlExtractorEngine extends ClerezzaRDFUtils.urifyBlankNodes(model); // make the model single rooted if (singleRootRdf) { - ClerezzaRDFUtils.makeConnected(model,ci.getUri(),new UriRef(NIE_NS+"contains")); + ClerezzaRDFUtils.makeConnected(model,ci.getUri(),new IRI(NIE_NS+"contains")); } //add the extracted triples to the metadata of the ContentItem ci.getLock().writeLock().lock(); Modified: stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/BundleURIResolver.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/BundleURIResolver.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/BundleURIResolver.java (original) +++ stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/BundleURIResolver.java Tue May 17 22:20:49 2016 @@ -55,7 +55,7 @@ public class BundleURIResolver implement String path = baseURI.getPath(); resource = path.substring(1, path.lastIndexOf('/') + 1) + href; newUrl = BUNDLE.getEntry(resource); - LOG.debug("Resource: " + resource); + LOG.debug("RDFTerm: " + resource); if (newUrl != null) { return new StreamSource(newUrl.openStream(), newUrl.toString()); } else { Modified: stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/ClerezzaRDFUtils.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/ClerezzaRDFUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/ClerezzaRDFUtils.java (original) +++ stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/ClerezzaRDFUtils.java Tue May 17 22:20:49 2016 @@ -23,14 +23,14 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.apache.clerezza.rdf.core.BNode; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.BlankNode; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,30 +50,30 @@ public final class ClerezzaRDFUtils { private static final Logger LOG = LoggerFactory.getLogger(ClerezzaRDFUtils.class); - public static void urifyBlankNodes(MGraph model) { - HashMap<BNode,UriRef> blankNodeMap = new HashMap<BNode,UriRef>(); - MGraph remove = new SimpleMGraph(); - MGraph add = new SimpleMGraph(); + public static void urifyBlankNodes(Graph model) { + HashMap<BlankNode,IRI> blankNodeMap = new HashMap<BlankNode,IRI>(); + Graph remove = new SimpleGraph(); + Graph add = new SimpleGraph(); for (Triple t: model) { - NonLiteral subj = t.getSubject(); - Resource obj = t.getObject(); - UriRef pred = t.getPredicate(); + BlankNodeOrIRI subj = t.getSubject(); + RDFTerm obj = t.getObject(); + IRI pred = t.getPredicate(); boolean match = false; - if (subj instanceof BNode) { + if (subj instanceof BlankNode) { match = true; - UriRef ru = blankNodeMap.get(subj); + IRI ru = blankNodeMap.get(subj); if (ru == null) { ru = createRandomUri(); - blankNodeMap.put((BNode)subj, ru); + blankNodeMap.put((BlankNode)subj, ru); } subj = ru; } - if (obj instanceof BNode) { + if (obj instanceof BlankNode) { match = true; - UriRef ru = blankNodeMap.get(obj); + IRI ru = blankNodeMap.get(obj); if (ru == null) { ru = createRandomUri(); - blankNodeMap.put((BNode)obj, ru); + blankNodeMap.put((BlankNode)obj, ru); } obj = ru; } @@ -86,31 +86,31 @@ public final class ClerezzaRDFUtils { model.addAll(add); } - public static UriRef createRandomUri() { - return new UriRef("urn:rnd:"+randomUUID()); + public static IRI createRandomUri() { + return new IRI("urn:rnd:"+randomUUID()); } - public static void makeConnected(MGraph model, NonLiteral root, UriRef property) { - Set<NonLiteral> roots = findRoots(model); + public static void makeConnected(Graph model, BlankNodeOrIRI root, IRI property) { + Set<BlankNodeOrIRI> roots = findRoots(model); LOG.debug("Roots: {}",roots.size()); boolean found = roots.remove(root); //connect all hanging roots to root by property - for (NonLiteral n: roots) { + for (BlankNodeOrIRI n: roots) { model.add(new TripleImpl(root,property,n)); } } - public static Set<NonLiteral> findRoots(MGraph model) { - Set<NonLiteral> roots = new HashSet<NonLiteral>(); - Set<NonLiteral> visited = new HashSet<NonLiteral>(); + public static Set<BlankNodeOrIRI> findRoots(Graph model) { + Set<BlankNodeOrIRI> roots = new HashSet<BlankNodeOrIRI>(); + Set<BlankNodeOrIRI> visited = new HashSet<BlankNodeOrIRI>(); for (Triple t: model) { - NonLiteral subj = t.getSubject(); + BlankNodeOrIRI subj = t.getSubject(); findRoot(model, subj, roots, visited); } return roots; } - private static void findRoot(MGraph model, NonLiteral node, Set<NonLiteral> roots, Set<NonLiteral> visited) { + private static void findRoot(Graph model, BlankNodeOrIRI node, Set<BlankNodeOrIRI> roots, Set<BlankNodeOrIRI> visited) { if (visited.contains(node)) { return; } @@ -124,7 +124,7 @@ public final class ClerezzaRDFUtils { } while (it.hasNext()) { Triple t = it.next(); - NonLiteral subj = t.getSubject(); + BlankNodeOrIRI subj = t.getSubject(); findRoot(model, subj, roots, visited); } } Modified: stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractionComponent.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractionComponent.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractionComponent.java (original) +++ stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractionComponent.java Tue May 17 22:20:49 2016 @@ -18,7 +18,7 @@ package org.apache.stanbol.enhancer.engi import java.util.Map; -import org.apache.clerezza.rdf.core.MGraph; +import org.apache.clerezza.commons.rdf.Graph; import org.w3c.dom.Document; /** @@ -29,7 +29,7 @@ import org.w3c.dom.Document; */ public interface HtmlExtractionComponent { - void extract(String id, Document doc, Map<String, Object> params, MGraph result) + void extract(String id, Document doc, Map<String, Object> params, Graph result) throws ExtractorException; } Modified: stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractor.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractor.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractor.java (original) +++ stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/HtmlExtractor.java Tue May 17 22:20:49 2016 @@ -26,9 +26,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -72,7 +72,7 @@ public class HtmlExtractor { public void extract(String id, InputStream input, Charset charset, String mimeType, - MGraph result) + Graph result) throws ExtractorException { if (registry == null) return; @@ -121,8 +121,8 @@ public class HtmlExtractor { InputStream input = new FileInputStream(file); Charset charset = Charset.forName("UTF-8"); String mimeType = "text/html"; - UriRef uri = new UriRef(file.toURI().toString()); - MGraph container = new SimpleMGraph(); + IRI uri = new IRI(file.toURI().toString()); + Graph container = new SimpleGraph(); inst.extract(uri.getUnicodeString(), input, charset, mimeType, container); System.out.println("Model for " + args[i]); //TODO Modified: stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/XsltExtractor.java URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/XsltExtractor.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/XsltExtractor.java (original) +++ stanbol/trunk/enhancement-engines/htmlextractor/src/main/java/org/apache/stanbol/enhancer/engines/htmlextractor/impl/XsltExtractor.java Tue May 17 22:20:49 2016 @@ -36,8 +36,8 @@ import javax.xml.transform.dom.DOMSource import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.apache.clerezza.rdf.core.Graph; -import org.apache.clerezza.rdf.core.MGraph; +import org.apache.clerezza.commons.rdf.ImmutableGraph; +import org.apache.clerezza.commons.rdf.Graph; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -126,7 +126,7 @@ public class XsltExtractor implements Ht } public synchronized void extract(String id, Document doc, Map<String, Object> params, - MGraph result) + Graph result) throws ExtractorException { if (params == null) { @@ -145,7 +145,7 @@ public class XsltExtractor implements Ht } InputStream reader = new ByteArrayInputStream(writer.toByteArray()); Parser rdfParser = Parser.getInstance(); - Graph graph = rdfParser.parse(reader, this.syntax); + ImmutableGraph graph = rdfParser.parse(reader, this.syntax); result.addAll(graph); } catch (TransformerException e) { throw new ExtractorException(e.getMessage(), e);
