You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/06/13 11:04:47 UTC
svn commit: r1492582 - in /stanbol/trunk/entityhub/generic:
core/src/main/java/org/apache/stanbol/entityhub/core/site/
servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/
Author: rwesten
Date: Thu Jun 13 09:04:47 2013
New Revision: 1492582
URL: http://svn.apache.org/r1492582
Log:
STANBOL-1105, STANBOL-1106: Added proximity ranking and boost features to the FieldQuery insterfaces; Minor SiteConfigurationImpl now correctly returns an empty array instead of null if no EntityPrefixes are set
Modified:
stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/SiteConfigurationImpl.java
stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/Constraint.java
stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/TextConstraint.java
Modified: stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/SiteConfigurationImpl.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/SiteConfigurationImpl.java?rev=1492582&r1=1492581&r2=1492582&view=diff
==============================================================================
--- stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/SiteConfigurationImpl.java (original)
+++ stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/SiteConfigurationImpl.java Thu Jun 13 09:04:47 2013
@@ -280,7 +280,8 @@ public class SiteConfigurationImpl imple
@Override
public final String[] getEntityPrefixes() {
- return getStringValues(ENTITY_PREFIX);
+ String[] prefixes = getStringValues(ENTITY_PREFIX);
+ return prefixes == null ? new String[]{} : prefixes;
}
/**
* Setter for the Entity prefixes (typically the namespace or the host name)
@@ -355,7 +356,8 @@ public class SiteConfigurationImpl imple
//ignore if name, text and url == null and/or empty
}
}
- return licenseList.isEmpty()?null:licenseList.toArray(new License[licenseList.size()]);
+ return licenseList.isEmpty() ? new License[]{} :
+ licenseList.toArray(new License[licenseList.size()]);
}
/**
* Setter for the {@link License} information. This method stores the name,
Modified: stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/Constraint.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/Constraint.java?rev=1492582&r1=1492581&r2=1492582&view=diff
==============================================================================
--- stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/Constraint.java (original)
+++ stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/Constraint.java Thu Jun 13 09:04:47 2013
@@ -23,6 +23,15 @@ package org.apache.stanbol.entityhub.ser
*
*/
public abstract class Constraint {
+
+ private static Double ONE = Double.valueOf(1.0);
+
+ /**
+ * The boost allows to define the relative importance of a constraint for
+ * ranking of the query results. Values MUST BE <code> >= 0</code>
+ */
+ private Double boost = ONE;
+
/**
* Defines the enumeration of available Constraints. TODO Maybe we need a more "extensible" way to define
* different constraints in future
@@ -75,6 +84,29 @@ public abstract class Constraint {
return type;
}
+ /**
+ * The boost
+ * @return the boost or <code>null</code> if not set
+ */
+ public final Double getBoost() {
+ return boost;
+ }
+
+ /**
+ * Setter for the boost.
+ * @param boost the boost or <code>null</code> to unset the boost
+ * @throws IllegalArgumentException it the boost is lower than zero
+ */
+ public final void setBoost(Double boost) {
+ if(boost == null){
+ this.boost = null;
+ } else if(boost <= 0f){
+ throw new IllegalArgumentException("The parsed Boost '{}' MUST NOT be <= zero!");
+ } else {
+ this.boost = boost;
+ }
+ }
+
@Override
public String toString() {
return String.format("Constraint [type :: %s][class :: %s]", type, getClass().toString());
Modified: stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/TextConstraint.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/TextConstraint.java?rev=1492582&r1=1492581&r2=1492582&view=diff
==============================================================================
--- stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/TextConstraint.java (original)
+++ stanbol/trunk/entityhub/generic/servicesapi/src/main/java/org/apache/stanbol/entityhub/servicesapi/query/TextConstraint.java Thu Jun 13 09:04:47 2013
@@ -47,6 +47,11 @@ public class TextConstraint extends Cons
private final boolean caseSensitive;
private final List<String> texts;
/**
+ * If enabled the proximity of query terms will be used for ranking the
+ * results.
+ */
+ private boolean proximityRanking;
+ /**
* Creates a TextConstraint for multiple texts and languages. Parsed texts
* are connected using OR and may appear in any of the parsed languages.
* @param text the texts or <code>null</code> to search for any text in active languages
@@ -149,6 +154,7 @@ public class TextConstraint extends Cons
public final List<String> getTexts() {
return texts;
}
+
/**
* Getter for the first text constraint. If multiple constrains are set only
* the first one will be returned.
@@ -159,6 +165,22 @@ public class TextConstraint extends Cons
public final String getText(){
return texts == null || texts.isEmpty() ? null : texts.get(0);
}
+ /**
+ * Getter for the Term Proximity state. If enabled the proximity of the
+ * parsed terms should be used to rank search results.
+ * @return the termProximity or <code>null</code> if not specified
+ */
+ public Boolean isProximityRanking() {
+ return proximityRanking;
+ }
+ /**
+ * Setter for the proximity ranking state. If enabled the proximity of the
+ * parsed terms should be used to rank search results.
+ * @param state the proximity ranking state to set
+ */
+ public void setProximityRanking(boolean state) {
+ this.proximityRanking = state;
+ }
@Override
public String toString() {
return String.format("TextConstraint[value=%s|%s|case %sensitive|languages:%s]",