You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by re...@apache.org on 2016/05/17 22:20:55 UTC
svn commit: r1744328 [6/24] - in /stanbol/trunk: ./
commons/indexedgraph/src/main/java/org/apache/stanbol/commons/indexedgraph/
commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/
commons/installer/bundleprovider/src/main/java/o...
Modified: stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/EntityCoMentionEngine.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/EntityCoMentionEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/EntityCoMentionEngine.java (original)
+++ stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/EntityCoMentionEngine.java Tue May 17 22:20:49 2016
@@ -47,16 +47,16 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-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.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.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.PlainLiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -199,8 +199,8 @@ public class EntityCoMentionEngine exten
linkerConfig.setRedirectProcessingMode(RedirectProcessingMode.IGNORE);
//remove all type mappings
linkerConfig.setDefaultDcType(null);
- Set<UriRef> mappedUris = new HashSet<UriRef>(linkerConfig.getTypeMappings().keySet());
- for(UriRef mappedUri : mappedUris){
+ Set<IRI> mappedUris = new HashSet<IRI>(linkerConfig.getTypeMappings().keySet());
+ for(IRI mappedUri : mappedUris){
linkerConfig.setTypeMapping(mappedUri.getUnicodeString(), null);
}
//parse confidence adjustment value (STANBOL-1219)
@@ -283,12 +283,12 @@ public class EntityCoMentionEngine exten
//create the in-memory database for the mentioned Entities
ContentItemMentionBuilder entityMentionIndex = new ContentItemMentionBuilder(
labelTokenizer, language, linkerConfig.getDefaultLanguage());
- MGraph metadata = ci.getMetadata();
- Set<UriRef> textAnnotations = new HashSet<UriRef>();
+ Graph metadata = ci.getMetadata();
+ Set<IRI> textAnnotations = new HashSet<IRI>();
ci.getLock().readLock().lock();
try { //iterate over all TextAnnotations (mentions of Entities)
for(Iterator<Triple> it = metadata.filter(null, RDF_TYPE, ENHANCER_TEXTANNOTATION); it.hasNext();){
- UriRef ta = (UriRef)it.next().getSubject();
+ IRI ta = (IRI)it.next().getSubject();
entityMentionIndex.registerTextAnnotation(ta, metadata);
textAnnotations.add(ta); //store the registered text annotations
}
@@ -314,21 +314,21 @@ public class EntityCoMentionEngine exten
}
private void writeComentions(ContentItem ci,Collection<LinkedEntity> comentions, String language,
- Set<UriRef> textAnnotations) {
+ Set<IRI> textAnnotations) {
Language languageObject = null;
if(language != null && !language.isEmpty()){
languageObject = new Language(language);
}
- MGraph metadata = ci.getMetadata();
+ Graph metadata = ci.getMetadata();
//we MUST adjust the confidence level of existing annotations only once
//se we need to keep track of those
- Set<NonLiteral> adjustedSuggestions = new HashSet<NonLiteral>();
+ Set<BlankNodeOrIRI> adjustedSuggestions = new HashSet<BlankNodeOrIRI>();
log.debug("Write Co-Mentions:");
for(LinkedEntity comention : comentions){
log.debug(" > {}",comention);
//URIs of TextAnnotations for the initial mention of this co-mention
- Collection<UriRef> initialMentions = new ArrayList<UriRef>(comention.getSuggestions().size());
+ Collection<IRI> initialMentions = new ArrayList<IRI>(comention.getSuggestions().size());
for(Suggestion suggestion : comention.getSuggestions()){
Entity entity = suggestion.getEntity();
if(textAnnotations.contains(entity.getUri())){
@@ -344,14 +344,14 @@ public class EntityCoMentionEngine exten
//search for existing text annotation
boolean ignore = false;
//search for textAnnotations with the same end
- UriRef textAnnotation = null;
+ IRI textAnnotation = null;
Iterator<Triple> it = metadata.filter(null, ENHANCER_START, startLiteral);
while(it.hasNext()){
Triple t = it.next();
Integer end = EnhancementEngineHelper.get(metadata, t.getSubject(), ENHANCER_END, Integer.class, literalFactory);
if(end != null && textAnnotations.contains(t.getSubject())){
//metadata.filter(t.getSubject(), RDF_TYPE, ENHANCER_TEXTANNOTATION).hasNext()){
- textAnnotation = (UriRef)t.getSubject();
+ textAnnotation = (IRI)t.getSubject();
if(end > occurrence.getEnd()){
// there is an other TextAnnotation selecting a bigger Span
//so we should ignore this Occurrence
@@ -365,7 +365,7 @@ public class EntityCoMentionEngine exten
Integer start = EnhancementEngineHelper.get(metadata, t.getSubject(), ENHANCER_START, Integer.class, literalFactory);
if(start != null && textAnnotations.contains(t.getSubject())){
//metadata.filter(t.getSubject(), RDF_TYPE, ENHANCER_TEXTANNOTATION).hasNext()){
- textAnnotation = (UriRef)t.getSubject();
+ textAnnotation = (IRI)t.getSubject();
if(start < occurrence.getStart()){
// there is an other TextAnnotation selecting a bigger Span
//so we should ignore this Occurrence
@@ -399,10 +399,10 @@ public class EntityCoMentionEngine exten
// ENHANCER_CONFIDENCE, Double.class, literalFactory);
}
//now process initial mention(s) for the co-mention
- Set<UriRef> dcTypes = new HashSet<UriRef>();
- for(UriRef initialMention : initialMentions){
+ Set<IRI> dcTypes = new HashSet<IRI>();
+ for(IRI initialMention : initialMentions){
//get the dc:type(s) of the initial mentions
- Iterator<UriRef> dcTypesIt = getReferences(metadata, initialMention, DC_TYPE);
+ Iterator<IRI> dcTypesIt = getReferences(metadata, initialMention, DC_TYPE);
while(dcTypesIt.hasNext()){
dcTypes.add(dcTypesIt.next());
}
@@ -419,12 +419,12 @@ public class EntityCoMentionEngine exten
//now we need to compare the suggestions of the initial
//mention(s) with the existing one.
//Get information about the suggestions of the initial mention
- Map<Resource,Double> initialSuggestions = new HashMap<Resource,Double>();
- Map<Resource, Resource> initialSuggestedEntities = new HashMap<Resource,Resource>();
+ Map<RDFTerm,Double> initialSuggestions = new HashMap<RDFTerm,Double>();
+ Map<RDFTerm, RDFTerm> initialSuggestedEntities = new HashMap<RDFTerm,RDFTerm>();
for(Iterator<Triple> suggestions = metadata.filter(null, DC_RELATION, initialMention); suggestions.hasNext();){
if(!textAnnotations.contains(suggestions)) {
- NonLiteral suggestion = suggestions.next().getSubject();
- Resource suggestedEntity = EnhancementEngineHelper.getReference(metadata, suggestion, ENHANCER_ENTITY_REFERENCE);
+ BlankNodeOrIRI suggestion = suggestions.next().getSubject();
+ RDFTerm suggestedEntity = EnhancementEngineHelper.getReference(metadata, suggestion, ENHANCER_ENTITY_REFERENCE);
if(suggestedEntity != null){ //it has a suggestion
Double confidence = EnhancementEngineHelper.get(
metadata, suggestion, ENHANCER_CONFIDENCE, Double.class, literalFactory);
@@ -441,18 +441,18 @@ public class EntityCoMentionEngine exten
}
//now we collect existing Suggestions for this TextAnnoation where we need
//to adjust the confidence (quite some things to check ....)
- Map<NonLiteral, Double> existingSuggestions = new HashMap<NonLiteral,Double>();
+ Map<BlankNodeOrIRI, Double> existingSuggestions = new HashMap<BlankNodeOrIRI,Double>();
if(maxConfidence != null && confidenceAdjustmentFactor < 1){
//suggestions are defined by incoming dc:releation
for(Iterator<Triple> esIt = metadata.filter(null, DC_RELATION, textAnnotation);esIt.hasNext();){
- NonLiteral existingSuggestion = esIt.next().getSubject();
+ BlankNodeOrIRI existingSuggestion = esIt.next().getSubject();
//but not all of them are suggestions
if(!textAnnotations.contains(existingSuggestion)) { //ignore fise:TextAnnotations
Double existingConfidence = EnhancementEngineHelper.get(metadata, existingSuggestion,
ENHANCER_CONFIDENCE, Double.class, literalFactory);
//ignore fise:TextAnnotations also suggested for the initial mention
if(!initialSuggestions.containsKey(existingSuggestion)){
- Resource suggestedEntity = EnhancementEngineHelper.getReference(metadata, existingSuggestion, ENHANCER_ENTITY_REFERENCE);
+ RDFTerm suggestedEntity = EnhancementEngineHelper.getReference(metadata, existingSuggestion, ENHANCER_ENTITY_REFERENCE);
//we might also have different fise:TextAnnotations that
//fise:entity-reference to an Entity present in the
//suggestions for the initial mention
@@ -463,7 +463,7 @@ public class EntityCoMentionEngine exten
} //else confidence already adjusted
} else { // different fise:EntityAnnotation, but same reference Entity
//we need to check confidences to decide what to do
- Resource initialSuggestion = initialSuggestedEntities.get(suggestedEntity);
+ RDFTerm initialSuggestion = initialSuggestedEntities.get(suggestedEntity);
Double initialConfidence = initialSuggestions.get(initialSuggestion);
if(initialConfidence == null || (existingConfidence != null &&
existingConfidence.compareTo(initialConfidence) >= 0)){
@@ -493,7 +493,7 @@ public class EntityCoMentionEngine exten
}
} //else ignore dc:relations to other fise:TextAnnotations
}
- for(Entry<NonLiteral,Double> entry : existingSuggestions.entrySet()){
+ for(Entry<BlankNodeOrIRI,Double> entry : existingSuggestions.entrySet()){
if(entry.getValue() != null){
double adjustedConfidence = entry.getValue() * confidenceAdjustmentFactor;
if(maxExistingConfidence == null || adjustedConfidence > maxExistingConfidence){
@@ -506,8 +506,8 @@ public class EntityCoMentionEngine exten
}
}
//add the suggestions of the initial mention to this one
- for(Resource suggestion : initialSuggestions.keySet()){
- metadata.add(new TripleImpl((NonLiteral)suggestion, DC_RELATION, textAnnotation));
+ for(RDFTerm suggestion : initialSuggestions.keySet()){
+ metadata.add(new TripleImpl((BlankNodeOrIRI)suggestion, DC_RELATION, textAnnotation));
}
//finally link the co-mentation with the initial one
@@ -524,7 +524,7 @@ public class EntityCoMentionEngine exten
maxConfidence.compareTo(maxExistingConfidence) >= 0);
boolean addCoMentionDcTypes = maxExistingConfidence == null ||
(maxConfidence != null && maxConfidence.compareTo(maxExistingConfidence) >= 1);
- Iterator<UriRef> existingDcTypesIt = getReferences(metadata, textAnnotation, DC_TYPE);
+ Iterator<IRI> existingDcTypesIt = getReferences(metadata, textAnnotation, DC_TYPE);
while(existingDcTypesIt.hasNext()){ //do not add existing
//remove dc:type triples if they are not re-added later and
//removeExistingDcTypes == true
@@ -534,7 +534,7 @@ public class EntityCoMentionEngine exten
}
}
if(addCoMentionDcTypes){
- for(UriRef dcType : dcTypes){ //add missing
+ for(IRI dcType : dcTypes){ //add missing
metadata.add(new TripleImpl(textAnnotation, DC_TYPE, dcType));
}
}
Modified: stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/ContentItemMentionBuilder.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/ContentItemMentionBuilder.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/ContentItemMentionBuilder.java (original)
+++ stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/ContentItemMentionBuilder.java Tue May 17 22:20:49 2016
@@ -33,11 +33,11 @@ import java.util.SortedMap;
import java.util.TreeMap;
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.TripleCollection;
-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.Graph;
+import org.apache.clerezza.commons.rdf.IRI;
import org.apache.stanbol.enhancer.engines.entitycomention.CoMentionConstants;
import org.apache.stanbol.enhancer.engines.entitylinking.LabelTokenizer;
import org.apache.stanbol.enhancer.engines.entitylinking.impl.LinkingStateAware;
@@ -64,7 +64,7 @@ public class ContentItemMentionBuilder e
super(labelTokenizer,CoMentionConstants.CO_MENTION_LABEL_FIELD, languages);
}
- public void registerTextAnnotation(UriRef textAnnotation, TripleCollection metadata){
+ public void registerTextAnnotation(IRI textAnnotation, Graph metadata){
String selectedText = EnhancementEngineHelper.getString(metadata, textAnnotation, ENHANCER_SELECTED_TEXT);
if(selectedText != null){
//NOTE: Typically it is not possible to find co-mentions for Entities with a
Modified: stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/EntityMention.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/EntityMention.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/EntityMention.java (original)
+++ stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/EntityMention.java Tue May 17 22:20:49 2016
@@ -18,10 +18,9 @@ package org.apache.stanbol.enhancer.engi
import java.util.Iterator;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.IRI;
+import org.apache.clerezza.commons.rdf.Literal;
import org.apache.commons.collections.IteratorUtils;
import org.apache.stanbol.enhancer.engines.entitycomention.CoMentionConstants;
import org.apache.stanbol.enhancer.engines.entitycomention.EntityCoMentionEngine;
@@ -31,7 +30,7 @@ import org.apache.stanbol.enhancer.engin
/**
* {@link Entity} implementation used by the {@link EntityCoMentionEngine}. It
- * overrides the {@link #getText(UriRef)} and {@link #getReferences(UriRef)}
+ * overrides the {@link #getText(IRI)} and {@link #getReferences(IRI)}
* methods to use the a different labelField if
* {@link CoMentionConstants#CO_MENTION_LABEL_FIELD} is parsed as parameter.
* This allows the {@link EntityLinker} to use different properties for different
@@ -43,11 +42,11 @@ public class EntityMention extends Entit
/**
* The label field of this Entity
*/
- private final UriRef nameField;
+ private final IRI nameField;
/**
* The type field of this Entity
*/
- private final UriRef typeField;
+ private final IRI typeField;
/**
* The start/end char indexes char index of the first mention
*/
@@ -58,15 +57,15 @@ public class EntityMention extends Entit
/**
* Creates a new MentionEntity for the parsed parameters
- * @param uri the {@link UriRef} of the Entity
- * @param data the {@link MGraph} with the data for the Entity
- * @param labelField the {@link UriRef} of the property holding the
+ * @param uri the {@link IRI} of the Entity
+ * @param data the {@link Graph} with the data for the Entity
+ * @param labelField the {@link IRI} of the property holding the
* labels of this Entity. This property will be used for all calls to
- * {@link #getText(UriRef)} and {@link #getReferences(UriRef)} if
+ * {@link #getText(IRI)} and {@link #getReferences(IRI)} if
* {@link CoMentionConstants#CO_MENTION_LABEL_FIELD} is parsed as parameter
* @param span the start/end char indexes of the mention
*/
- public EntityMention(UriRef uri, TripleCollection data, UriRef labelField, UriRef typeField, Integer[] span) {
+ public EntityMention(IRI uri, Graph data, IRI labelField, IRI typeField, Integer[] span) {
super(uri, data);
if(labelField == null){
throw new IllegalArgumentException("The LabelField MUST NOT be NULL!");
@@ -87,18 +86,18 @@ public class EntityMention extends Entit
* Wrapps the parsed Entity and redirects calls to
* {@link CoMentionConstants#CO_MENTION_LABEL_FIELD} to the parsed labelField
* @param entity the Entity to wrap
- * @param labelField the {@link UriRef} of the property holding the
+ * @param labelField the {@link IRI} of the property holding the
* labels of this Entity. This property will be used for all calls to
- * {@link #getText(UriRef)} and {@link #getReferences(UriRef)} if
+ * {@link #getText(IRI)} and {@link #getReferences(IRI)} if
* {@link CoMentionConstants#CO_MENTION_LABEL_FIELD} is parsed as parameter
* @param index the char index of the initial mention in the document
*/
- public EntityMention(Entity entity, UriRef labelField, UriRef typeField, Integer[] span) {
+ public EntityMention(Entity entity, IRI labelField, IRI typeField, Integer[] span) {
this(entity.getUri(), entity.getData(),labelField,typeField,span);
}
@Override
- public Iterator<PlainLiteral> getText(UriRef field) {
+ public Iterator<Literal> getText(IRI field) {
if(CO_MENTION_FIELD_HASH == field.hashCode() && //avoid calling equals
CoMentionConstants.CO_MENTION_LABEL_FIELD.equals(field)){
return super.getText(nameField);
@@ -111,7 +110,7 @@ public class EntityMention extends Entit
}
@Override
- public Iterator<UriRef> getReferences(UriRef field) {
+ public Iterator<IRI> getReferences(IRI field) {
if(CO_MENTION_FIELD_HASH == field.hashCode() && //avoid calling equals
CoMentionConstants.CO_MENTION_LABEL_FIELD.equals(field)){
return super.getReferences(nameField);
@@ -155,7 +154,7 @@ public class EntityMention extends Entit
* @return the field (property) used to obtain the labels of this mention
* @see EntityLinkerConfig#getNameField()
*/
- public UriRef getNameField() {
+ public IRI getNameField() {
return nameField;
}
/**
@@ -165,7 +164,7 @@ public class EntityMention extends Entit
* @return the field (property) used to obtain the type of this mention
* @see EntityLinkerConfig#getTypeField()
*/
- public UriRef getTypeField() {
+ public IRI getTypeField() {
return typeField;
}
Modified: stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/InMemoryEntityIndex.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/InMemoryEntityIndex.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/InMemoryEntityIndex.java (original)
+++ stanbol/trunk/enhancement-engines/entitycomention/src/main/java/org/apache/stanbol/enhancer/engines/entitycomention/impl/InMemoryEntityIndex.java Tue May 17 22:20:49 2016
@@ -32,13 +32,11 @@ import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.clerezza.rdf.core.Language;
-import org.apache.clerezza.rdf.core.MGraph;
-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.stanbol.commons.indexedgraph.IndexedMGraph;
+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.commons.indexedgraph.IndexedGraph;
import org.apache.stanbol.enhancer.engines.entitylinking.Entity;
import org.apache.stanbol.enhancer.engines.entitylinking.EntitySearcher;
import org.apache.stanbol.enhancer.engines.entitylinking.LabelTokenizer;
@@ -58,13 +56,13 @@ public class InMemoryEntityIndex impleme
protected final LabelTokenizer tokenizer;
//Holds Entity data
private SortedMap<String,Collection<Entity>> index = new TreeMap<String,Collection<Entity>>(String.CASE_INSENSITIVE_ORDER);
- private Map<UriRef,Entity> entities = new HashMap<UriRef,Entity>();
+ private Map<IRI,Entity> entities = new HashMap<IRI,Entity>();
private Set<String> indexLanguages;
protected String language;
- protected UriRef nameField;
+ protected IRI nameField;
- public InMemoryEntityIndex(LabelTokenizer tokenizer, UriRef nameField, String...languages) {
+ public InMemoryEntityIndex(LabelTokenizer tokenizer, IRI nameField, String...languages) {
this.indexLanguages = languages == null || languages.length < 1 ?
Collections.singleton((String)null) :
new HashSet<String>(Arrays.asList(languages));
@@ -80,9 +78,9 @@ public class InMemoryEntityIndex impleme
log.debug(" > register {}",entity);
}
entities.put(entity.getUri(), entity);
- Iterator<PlainLiteral> labels = entity.getText(nameField);
+ Iterator<Literal> labels = entity.getText(nameField);
while(labels.hasNext()){
- PlainLiteral label = labels.next();
+ Literal label = labels.next();
String lang = label.getLanguage() == null ? null : label.getLanguage().toString();
if(indexLanguages.contains(lang)){
for(String token : tokenizer.tokenize(label.getLexicalForm(),null)){
@@ -100,13 +98,13 @@ public class InMemoryEntityIndex impleme
}
@Override
- public Entity get(UriRef id, Set<UriRef> includeFields, String...languages) throws IllegalStateException {
+ public Entity get(IRI id, Set<IRI> includeFields, String...languages) 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 {
//this assumes that
@@ -233,7 +231,7 @@ public class InMemoryEntityIndex impleme
}
@Override
- public Map<UriRef,Collection<Resource>> getOriginInformation() {
+ public Map<IRI,Collection<RDFTerm>> getOriginInformation() {
return Collections.emptyMap();
}
}
Propchange: stanbol/trunk/enhancement-engines/entitycoreference/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 17 22:20:49 2016
@@ -0,0 +1 @@
+target
Modified: stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/datamodel/PlaceAdjectival.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/datamodel/PlaceAdjectival.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/datamodel/PlaceAdjectival.java (original)
+++ stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/datamodel/PlaceAdjectival.java Tue May 17 22:20:49 2016
@@ -16,7 +16,8 @@
*/
package org.apache.stanbol.enhancer.engines.entitycoreference.datamodel;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.IRI;
+
/**
* Represents a place adjectival inside a {@link Span}.
@@ -36,18 +37,18 @@ public class PlaceAdjectival {
private int endIdx;
/**
- * The {@link UriRef} in the {@link SiteManager} or {@link Entityhub} that this place adjectival points
+ * The {@link IRI} in the {@link SiteManager} or {@link Entityhub} that this place adjectival points
* to.
*/
- private UriRef placeUri;
+ private IRI placeUri;
- public PlaceAdjectival(int startIdx, int endIdx, UriRef placeUri) {
+ public PlaceAdjectival(int startIdx, int endIdx, IRI placeUri) {
this.startIdx = startIdx;
this.endIdx = endIdx;
this.placeUri = placeUri;
}
- public UriRef getPlaceUri() {
+ public IRI getPlaceUri() {
return placeUri;
}
Modified: stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinder.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinder.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinder.java (original)
+++ stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinder.java Tue May 17 22:20:49 2016
@@ -25,8 +25,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.clerezza.commons.rdf.IRI;
+
-import org.apache.clerezza.rdf.core.UriRef;
import org.apache.stanbol.enhancer.engines.entitycoreference.Constants;
import org.apache.stanbol.enhancer.engines.entitycoreference.datamodel.NounPhrase;
import org.apache.stanbol.enhancer.engines.entitycoreference.datamodel.PlaceAdjectival;
@@ -251,7 +252,7 @@ public class CoreferenceFinder {
*/
if (nounPhrase.hasNers()) {
List<Span> npNers = nounPhrase.getNerChunks();
- UriRef nerType = ner.getAnnotation(NlpAnnotations.NER_ANNOTATION).value().getType();
+ IRI nerType = ner.getAnnotation(NlpAnnotations.NER_ANNOTATION).value().getType();
for (Span npNer : npNers) {
/*
@@ -264,7 +265,7 @@ public class CoreferenceFinder {
Entity npEntity = lookupEntity(npNer, language);
if (npEntity != null) {
- UriRef npNerType = npNer.getAnnotation(NlpAnnotations.NER_ANNOTATION).value().getType();
+ IRI npNerType = npNer.getAnnotation(NlpAnnotations.NER_ANNOTATION).value().getType();
Set<String> rulesOntologyAttr = new HashSet<String>();
if (OntologicalClasses.DBPEDIA_PLACE.equals(npNerType)) {
@@ -327,7 +328,7 @@ public class CoreferenceFinder {
if (this.config.shouldExcludeClass(typeUri)) continue;
// First try the in memory index
- Set<String> labels = this.entityTypeIndex.lookupEntityType(new UriRef(typeUri), language);
+ Set<String> labels = this.entityTypeIndex.lookupEntityType(new IRI(typeUri), language);
if (labels == null) {
Site site = getReferencedSite();
@@ -343,7 +344,7 @@ public class CoreferenceFinder {
labels.add(labelIterator.next().getText());
}
- this.entityTypeIndex.addEntityType(new UriRef(typeUri), language, labels);
+ this.entityTypeIndex.addEntityType(new IRI(typeUri), language, labels);
}
}
Modified: stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinderConfig.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinderConfig.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinderConfig.java (original)
+++ stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/CoreferenceFinderConfig.java Tue May 17 22:20:49 2016
@@ -20,8 +20,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.UriRef;
import org.apache.stanbol.enhancer.engines.entitycoreference.datamodel.NounPhrase;
import org.apache.stanbol.enhancer.servicesapi.rdf.OntologicalClasses;
import org.osgi.service.cm.ConfigurationException;
@@ -42,12 +42,12 @@ public class CoreferenceFinderConfig {
/**
* The Uris for spatial properties for the NER to be inspected when doing the coref spatial match.
*/
- private Map<UriRef,Set<String>> spatialAttributes;
+ private Map<IRI,Set<String>> spatialAttributes;
/**
* The Uris for org membership properties for the NER to be inspected when doing the coref match.
*/
- private Map<UriRef,Set<String>> orgMembershipAttributes;
+ private Map<IRI,Set<String>> orgMembershipAttributes;
/**
* Entity classes which will not be used for coreference because they are too general.
@@ -62,8 +62,8 @@ public class CoreferenceFinderConfig {
String entityClassesToExclude) throws ConfigurationException {
this.maxDistance = maxDistance;
- this.spatialAttributes = new HashMap<UriRef,Set<String>>();
- this.orgMembershipAttributes = new HashMap<UriRef, Set<String>>();
+ this.spatialAttributes = new HashMap<IRI,Set<String>>();
+ this.orgMembershipAttributes = new HashMap<IRI, Set<String>>();
if (spatialAttrForPerson != null) {
Set<String> attributes = new HashSet<String>();
@@ -124,7 +124,7 @@ public class CoreferenceFinderConfig {
* of the Entity type for which we want to get the ontology.
* @return
*/
- public Set<String> getSpatialAttributes(UriRef uri) {
+ public Set<String> getSpatialAttributes(IRI uri) {
return this.spatialAttributes.get(uri);
}
@@ -135,7 +135,7 @@ public class CoreferenceFinderConfig {
* of the Entity type for which we want to get the ontology.
* @return
*/
- public Set<String> getOrgMembershipAttributes(UriRef uri) {
+ public Set<String> getOrgMembershipAttributes(IRI uri) {
return this.orgMembershipAttributes.get(uri);
}
Modified: stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/Dictionaries.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/Dictionaries.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/Dictionaries.java (original)
+++ stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/Dictionaries.java Tue May 17 22:20:49 2016
@@ -23,7 +23,8 @@ import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.IRI;
+
import org.apache.stanbol.enhancer.engines.entitycoreference.Constants;
import org.apache.stanbol.enhancer.engines.entitycoreference.datamodel.NounPhrase;
import org.apache.stanbol.enhancer.engines.entitycoreference.datamodel.PlaceAdjectival;
@@ -38,18 +39,18 @@ import org.osgi.service.cm.Configuration
*/
class Dictionaries {
/**
- * Contains the list of place adjectivals in the form: language -> adjectival -> UriRef -> adjectival ->
- * UriRef There are Places that have multiple adjectivals so in this map there are adjectivals that point
- * to the same UriRef but that ensures a fast lookup.
+ * Contains the list of place adjectivals in the form: language -> adjectival -> IRI -> adjectival ->
+ * IRI There are Places that have multiple adjectivals so in this map there are adjectivals that point
+ * to the same IRI but that ensures a fast lookup.
*/
- private Map<String,Map<String,UriRef>> placeAdjectivalsMap;
+ private Map<String,Map<String,IRI>> placeAdjectivalsMap;
public Dictionaries(String[] languages, String entityUriBase) throws ConfigurationException {
placeAdjectivalsMap = new HashMap<>();
for (String language : languages) {
String line = null;
- Map<String,UriRef> languagePlaceAdjMap = new HashMap<>();
+ Map<String,IRI> languagePlaceAdjMap = new HashMap<>();
InputStream langIn = null;
BufferedReader reader = null;
@@ -62,7 +63,7 @@ class Dictionaries {
String[] splittedLine = line.split("\t");
String place = splittedLine[0];
String adjectivals = splittedLine[1];
- UriRef ref = new UriRef(entityUriBase + place.trim());
+ IRI ref = new IRI(entityUriBase + place.trim());
String[] adjectivalsArray = adjectivals.split(",");
for (String adjectival : adjectivalsArray) {
@@ -99,7 +100,7 @@ class Dictionaries {
*/
public PlaceAdjectival findPlaceAdjectival(String language, NounPhrase nounPhrase) {
List<Span> tokens = nounPhrase.getTokens();
- Map<String,UriRef> langPlaceAdjectivalsMap = placeAdjectivalsMap.get(language);
+ Map<String,IRI> langPlaceAdjectivalsMap = placeAdjectivalsMap.get(language);
/*
* Go through all 1-grams and 2-grams and see if we have a match in the place adjectivals map. 2-grams
* should be good enough since there are no 3-gram places at least from what I saw.
Modified: stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/InMemoryEntityTypeIndex.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/InMemoryEntityTypeIndex.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/InMemoryEntityTypeIndex.java (original)
+++ stanbol/trunk/enhancement-engines/entitycoreference/src/main/java/org/apache/stanbol/enhancer/engines/entitycoreference/impl/InMemoryEntityTypeIndex.java Tue May 17 22:20:49 2016
@@ -20,7 +20,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.IRI;
/**
* Memory cache for storing often used Entity Type (Class) information.
@@ -32,10 +32,10 @@ public class InMemoryEntityTypeIndex {
/**
* The index having as key the Uri of the class and the value the set of labels ordered by language.
*/
- private Map<UriRef,Map<String,Set<String>>> index;
+ private Map<IRI,Map<String,Set<String>>> index;
public InMemoryEntityTypeIndex() {
- index = new HashMap<UriRef,Map<String,Set<String>>>();
+ index = new HashMap<IRI,Map<String,Set<String>>>();
}
/**
@@ -45,7 +45,7 @@ public class InMemoryEntityTypeIndex {
* @param language
* @return
*/
- public Set<String> lookupEntityType(UriRef uri, String language) {
+ public Set<String> lookupEntityType(IRI uri, String language) {
Map<String,Set<String>> langMap = index.get(uri);
if (langMap != null) {
@@ -62,7 +62,7 @@ public class InMemoryEntityTypeIndex {
* @param language
* @param labels
*/
- public void addEntityType(UriRef uri, String language, Set<String> labels) {
+ public void addEntityType(IRI uri, String language, Set<String> labels) {
Map<String,Set<String>> langMap = index.get(uri);
if (langMap == null) {
Modified: stanbol/trunk/enhancement-engines/entitycoreference/src/test/java/org/apache/stanbol/enhancer/engines/entitycoreference/EntityCoReferenceEngineTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitycoreference/src/test/java/org/apache/stanbol/enhancer/engines/entitycoreference/EntityCoReferenceEngineTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitycoreference/src/test/java/org/apache/stanbol/enhancer/engines/entitycoreference/EntityCoReferenceEngineTest.java (original)
+++ stanbol/trunk/enhancement-engines/entitycoreference/src/test/java/org/apache/stanbol/enhancer/engines/entitycoreference/EntityCoReferenceEngineTest.java Tue May 17 22:20:49 2016
@@ -11,10 +11,10 @@ import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Map.Entry;
-import org.apache.clerezza.rdf.core.MGraph;
-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.IRI;
+import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory;
import org.apache.stanbol.enhancer.nlp.NlpAnnotations;
import org.apache.stanbol.enhancer.nlp.coref.CorefFeature;
@@ -85,13 +85,13 @@ public class EntityCoReferenceEngineTest
@Test
public void testSpatialCoref() throws EngineException, IOException {
ContentItem ci = ciFactory.createContentItem(new StringSource(SPATIAL_TEXT));
- MGraph graph = ci.getMetadata();
- UriRef textEnhancement = EnhancementEngineHelper.createTextEnhancement(ci, engine);
+ Graph graph = ci.getMetadata();
+ IRI textEnhancement = EnhancementEngineHelper.createTextEnhancement(ci, engine);
graph.add(new TripleImpl(textEnhancement, DC_LANGUAGE, new PlainLiteralImpl("en")));
graph.add(new TripleImpl(textEnhancement, ENHANCER_CONFIDENCE, new PlainLiteralImpl("100.0")));
graph.add(new TripleImpl(textEnhancement, DC_TYPE, DCTERMS_LINGUISTIC_SYSTEM));
- Entry<UriRef, Blob> textBlob = ContentItemHelper.getBlob(ci, Collections.singleton("text/plain"));
+ Entry<IRI, Blob> textBlob = ContentItemHelper.getBlob(ci, Collections.singleton("text/plain"));
AnalysedText at = atFactory.createAnalysedText(ci, textBlob.getValue());
Sentence sentence1 = at.addSentence(0, SPATIAL_SENTENCE_1.indexOf(".") + 1);
Modified: stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntitySearcherUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntitySearcherUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntitySearcherUtils.java (original)
+++ stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntitySearcherUtils.java Tue May 17 22:20:49 2016
@@ -21,7 +21,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.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -49,8 +49,8 @@ public final class EntitySearcherUtils {
* @return
*/
public final static FieldQuery createFieldQuery(FieldQueryFactory factory,
- UriRef field,
- Set<UriRef> includeFields,
+ IRI field,
+ Set<IRI> includeFields,
List<String> search,
String... languages) {
if(field == null || field.getUnicodeString().isEmpty()){
@@ -67,7 +67,7 @@ public final class EntitySearcherUtils {
if(!includeFields.contains(field.getUnicodeString())){
query.addSelectedField(field.getUnicodeString());
}
- for(UriRef select : includeFields){
+ for(IRI select : includeFields){
query.addSelectedField(select.getUnicodeString());
}
}
Modified: stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubEntity.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubEntity.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubEntity.java (original)
+++ stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubEntity.java Tue May 17 22:20:49 2016
@@ -19,9 +19,9 @@ package org.apache.stanbol.enhancer.engi
import java.util.Iterator;
import java.util.Set;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.IRI;
import org.apache.stanbol.enhancer.engines.entitylinking.Entity;
import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation;
@@ -33,10 +33,10 @@ import org.apache.stanbol.entityhub.serv
public class EntityhubEntity extends Entity {
private static RdfValueFactory vf = RdfValueFactory.getInstance();
- private static UriRef entityRanking = new UriRef(RdfResourceEnum.entityRank.getUri());
+ private static IRI entityRanking = new IRI(RdfResourceEnum.entityRank.getUri());
- public EntityhubEntity(Representation rep, Set<UriRef> fields, Set<String> languages) {
- super(new UriRef(rep.getId()),
+ public EntityhubEntity(Representation rep, Set<IRI> fields, Set<String> languages) {
+ super(new IRI(rep.getId()),
toGraph(rep, fields, languages));
}
@Override
@@ -44,13 +44,13 @@ public class EntityhubEntity extends Ent
return EnhancementEngineHelper.get(data, uri, entityRanking, Float.class, lf);
}
/**
- * Converts {@link Representation}s to RDF ({@link TripleCollection}) and
+ * Converts {@link Representation}s to RDF ({@link Graph}) and
* also filter literals with languages other than the parsed one
* @param rep
* @param languages
* @return
*/
- private static TripleCollection toGraph(Representation rep, Set<UriRef> includeFields, Set<String> languages){
+ private static Graph toGraph(Representation rep, Set<IRI> includeFields, Set<String> languages){
if (rep instanceof RdfRepresentation) {
return ((RdfRepresentation) rep).getRdfGraph();
} else {
Modified: stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubSearcher.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubSearcher.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubSearcher.java (original)
+++ stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/EntityhubSearcher.java Tue May 17 22:20:49 2016
@@ -25,9 +25,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-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.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.EntitySearcherException;
@@ -43,7 +43,7 @@ import org.osgi.util.tracker.ServiceTrac
public final class EntityhubSearcher extends TrackingEntitySearcher<Entityhub> implements EntitySearcher {
private final Integer limit;
- private Map<UriRef,Collection<Resource>> originInfo;
+ private Map<IRI,Collection<RDFTerm>> originInfo;
public EntityhubSearcher(BundleContext context, Integer limit) {
this(context,limit,null);
@@ -52,13 +52,13 @@ public final class EntityhubSearcher ext
super(context,Entityhub.class,null,customizer);
this.limit = limit != null && limit > 0 ? limit : null;
this.originInfo = Collections.singletonMap(
- new UriRef(RdfResourceEnum.site.getUri()),
- (Collection<Resource>)Collections.singleton(
- (Resource)new PlainLiteralImpl("entityhub")));
+ new IRI(RdfResourceEnum.site.getUri()),
+ (Collection<RDFTerm>)Collections.singleton(
+ (RDFTerm)new PlainLiteralImpl("entityhub")));
}
@Override
- public Entity get(UriRef id,Set<UriRef> fields, String...languages) throws EntitySearcherException {
+ public Entity get(IRI id,Set<IRI> fields, String...languages) throws EntitySearcherException {
if(id == null || id.getUnicodeString().isEmpty()){
return null;
}
@@ -89,8 +89,8 @@ public final class EntityhubSearcher ext
}
@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 limit, Integer offset) throws EntitySearcherException {
@@ -138,7 +138,7 @@ public final class EntityhubSearcher ext
}
@Override
- public Map<UriRef,Collection<Resource>> getOriginInformation() {
+ public Map<IRI,Collection<RDFTerm>> getOriginInformation() {
return originInfo;
}
Modified: stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/ReferencedSiteSearcher.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/ReferencedSiteSearcher.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/ReferencedSiteSearcher.java (original)
+++ stanbol/trunk/enhancement-engines/entityhublinking/src/main/java/org/apache/stanbol/enhancer/engines/entityhublinking/ReferencedSiteSearcher.java Tue May 17 22:20:49 2016
@@ -25,9 +25,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-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.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.impl.Statistic;
@@ -49,7 +49,7 @@ public final class ReferencedSiteSearche
private final String siteId;
private final Integer limit;
- private Map<UriRef,Collection<Resource>> originInfo;
+ private Map<IRI,Collection<RDFTerm>> originInfo;
Statistic queryStats = new Statistic("query", 100, log);
Statistic resultStats = new Statistic("result", 1000, log);
public ReferencedSiteSearcher(BundleContext context,String siteId, Integer limit){
@@ -62,13 +62,13 @@ public final class ReferencedSiteSearche
this.siteId = siteId;
this.limit = limit != null && limit > 0 ? limit : null;
this.originInfo = Collections.singletonMap(
- new UriRef(RdfResourceEnum.site.getUri()),
- (Collection<Resource>)Collections.singleton(
- (Resource)new PlainLiteralImpl(siteId)));
+ new IRI(RdfResourceEnum.site.getUri()),
+ (Collection<RDFTerm>)Collections.singleton(
+ (RDFTerm)new PlainLiteralImpl(siteId)));
}
@Override
- public Entity get(UriRef id,Set<UriRef> fields, String ... languages) {
+ public Entity get(IRI id,Set<IRI> fields, String ... languages) {
if(id == null || id.getUnicodeString().isEmpty()){
return null;
}
@@ -99,8 +99,8 @@ public final class ReferencedSiteSearche
}
@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 limit, Integer offset) throws IllegalStateException {
@@ -156,7 +156,7 @@ public final class ReferencedSiteSearche
}
@Override
- public Map<UriRef,Collection<Resource>> getOriginInformation() {
+ public Map<IRI,Collection<RDFTerm>> getOriginInformation() {
return originInfo;
}
}
Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/Entity.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/Entity.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/Entity.java (original)
+++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/Entity.java Tue May 17 22:20:49 2016
@@ -19,12 +19,11 @@ package org.apache.stanbol.enhancer.engi
import java.util.Iterator;
import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.MGraph;
-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.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
+
+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.commons.collections.Predicate;
import org.apache.commons.collections.PredicateUtils;
import org.apache.commons.collections.Transformer;
@@ -46,44 +45,44 @@ public class Entity implements Comparabl
return ((Triple)input).getObject();
}
};
- protected static final Predicate PLAIN_LITERALS = PredicateUtils.instanceofPredicate(PlainLiteral.class);
- protected static final Predicate TYPED_LITERALS = PredicateUtils.instanceofPredicate(TypedLiteral.class);
- protected static final Predicate REFERENCES = PredicateUtils.instanceofPredicate(UriRef.class);
+ protected static final Predicate PLAIN_LITERALS = PredicateUtils.instanceofPredicate(Literal.class);
+ //protected static final Predicate TYPED_LITERALS = PredicateUtils.instanceofPredicate(TypedLiteral.class);
+ protected static final Predicate REFERENCES = PredicateUtils.instanceofPredicate(IRI.class);
/**
* The URI of the Entity
*/
- protected final UriRef uri;
+ protected final IRI uri;
/**
* The data of the Entity. The graph is expected to contain all information
* of the entity by containing {@link Triple}s that use the {@link #uri} as
* {@link Triple#getSubject() subject}
*/
- protected final TripleCollection data;
+ protected final Graph data;
/**
* Constructs a new Entity
* @param uri
* @param data
*/
- public Entity(UriRef uri, TripleCollection data) {
+ public Entity(IRI uri, Graph data) {
this.uri = uri;
this.data = data;
}
- public final UriRef getUri() {
+ public final IRI getUri() {
return uri;
}
public final String getId(){
return uri.getUnicodeString();
}
- public final TripleCollection getData() {
+ public final Graph getData() {
return data;
}
@SuppressWarnings("unchecked")
- public Iterator<PlainLiteral> getText(UriRef field) {
+ public Iterator<Literal> getText(IRI field) {
return new FilterIterator(new TransformIterator(data.filter(uri, field, null), TRIPLE2OBJECT), PLAIN_LITERALS);
}
@SuppressWarnings("unchecked")
- public Iterator<UriRef> getReferences(UriRef field){
+ public Iterator<IRI> getReferences(IRI field){
return new FilterIterator(new TransformIterator(data.filter(uri, field, null), TRIPLE2OBJECT), REFERENCES);
}
Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/EntitySearcher.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/EntitySearcher.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/EntitySearcher.java (original)
+++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/EntitySearcher.java Tue May 17 22:20:49 2016
@@ -21,9 +21,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-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.commons.rdf.RDFTerm;
+import org.apache.clerezza.commons.rdf.IRI;
/**
* Interface used to search for Entities (e.g. as defined by a Controlled
@@ -52,7 +51,7 @@ public interface EntitySearcher {
* @throws IllegalArgumentException if the parsed field is <code>null</code>;
* the list with the search terms is <code>null</code> or empty;
*/
- Collection<? extends Entity> lookup(UriRef field, Set<UriRef> selectedFields,
+ Collection<? extends Entity> lookup(IRI field, Set<IRI> selectedFields,
List<String> search, String[] languages, Integer limit, Integer offset)
throws EntitySearcherException;
/**
@@ -67,7 +66,7 @@ public interface EntitySearcher {
* Entity with the parsed Id
* @throws IllegalArgumentException if the parsed id is <code>null</code>
*/
- Entity get(UriRef id,Set<UriRef> selectedFields, String...languages) throws EntitySearcherException;
+ Entity get(IRI id,Set<IRI> selectedFields, String...languages) throws EntitySearcherException;
/**
* Returns <code>true</code> if this EntitySearcher can operate without
* dependencies to remote services. This is important because Stanbol can
@@ -90,5 +89,5 @@ public interface EntitySearcher {
* @return the predicate[1..1] -> predicate[1..*] tuples added to any
* 'fise:EntityAnnotation'.
*/
- Map<UriRef,Collection<Resource>> getOriginInformation();
+ Map<IRI,Collection<RDFTerm>> getOriginInformation();
}
\ No newline at end of file
Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/config/EntityLinkerConfig.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/config/EntityLinkerConfig.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/config/EntityLinkerConfig.java (original)
+++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/config/EntityLinkerConfig.java Tue May 17 22:20:49 2016
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.IRI;
import org.apache.stanbol.commons.namespaceprefix.NamespaceMappingUtils;
import org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService;
import org.apache.stanbol.enhancer.engines.entitylinking.EntitySearcher;
@@ -260,17 +260,17 @@ public class EntityLinkerConfig {
/**
* Default value for {@link #getNameField()} (rdfs:label)
*/
- public static final UriRef DEFAULT_NAME_FIELD = new UriRef(
+ public static final IRI DEFAULT_NAME_FIELD = new IRI(
"http://www.w3.org/2000/01/rdf-schema#label");
/**
* Default value for {@link #getTypeField()} (rdf:type)
*/
- public static final UriRef DEFAULT_TYPE_FIELD = new UriRef(
+ public static final IRI DEFAULT_TYPE_FIELD = new IRI(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
/**
* Default value for {@link #getRedirectField()} (rdf:seeAlso)
*/
- public static final UriRef DEFAULT_REDIRECT_FIELD = new UriRef(
+ public static final IRI DEFAULT_REDIRECT_FIELD = new IRI(
"http://www.w3.org/2000/01/rdf-schema#seeAlso");
/**
* The default language used to search for labels regardless of the language
@@ -300,41 +300,41 @@ public class EntityLinkerConfig {
* Default mapping for Concept types to dc:type values added for
* TextAnnotations.
*/
- public static final Map<UriRef,UriRef> DEFAULT_ENTITY_TYPE_MAPPINGS;
+ public static final Map<IRI,IRI> DEFAULT_ENTITY_TYPE_MAPPINGS;
static { //the default mappings for the three types used by the Stanbol Enhancement Structure
- Map<UriRef,UriRef> mappings = new HashMap<UriRef,UriRef>();
+ Map<IRI,IRI> mappings = new HashMap<IRI,IRI>();
mappings.put(OntologicalClasses.DBPEDIA_ORGANISATION, OntologicalClasses.DBPEDIA_ORGANISATION);
- mappings.put(new UriRef("http://dbpedia.org/ontology/Newspaper"), OntologicalClasses.DBPEDIA_ORGANISATION);
- mappings.put(new UriRef("http://schema.org/Organization"), OntologicalClasses.DBPEDIA_ORGANISATION);
+ mappings.put(new IRI("http://dbpedia.org/ontology/Newspaper"), OntologicalClasses.DBPEDIA_ORGANISATION);
+ mappings.put(new IRI("http://schema.org/Organization"), OntologicalClasses.DBPEDIA_ORGANISATION);
// mappings.put(NamespaceEnum.dailymed+"organization",OntologicalClasses.DBPEDIA_ORGANISATION);
mappings.put(OntologicalClasses.DBPEDIA_PERSON, OntologicalClasses.DBPEDIA_PERSON);
- mappings.put(new UriRef("http://xmlns.com/foaf/0.1/Person"), OntologicalClasses.DBPEDIA_PERSON);
- mappings.put(new UriRef("http://schema.org/Person"), OntologicalClasses.DBPEDIA_PERSON);
+ mappings.put(new IRI("http://xmlns.com/foaf/0.1/Person"), OntologicalClasses.DBPEDIA_PERSON);
+ mappings.put(new IRI("http://schema.org/Person"), OntologicalClasses.DBPEDIA_PERSON);
mappings.put(OntologicalClasses.DBPEDIA_PLACE, OntologicalClasses.DBPEDIA_PLACE);
- mappings.put(new UriRef("http://schema.org/Place"), OntologicalClasses.DBPEDIA_PLACE);
- mappings.put(new UriRef("http://www.opengis.net/gml/_Feature"), OntologicalClasses.DBPEDIA_PLACE);
+ mappings.put(new IRI("http://schema.org/Place"), OntologicalClasses.DBPEDIA_PLACE);
+ mappings.put(new IRI("http://www.opengis.net/gml/_Feature"), OntologicalClasses.DBPEDIA_PLACE);
mappings.put(OntologicalClasses.SKOS_CONCEPT, OntologicalClasses.SKOS_CONCEPT);
-// UriRef DRUG = new UriRef(NamespaceEnum.drugbank+"drugs");
+// IRI DRUG = new IRI(NamespaceEnum.drugbank+"drugs");
// mappings.put(DRUG.getUnicodeString(), DRUG);
// mappings.put(NamespaceEnum.dbpediaOnt+"Drug", DRUG);
// mappings.put(NamespaceEnum.dailymed+"drugs", DRUG);
// mappings.put(NamespaceEnum.sider+"drugs", DRUG);
// mappings.put(NamespaceEnum.tcm+"Medicine", DRUG);
//
-// UriRef DISEASE = new UriRef(NamespaceEnum.diseasome+"diseases");
+// IRI DISEASE = new IRI(NamespaceEnum.diseasome+"diseases");
// mappings.put(DISEASE.getUnicodeString(), DISEASE);
// mappings.put(NamespaceEnum.linkedct+"condition", DISEASE);
// mappings.put(NamespaceEnum.tcm+"Disease", DISEASE);
//
-// UriRef SIDE_EFFECT = new UriRef(NamespaceEnum.sider+"side_effects");
+// IRI SIDE_EFFECT = new IRI(NamespaceEnum.sider+"side_effects");
// mappings.put(SIDE_EFFECT.getUnicodeString(), SIDE_EFFECT);
//
-// UriRef INGREDIENT = new UriRef(NamespaceEnum.dailymed+"ingredients");
+// IRI INGREDIENT = new IRI(NamespaceEnum.dailymed+"ingredients");
// mappings.put(INGREDIENT.getUnicodeString(), INGREDIENT);
DEFAULT_ENTITY_TYPE_MAPPINGS = Collections.unmodifiableMap(mappings);
@@ -403,8 +403,8 @@ public class EntityLinkerConfig {
* Holds the mappings of rdf:type used by concepts to dc:type values used
* by TextAnnotations.
*/
- private Map<UriRef,UriRef> typeMappings;
- private Map<UriRef, UriRef> unmodTypeMappings;
+ private Map<IRI,IRI> typeMappings;
+ private Map<IRI, IRI> unmodTypeMappings;
/**
* The mode on how to process redirect for Entities.
*/
@@ -412,16 +412,16 @@ public class EntityLinkerConfig {
/**
* the default DC Type
*/
- private UriRef defaultDcType;
- private UriRef nameField;
- private UriRef redirectField;
- private UriRef typeField;
- private Map<UriRef,Integer> blacklistedTypes = new HashMap<UriRef,Integer>();
- private Map<UriRef,Integer> whitelistedTypes = new HashMap<UriRef,Integer>();
+ private IRI defaultDcType;
+ private IRI nameField;
+ private IRI redirectField;
+ private IRI typeField;
+ private Map<IRI,Integer> blacklistedTypes = new HashMap<IRI,Integer>();
+ private Map<IRI,Integer> whitelistedTypes = new HashMap<IRI,Integer>();
private Boolean defaultWhitelistTypes = null;
- private Set<UriRef> dereferencedFields = new HashSet<UriRef>();
+ private Set<IRI> dereferencedFields = new HashSet<IRI>();
- private Set<UriRef> __selectedFields;
+ private Set<IRI> __selectedFields;
/**
* The language always included in searches (regardless of the language
* detected for the text.
@@ -513,7 +513,7 @@ public class EntityLinkerConfig {
setMaxSuggestions(DEFAULT_SUGGESTIONS);
setMaxSearchTokens(DEFAULT_MAX_SEARCH_TOKENS);
setRedirectProcessingMode(DEFAULT_REDIRECT_PROCESSING_MODE);
- typeMappings = new HashMap<UriRef,UriRef>(DEFAULT_ENTITY_TYPE_MAPPINGS);
+ typeMappings = new HashMap<IRI,IRI>(DEFAULT_ENTITY_TYPE_MAPPINGS);
unmodTypeMappings = Collections.unmodifiableMap(typeMappings);
setDefaultDcType(typeMappings.remove(null));
setNameField(DEFAULT_NAME_FIELD);
@@ -559,7 +559,7 @@ public class EntityLinkerConfig {
if(value.toString().isEmpty()){
throw new ConfigurationException(NAME_FIELD,"The configured name field MUST NOT be empty");
}
- linkerConfig.setNameField(new UriRef(
+ linkerConfig.setNameField(new IRI(
getFullName(prefixService,NAME_FIELD,value.toString())));
}
@@ -577,7 +577,7 @@ public class EntityLinkerConfig {
if(value.toString().isEmpty()){
throw new ConfigurationException(TYPE_FIELD,"The configured name field MUST NOT be empty");
}
- linkerConfig.setTypeField(new UriRef(
+ linkerConfig.setTypeField(new IRI(
getFullName(prefixService, TYPE_FIELD, value.toString())));
}
@@ -587,7 +587,7 @@ public class EntityLinkerConfig {
if(value.toString().isEmpty()){
throw new ConfigurationException(NAME_FIELD,"The configured name field MUST NOT be empty");
}
- linkerConfig.setRedirectField(new UriRef(
+ linkerConfig.setRedirectField(new IRI(
getFullName(prefixService,REDIRECT_FIELD,value.toString())));
}
@@ -846,13 +846,13 @@ public class EntityLinkerConfig {
sourceTypes[0],o);
continue configs;
}
- UriRef targetUri = new UriRef(targetType);
+ IRI targetUri = new IRI(targetType);
for(String sourceType : sourceTypes){
if(!sourceType.isEmpty()){
sourceType = getFullName(prefixService,TYPE_MAPPINGS,sourceType.trim()); //support for ns:localName
try { //validate
new URI(sourceType);
- UriRef old = linkerConfig.setTypeMapping(sourceType, targetUri);
+ IRI old = linkerConfig.setTypeMapping(sourceType, targetUri);
if(old == null){
log.info(" > add type mapping {} > {}", sourceType,targetType);
} else {
@@ -887,20 +887,20 @@ public class EntityLinkerConfig {
for(String field : (String[])value){
if(field != null && !field.isEmpty()){
linkerConfig.getDereferencedFields().add(
- new UriRef(getFullName(prefixService,DEREFERENCE_ENTITIES_FIELDS,field)));
+ new IRI(getFullName(prefixService,DEREFERENCE_ENTITIES_FIELDS,field)));
}
}
} else if(value instanceof Collection<?>){
for(Object field : (Collection<?>)value){
if(field != null && !field.toString().isEmpty()){
linkerConfig.getDereferencedFields().add(
- new UriRef(getFullName(prefixService,DEREFERENCE_ENTITIES_FIELDS,field.toString())));
+ new IRI(getFullName(prefixService,DEREFERENCE_ENTITIES_FIELDS,field.toString())));
}
}
} else if(value instanceof String){
if(!value.toString().isEmpty()){
linkerConfig.getDereferencedFields().add(
- new UriRef(getFullName(prefixService,DEREFERENCE_ENTITIES_FIELDS,value.toString())));
+ new IRI(getFullName(prefixService,DEREFERENCE_ENTITIES_FIELDS,value.toString())));
}
} else if(value != null){
throw new ConfigurationException(DEREFERENCE_ENTITIES_FIELDS,
@@ -980,7 +980,7 @@ public class EntityLinkerConfig {
throw new ConfigurationException(ENTITY_TYPES, "The list of whitelisted/blacklisted "
+ "MUST NOT contain '!' (configured: "+entityTypesConfig+")!");
}
- UriRef uri = new UriRef(getFullName(prefixService, ENTITY_TYPES,
+ IRI uri = new IRI(getFullName(prefixService, ENTITY_TYPES,
blacklisted ? type.substring(1) : type));
if(blacklisted){
linkerConfig.addBlacklistType(uri, Integer.valueOf(i));
@@ -1026,7 +1026,7 @@ public class EntityLinkerConfig {
* (e.g. rdfs:label, skos:prefLabel). Needs to return the full URI
* @return the field used for the names of in the Taxonomy.
*/
- public final UriRef getNameField() {
+ public final IRI getNameField() {
return nameField;
}
/**
@@ -1034,7 +1034,7 @@ public class EntityLinkerConfig {
* (e.g. rdfs:label, skos:prefLabel).
* @param nameField the nameField to set
*/
- public final void setNameField(UriRef nameField) {
+ public final void setNameField(IRI nameField) {
this.nameField = nameField;
__selectedFields = null;
}
@@ -1043,21 +1043,21 @@ public class EntityLinkerConfig {
* set that allows to configure the fields that should be dereferenced
* @return
*/
- public final Set<UriRef> getDereferencedFields(){
+ public final Set<IRI> getDereferencedFields(){
return dereferencedFields;
}
/**
* The field used to follow redirects (typically rdf:seeAlso)
* @return the redirect field
*/
- public final UriRef getRedirectField() {
+ public final IRI getRedirectField() {
return redirectField;
}
/**
* The field used to follow redirects (typically rdf:seeAlso)
* @param redirectField the redirectField to set
*/
- public final void setRedirectField(UriRef redirectField) {
+ public final void setRedirectField(IRI redirectField) {
this.redirectField = redirectField;
__selectedFields = null;
}
@@ -1065,14 +1065,14 @@ public class EntityLinkerConfig {
* The field used to lookup the types (typically rdf:type)
* @return the field name used to lookup types
*/
- public final UriRef getTypeField() {
+ public final IRI getTypeField() {
return typeField;
}
/**
* The field used to lookup the types (typically rdf:type)
* @param typeField the typeField to set
*/
- public final void setTypeField(UriRef typeField) {
+ public final void setTypeField(IRI typeField) {
this.typeField = typeField;
__selectedFields = null;
}
@@ -1175,28 +1175,28 @@ public class EntityLinkerConfig {
* @param conceptType the concept type to remove the mapping
* @return the previously mapped dc:type value or <code>null</code> if
* no mapping for the parsed concept type was present
- public UriRef removeTypeMapping(UriRef conceptType){
+ public IRI removeTypeMapping(IRI conceptType){
return typeMappings.remove(conceptType);
}
*/
/**
*
* @param conceptType the type of the concept or <code>null</code> to
- * add the default dc:type mapping. See also {@link #setDefaultDcType(UriRef)}
+ * add the default dc:type mapping. See also {@link #setDefaultDcType(IRI)}
* @param dcType the dc:type for the parsed concept type
* @return the previously mapped dc:type value if an existing mapping
* was updated or <code>null</code> if a new mapping was added.
*/
- public UriRef setTypeMapping(String conceptType, UriRef dcType){
+ public IRI setTypeMapping(String conceptType, IRI dcType){
if(dcType == null) {
- return typeMappings.remove(conceptType == null ? null : new UriRef(conceptType));
+ return typeMappings.remove(conceptType == null ? null : new IRI(conceptType));
} else {
if(conceptType == null){ //handle setting of the default dc:type value
- UriRef oldDefault = getDefaultDcType();
+ IRI oldDefault = getDefaultDcType();
setDefaultDcType(dcType);
return oldDefault;
}
- return typeMappings.put(new UriRef(conceptType), dcType);
+ return typeMappings.put(new IRI(conceptType), dcType);
}
}
@@ -1207,7 +1207,7 @@ public class EntityLinkerConfig {
* cases.
* @param defaultDcType the defaultDcType to set
*/
- public void setDefaultDcType(UriRef defaultDcType) {
+ public void setDefaultDcType(IRI defaultDcType) {
this.defaultDcType = defaultDcType;
}
/**
@@ -1216,7 +1216,7 @@ public class EntityLinkerConfig {
* explicit mapping exists
* @return the defaultDcType
*/
- public UriRef getDefaultDcType() {
+ public IRI getDefaultDcType() {
return defaultDcType;
}
/**
@@ -1238,7 +1238,7 @@ public class EntityLinkerConfig {
* Getter for the read only mappings of type mappings
* @return the type mappings (read only)
*/
- public Map<UriRef,UriRef> getTypeMappings() {
+ public Map<IRI,IRI> getTypeMappings() {
return unmodTypeMappings;
}
/**
@@ -1502,9 +1502,9 @@ public class EntityLinkerConfig {
* @return the selected fields for queries against the linked vocabulary.
* @deprecated Use a Dereference Engine instead (STANBOL-336)
*/
- public Set<UriRef> getSelectedFields() {
+ public Set<IRI> getSelectedFields() {
if(__selectedFields == null){
- Set<UriRef> fields = new HashSet<UriRef>();
+ Set<IRI> fields = new HashSet<IRI>();
fields.add(nameField);
fields.add(typeField);
if(redirectProcessingMode != RedirectProcessingMode.IGNORE){
@@ -1568,7 +1568,7 @@ public class EntityLinkerConfig {
/**
* Adds an type to the blacklist
*/
- public final void addBlacklistType(UriRef type, Integer order) {
+ public final void addBlacklistType(IRI type, Integer order) {
if(type != null && order != null){
blacklistedTypes.put(type, order);
}
@@ -1576,7 +1576,7 @@ public class EntityLinkerConfig {
/**
* Adds an type to the blacklist
*/
- public final void addWhitelistType(UriRef type, Integer order) {
+ public final void addWhitelistType(IRI type, Integer order) {
if(type != null && order != null){
whitelistedTypes.put(type, order);
}
@@ -1600,7 +1600,7 @@ public class EntityLinkerConfig {
/**
* @param ignoredTypes the ignoredTypes to set
*/
- public final Map<UriRef, Integer> getBlacklistedTypes() {
+ public final Map<IRI, Integer> getBlacklistedTypes() {
return blacklistedTypes;
}
@@ -1608,7 +1608,7 @@ public class EntityLinkerConfig {
/**
* @param ignoredTypes the ignoredTypes to set
*/
- public final Map<UriRef, Integer> getWhitelistedTypes() {
+ public final Map<IRI, Integer> getWhitelistedTypes() {
return whitelistedTypes;
}
/**
Modified: stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngine.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngine.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngine.java (original)
+++ stanbol/trunk/enhancement-engines/entitylinking/engine/src/main/java/org/apache/stanbol/enhancer/engines/entitylinking/engine/EntityLinkingEngine.java Tue May 17 22:20:49 2016
@@ -34,17 +34,16 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-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.PlainLiteral;
-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.clerezza.rdf.core.impl.TypedLiteralImpl;
+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.clerezza.commons.rdf.impl.utils.TypedLiteralImpl;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
@@ -98,9 +97,9 @@ public class EntityLinkingEngine impleme
*/
public static final Integer DEFAULT_ORDER = ServiceProperties.ORDERING_DEFAULT - 10;
- private static final UriRef XSD_DOUBLE = new UriRef("http://www.w3.org/2001/XMLSchema#double");
+ private static final IRI XSD_DOUBLE = new IRI("http://www.w3.org/2001/XMLSchema#double");
- private static final UriRef ENHANCER_ENTITY_RANKING = new UriRef(NamespaceEnum.fise + "entity-ranking");
+ private static final IRI ENHANCER_ENTITY_RANKING = new IRI(NamespaceEnum.fise + "entity-ranking");
/**
* The name of this engine
@@ -293,23 +292,23 @@ public class EntityLinkingEngine impleme
if(language != null && !language.isEmpty()){
languageObject = new Language(language);
}
- Set<UriRef> dereferencedEntitis = new HashSet<UriRef>();
+ Set<IRI> dereferencedEntitis = new HashSet<IRI>();
- MGraph metadata = ci.getMetadata();
+ Graph metadata = ci.getMetadata();
for(LinkedEntity linkedEntity : linkedEntities){
- Collection<UriRef> textAnnotations = new ArrayList<UriRef>(linkedEntity.getOccurrences().size());
+ Collection<IRI> textAnnotations = new ArrayList<IRI>(linkedEntity.getOccurrences().size());
//first create the TextAnnotations for the Occurrences
for(Occurrence occurrence : linkedEntity.getOccurrences()){
Literal startLiteral = literalFactory.createTypedLiteral(occurrence.getStart());
Literal endLiteral = literalFactory.createTypedLiteral(occurrence.getEnd());
//search for existing text annotation
Iterator<Triple> it = metadata.filter(null, ENHANCER_START, startLiteral);
- UriRef textAnnotation = null;
+ IRI textAnnotation = null;
while(it.hasNext()){
Triple t = it.next();
if(metadata.filter(t.getSubject(), ENHANCER_END, endLiteral).hasNext() &&
metadata.filter(t.getSubject(), RDF_TYPE, ENHANCER_TEXTANNOTATION).hasNext()){
- textAnnotation = (UriRef)t.getSubject();
+ textAnnotation = (IRI)t.getSubject();
break;
}
}
@@ -335,7 +334,7 @@ public class EntityLinkingEngine impleme
new PlainLiteralImpl(this.getClass().getName())));
}
//add dc:types (even to existing)
- for(UriRef dcType : linkedEntity.getTypes()){
+ for(IRI dcType : linkedEntity.getTypes()){
metadata.add(new TripleImpl(
textAnnotation, Properties.DC_TYPE, dcType));
}
@@ -343,26 +342,26 @@ public class EntityLinkingEngine impleme
}
//now the EntityAnnotations for the Suggestions
for(Suggestion suggestion : linkedEntity.getSuggestions()){
- UriRef entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(ci, this);
+ IRI entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(ci, this);
//should we use the label used for the match, or search the
//representation for the best label ... currently its the matched one
- PlainLiteral label = suggestion.getBestLabel(linkerConfig.getNameField(),language);
+ Literal label = suggestion.getBestLabel(linkerConfig.getNameField(),language);
Entity entity = suggestion.getEntity();
metadata.add(new TripleImpl(entityAnnotation, Properties.ENHANCER_ENTITY_LABEL, label));
metadata.add(new TripleImpl(entityAnnotation,ENHANCER_ENTITY_REFERENCE, entity.getUri()));
- Iterator<UriRef> suggestionTypes = entity.getReferences(linkerConfig.getTypeField());
+ Iterator<IRI> suggestionTypes = entity.getReferences(linkerConfig.getTypeField());
while(suggestionTypes.hasNext()){
metadata.add(new TripleImpl(entityAnnotation,
Properties.ENHANCER_ENTITY_TYPE, suggestionTypes.next()));
}
metadata.add(new TripleImpl(entityAnnotation,
Properties.ENHANCER_CONFIDENCE, literalFactory.createTypedLiteral(suggestion.getScore())));
- for(UriRef textAnnotation : textAnnotations){
+ for(IRI textAnnotation : textAnnotations){
metadata.add(new TripleImpl(entityAnnotation, Properties.DC_RELATION, textAnnotation));
}
//add origin information of the EntiySearcher
- for(Entry<UriRef,Collection<Resource>> originInfo : entitySearcher.getOriginInformation().entrySet()){
- for(Resource value : originInfo.getValue()){
+ for(Entry<IRI,Collection<RDFTerm>> originInfo : entitySearcher.getOriginInformation().entrySet()){
+ for(RDFTerm value : originInfo.getValue()){
metadata.add(new TripleImpl(entityAnnotation,
originInfo.getKey(),value));
}