You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by si...@apache.org on 2012/01/31 14:43:55 UTC
svn commit: r1238518 [1/2] - in /incubator/stanbol/trunk/contenthub:
crawler/cnn/
crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/
crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/
ldpath/ ldpath/src/main/jav...
Author: sinaci
Date: Tue Jan 31 13:43:54 2012
New Revision: 1238518
URL: http://svn.apache.org/viewvc?rev=1238518&view=rev
Log:
Javadocs and minor refactoring within servicesapi of Contenthub
Added:
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/AbstractContenthubException.java
Removed:
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/AbstractContenthubException.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/enhancements/vocabulary/
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/ContenthubException.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/vocabulary/
Modified:
incubator/stanbol/trunk/contenthub/crawler/cnn/pom.xml
incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java
incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/NewsSummary.java
incubator/stanbol/trunk/contenthub/ldpath/pom.xml
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaBackend.java
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java
incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java
incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java
incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/IndexingHelper.java
incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/OntologyResourceSearch.java
incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/QueryFactory.java
incubator/stanbol/trunk/contenthub/servicesapi/pom.xml
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/solr/SolrSearch.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/StoreException.java
incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java
incubator/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/CNNImporterResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDProgramManagerResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
Modified: incubator/stanbol/trunk/contenthub/crawler/cnn/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/crawler/cnn/pom.xml?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/crawler/cnn/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/crawler/cnn/pom.xml Tue Jan 31 13:43:54 2012
@@ -16,80 +16,80 @@
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.contenthub.parent</artifactId>
- <version>0.9.0-incubating-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
+ <parent>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.contenthub.parent</artifactId>
+ <version>0.9.0-incubating-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
- <artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId>
- <packaging>bundle</packaging>
+ <artifactId>org.apache.stanbol.contenthub.crawler.cnn</artifactId>
+ <packaging>bundle</packaging>
- <name>Apache Stanbol Contenthub Crawler for News on CNN</name>
+ <name>Apache Stanbol Contenthub Crawler for News on CNN</name>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Embed-Dependency>jtidy|htmlcleaner</Embed-Dependency>
- <Import-Package>
- !org.jdom,
- !org.apache.tools.ant,
- *
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Embed-Dependency>jtidy|htmlcleaner</Embed-Dependency>
+ <Import-Package>
+ !org.jdom,
+ !org.apache.tools.ant,
+ *
</Import-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.htmlcleaner</groupId>
- <artifactId>htmlcleaner</artifactId>
- <version>2.2</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>jtidy</groupId>
- <artifactId>jtidy</artifactId>
- </dependency>
- </dependencies>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.htmlcleaner</groupId>
+ <artifactId>htmlcleaner</artifactId>
+ <version>2.2</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jtidy</groupId>
+ <artifactId>jtidy</artifactId>
+ </dependency>
+ </dependencies>
</project>
Modified: incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java (original)
+++ incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/CNNImporter.java Tue Jan 31 13:43:54 2012
@@ -21,12 +21,29 @@ import java.net.URI;
import java.util.Map;
/**
+ * This is the interface to crawl CNN.
+ *
+ * @see <a href=" http://topics.cnn.com/topics/">CNN News Topics</a>
+ *
*
* @author cihan
*
*/
public interface CNNImporter {
- Map<URI, String> importCNNNews(String topic, int maxNumber, boolean fullNews);
+ /**
+ *
+ * @param topic
+ * The topic which will be crawled.
+ * @param maxNumber
+ * Max number of news to be retrieved from CNN about the {@link topic}
+ * @param fullNews
+ * If {@code true}, the topic will be crawled in detail to retrieve all information from CNN
+ * about the {@link topic}. If {@code false}, only summary of the news will be crawled and
+ * imported.
+ * @return A map which includes the URI of the related topic and the news content. If {@link fullNews} is
+ * {@code true}, the news content is the full news; if not, it is the summary of the news.
+ */
+ Map<URI,String> importCNNNews(String topic, int maxNumber, boolean fullNews);
}
Modified: incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/NewsSummary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/NewsSummary.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/NewsSummary.java (original)
+++ incubator/stanbol/trunk/contenthub/crawler/cnn/src/main/java/org/apache/stanbol/contenthub/crawler/cnn/impl/NewsSummary.java Tue Jan 31 13:43:54 2012
@@ -20,6 +20,7 @@ package org.apache.stanbol.contenthub.cr
import java.net.URI;
/**
+ * Bean class to keep information about news that are obtained from news sources.
*
* @author cihan
*
@@ -53,14 +54,4 @@ public class NewsSummary {
public void setTitle(String title) {
this.title = title;
}
-
- /*public Map<String, List<Object>> getTitleConstraint() {
- if(title == null || title.isEmpty()) return null;
- Map<String, List<Object>> titleConstraint = new HashMap<String,List<Object>>();
- List<Object> titleList = new ArrayList<Object>(1);
- titleList.add(title);
- titleConstraint.put(SolrVocabulary.SolrFieldName.TITLE.toString(), titleList);
- return titleConstraint;
- }*/
-
}
Modified: incubator/stanbol/trunk/contenthub/ldpath/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/pom.xml?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/pom.xml Tue Jan 31 13:43:54 2012
@@ -1,14 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
- license agreements. See the NOTICE file distributed with this work for additional
- information regarding copyright ownership. The ASF licenses this file to
- You under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of
- the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
- by applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- OF ANY KIND, either express or implied. See the License for the specific
- language governing permissions and limitations under the License. -->
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaBackend.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaBackend.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaBackend.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaBackend.java Tue Jan 31 13:43:54 2012
@@ -48,6 +48,9 @@ import org.slf4j.LoggerFactory;
import at.newmedialab.ldpath.api.backend.RDFBackend;
/**
+ * Clerezza based implementation of {@link RDFBackend} interface. This implementation uses the
+ * {@link Resource} objects of Clerezza as processing unit RDFBackend.
+ *
* @author anil.sinaci
*
*/
@@ -241,81 +244,81 @@ public class ClerezzaBackend implements
}
}
- @Override
- public Boolean booleanValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public Boolean booleanValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(Boolean.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
- @Override
- public Date dateTimeValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public Date dateTimeValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(Date.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
- @Override
- public Date dateValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public Date dateValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(Date.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
- @Override
- public Date timeValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public Date timeValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(Date.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
- @Override
- public Float floatValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public Float floatValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(Float.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
- @Override
- public Integer intValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public Integer intValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(Integer.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
- @Override
- public BigInteger integerValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
+ @Override
+ public BigInteger integerValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
return LiteralFactory.getInstance().createObject(BigInteger.class, (TypedLiteral) resource);
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
+
+ @Override
+ public BigDecimal decimalValue(Resource resource) {
+ if (resource instanceof TypedLiteral) {
+ try {
+ return LiteralFactory.getInstance().createObject(BigDecimal.class, (TypedLiteral) resource);
+ } catch (NoConvertorException e) {
+ throw new NumberFormatException("Resource " + resource.toString()
+ + " can not converted, no convertor for the BigDecimal");
+ }
- @Override
- public BigDecimal decimalValue(Resource resource) {
- if (resource instanceof TypedLiteral) {
- try {
- return LiteralFactory.getInstance().createObject(BigDecimal.class, (TypedLiteral) resource);
- }
- catch(NoConvertorException e) {
- throw new NumberFormatException("Resource " + resource.toString() + " can not converted, no convertor for the BigDecimal");
- }
-
} else {
throw new IllegalArgumentException("Resource " + resource.toString() + " is not a TypedLiteral");
}
- }
+ }
}
\ No newline at end of file
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/ClerezzaQuery.java Tue Jan 31 13:43:54 2012
@@ -43,13 +43,38 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.newmedialab.ldpath.LDPath;
+import at.newmedialab.ldpath.api.backend.RDFBackend;
import at.newmedialab.ldpath.exception.LDPathParseException;
+/**
+ * This class provides a main function for executing an LDProgram on {@link ClerezzaBackend} ,which is
+ * Clerezza based implementation of {@link RDFBackend}, populated with RDF data.
+ *
+ * @author suat
+ *
+ */
public class ClerezzaQuery {
private static final Logger logger = LoggerFactory.getLogger(ClerezzaQuery.class);
private static Parser clerezzaRDFParser;
+ /**
+ * This executable method provides execution of an LDPath program over an RDF data and prints out the
+ * obtained results. Passed RDF data should be in <b>RDF/XML</b> format.<br>
+ *
+ * Usage of this main method is as follows: <br>
+ * ClerezzaQuery -context <pre><uri></pre> -filePath <pre><filePath></pre> -path <pre><path></pre> | -program <pre><file></pre></br></br>
+ *
+ * <b><code>context</code>:</b> URI of the context node to start from<br>
+ * <b><code>rdfData</code>:</b> File system path of the file holding RDF data<br>
+ * <b><code>path</code>:</b> LD Path to evaluate on the file starting from the <code>context</code><br>
+ * <b><code>program</code>:</b> LD Path program to evaluate on the file starting from the
+ * <code>context</code><br>
+ *
+ * @param args
+ * Collection of <code>context</code>, <code>rdfData</code>, <code>path</code> and <code>program</code> parameters
+ *
+ */
public static void main(String[] args) {
Options options = buildOptions();
@@ -58,11 +83,11 @@ public class ClerezzaQuery {
CommandLine cmd = parser.parse(options, args);
ClerezzaBackend clerezzaBackend = null;
- if (cmd.hasOption("filePath")) {
+ if (cmd.hasOption("rdfData")) {
clerezzaRDFParser = new Parser();
clerezzaRDFParser.bindParsingProvider(new JenaParserProvider());
MGraph mGraph = new SimpleMGraph(clerezzaRDFParser.parse(
- new FileInputStream(cmd.getOptionValue("filePath")), SupportedFormat.RDF_XML));
+ new FileInputStream(cmd.getOptionValue("rdfData")), SupportedFormat.RDF_XML));
clerezzaBackend = new ClerezzaBackend(mGraph);
}
@@ -106,14 +131,14 @@ public class ClerezzaQuery {
} catch (ParseException e) {
logger.error("invalid arguments");
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("LDQuery", options, true);
+ formatter.printHelp("ClerezzaQuery", options, true);
} catch (LDPathParseException e) {
logger.error("path or program could not be parsed");
e.printStackTrace();
} catch (FileNotFoundException e) {
logger.error("file or program could not be found");
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("LDQuery", options, true);
+ formatter.printHelp("ClerezzaQuery", options, true);
}
}
@@ -124,32 +149,27 @@ public class ClerezzaQuery {
OptionGroup query = new OptionGroup();
OptionBuilder.withArgName("path");
OptionBuilder.hasArg();
- OptionBuilder
- .withDescription("LD Path to evaluate on the file starting from the context");
+ OptionBuilder.withDescription("LD Path to evaluate on the file starting from the context");
Option path = OptionBuilder.create("path");
OptionBuilder.withArgName("file");
OptionBuilder.hasArg();
- OptionBuilder
- .withDescription("LD Path program to evaluate on the file starting from the context");
- Option program = OptionBuilder
- .create("program");
+ OptionBuilder.withDescription("LD Path program to evaluate on the file starting from the context");
+ Option program = OptionBuilder.create("program");
query.addOption(path);
query.addOption(program);
query.setRequired(true);
result.addOptionGroup(query);
- OptionBuilder.withArgName("filePath");
+ OptionBuilder.withArgName("rdfData");
OptionBuilder.hasArg();
- OptionBuilder
- .withDescription("File system path of the file holding RDF data");
- Option filePath = OptionBuilder.create("filePath");
+ OptionBuilder.withDescription("File system path of the file holding RDF data");
+ Option filePath = OptionBuilder.create("rdfData");
filePath.setRequired(true);
result.addOption(filePath);
OptionBuilder.withArgName("uri");
OptionBuilder.hasArg();
- OptionBuilder
- .withDescription("URI of the context node to start from");
+ OptionBuilder.withDescription("URI of the context node to start from");
Option context = OptionBuilder.create("context");
context.setRequired(true);
result.addOption(context);
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDPathUtils.java Tue Jan 31 13:43:54 2012
@@ -65,6 +65,8 @@ import at.newmedialab.ldpath.parser.Pars
import at.newmedialab.ldpath.parser.RdfPathParser;
/**
+ * Class containing utility methods for LDPath functionalities.
+ *
* @author anil.sinaci
*
*/
@@ -125,6 +127,12 @@ public class LDPathUtils {
private Bundle bundle;
+ /**
+ * Constructor taking a {@link Bundle} parameter. This bundle is used when obtaining Solr schema template.
+ *
+ * @param bundle
+ * From which the template Solr schema is obtained.
+ */
public LDPathUtils(Bundle bundle) {
this.bundle = bundle;
}
@@ -147,6 +155,14 @@ public class LDPathUtils {
}
}
+ /**
+ * Creates a {@link Reader} instance from the given program string.
+ *
+ * @param program
+ * @return a {@link InputStreamReader}.
+ * @throws LDPathException
+ * if {@link Constants#DEFAULT_ENCODING} is not supported
+ */
public static Reader constructReader(String program) throws LDPathException {
try {
return new InputStreamReader(new ByteArrayInputStream(
@@ -180,6 +196,21 @@ public class LDPathUtils {
return program;
}
+ /**
+ * This method creates an {@link ArchiveInputStream} containing Solr schema configurations based on the
+ * provided <code>ldPathProgram</code>. All folders and files except <b>"schema-template.xml"</b> is took
+ * from a default Solr configuration template which is located in the resources of the bundle specified in
+ * the constructor of this class i.e {@link LDPathUtils}. Instead of the "schema-template" file, a
+ * <b>"schema.xml"</b> is created.
+ *
+ * @param coreName
+ * Name of the Solr core that is used instead of template
+ * @param ldPathProgram
+ * Program for which the Solr core will be created
+ * @return {@link ArchiveInputStream} containing the Solr configurations for the provided
+ * <code>ldPathProgram</code>
+ * @throws LDPathException
+ */
public ArchiveInputStream createSchemaArchive(String coreName, String ldPathProgram) throws LDPathException {
ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
ArchiveStreamFactory asf = new ArchiveStreamFactory();
@@ -199,8 +230,7 @@ public class LDPathUtils {
byte[] schemaFile = null;
while ((ze = zis.getNextZipEntry()) != null) {
if (SOLR_TEMPLATE_SCHEMA.equals(ze.getName())) {
- schemaFile = createSchemaXML(coreName, getLDPathProgram(ldPathProgram),
- IOUtils.toByteArray(zis));
+ schemaFile = createSchemaXML(getLDPathProgram(ldPathProgram), IOUtils.toByteArray(zis));
TarArchiveEntry te = new TarArchiveEntry(coreName + SOLR_SCHEMA);
te.setSize(schemaFile.length);
tarOutputStream.putArchiveEntry(te);
@@ -259,7 +289,25 @@ public class LDPathUtils {
return is;
}
- private byte[] createSchemaXML(String coreName, Program<Resource> program, byte[] template) throws LDPathException {
+ /**
+ * Creates <b>"schema.xml"</b> file for the Solr configurations to be created for the provided LDPath
+ * program. Creates <b>Solr fields</b> for each field obtained by calling {@link Program#getFields()} of
+ * provided <code>program</code>. By default, <i>name</i>, <i>type</i>, <i>stored</i>, <i>indexed</i> and
+ * <i>multiValued</i> attributes of fields are set. Furthermore, any attribute obtained from the fields of
+ * the program is also set if it is included in {@link LDPathUtils#SOLR_FIELD_OPTIONS}. Another
+ * configuration about the fields obtained from the program is {@link LDPathUtils#SOLR_COPY_FIELD_OPTION}.
+ * If there is a specified configuration about this field, <b>destination</b> of <b>copyField</b> element
+ * is set accordingly. Otherwise, the destination is set as <b>text_all</b>
+ *
+ * @param program
+ * LDPath program of which fields will be obtained
+ * @param template
+ * Solr schema template to be populated with the fields based on the provided
+ * <code>program</code>
+ * @return created template in an array of bytes.
+ * @throws LDPathException
+ */
+ private byte[] createSchemaXML(Program<Resource> program, byte[] template) throws LDPathException {
Builder xmlParser = new Builder();
ByteArrayInputStream is = new ByteArrayInputStream(template);
Modified: incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/solr/LDProgramManagerImpl.java Tue Jan 31 13:43:54 2012
@@ -192,7 +192,8 @@ public class LDProgramManagerImpl implem
@Override
public void deleteProgram(String programName) {
if (isManagedProgram(programName)) {
- SolrCoreManager.getInstance(bundle.getBundleContext(), managedSolrServer).deleteSolrCore(programName);
+ SolrCoreManager.getInstance(bundle.getBundleContext(), managedSolrServer).deleteSolrCore(
+ programName);
nameProgramMap.remove(programName);
String programFilePath = managedProgramsDir.getAbsolutePath() + File.separator + programName;
File programFile = new File(programFilePath);
@@ -219,16 +220,18 @@ public class LDProgramManagerImpl implem
LDPath<Resource> ldpath = new LDPath<Resource>(new ClerezzaBackend(graph));
String ldPathProgram = getProgramByName(programName);
Iterator<Triple> it = graph.filter(null, Properties.ENHANCER_ENTITY_REFERENCE, null);
- while(it.hasNext()) {
+ while (it.hasNext()) {
try {
- Map<String,Collection<?>> entityResults = ldpath.programQuery(it.next().getObject(), LDPathUtils.constructReader(ldPathProgram));
- for(Entry<String,Collection<?>> entry : entityResults.entrySet()) {
- if(results.containsKey(entry.getKey())) {
+ Map<String,Collection<?>> entityResults = ldpath.programQuery(it.next().getObject(),
+ LDPathUtils.constructReader(ldPathProgram));
+ for (Entry<String,Collection<?>> entry : entityResults.entrySet()) {
+ if (results.containsKey(entry.getKey())) {
@SuppressWarnings("unchecked")
- Collection<Object> resultCollection = (Collection<Object>) results.get(entry.getKey());
+ Collection<Object> resultCollection = (Collection<Object>) results
+ .get(entry.getKey());
@SuppressWarnings("unchecked")
Collection<Object> tmpCol = (Collection<Object>) entry.getValue();
- for(Object o : tmpCol) {
+ for (Object o : tmpCol) {
resultCollection.add(o);
}
} else {
@@ -242,7 +245,7 @@ public class LDProgramManagerImpl implem
}
}
return results;
-
+
}
}
Modified: incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/FeaturedSearchImpl.java Tue Jan 31 13:43:54 2012
@@ -181,12 +181,12 @@ public class FeaturedSearchImpl implemen
}
@Override
- public List<String> getFacetNames() throws SearchException {
- return getFacetNames(null);
+ public List<String> getFieldNames() throws SearchException {
+ return getFieldNames(null);
}
@Override
- public List<String> getFacetNames(String ldProgramName) throws SearchException {
+ public List<String> getFieldNames(String ldProgramName) throws SearchException {
SolrServer solrServer = null;
try {
solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(
Modified: incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java (original)
+++ incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/RelatedKeywordSearchManagerImpl.java Tue Jan 31 13:43:54 2012
@@ -95,7 +95,7 @@ public class RelatedKeywordSearchManager
}
@Override
- public SearchResult getRelatedKeywordsFromReferencedCites(String keyword) throws SearchException {
+ public SearchResult getRelatedKeywordsFromReferencedSites(String keyword) throws SearchException {
return getRelatedKeywordsFrom(keyword, ReferencedSiteSearch.class);
}
}
Modified: incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/IndexingHelper.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/IndexingHelper.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/IndexingHelper.java (original)
+++ incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/IndexingHelper.java Tue Jan 31 13:43:54 2012
@@ -19,7 +19,7 @@ package org.apache.stanbol.contenthub.se
import java.util.List;
import org.apache.stanbol.cmsadapter.servicesapi.helper.CMSAdapterVocabulary;
-import org.apache.stanbol.contenthub.servicesapi.search.vocabulary.SearchVocabulary;
+import org.apache.stanbol.contenthub.servicesapi.Constants;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
@@ -34,16 +34,28 @@ import com.hp.hpl.jena.vocabulary.RDF;
* This class is created to create LARQ index of external ontology provided for the search operation
*/
public class IndexingHelper {
+
+ /**
+ * Represents the special property which is used by Lucene while creating the index. At the beginning of a
+ * search operation, user ontology is processed to add this special property to each class and individual
+ * resource by using their local names.
+ */
+ public static final Property HAS_LOCAL_NAME = property("hasLocalName");
+
+ private static Property property(String local) {
+ return ResourceFactory.createProperty(Constants.SEARCH_URI, local);
+ }
+
public static void addIndexPropertyToOntResources(OntModel model) {
// Add class names
for (OntClass klass : model.listClasses().toList()) {
if (klass == null || klass.isAnon()) continue;
- klass.addProperty(SearchVocabulary.HAS_LOCAL_NAME, klass.getLocalName());
+ klass.addProperty(HAS_LOCAL_NAME, klass.getLocalName());
}
// Add individual names
for (OntResource ind : model.listIndividuals().toList()) {
if (ind == null || ind.isAnon()) continue;
- ind.addProperty(SearchVocabulary.HAS_LOCAL_NAME, ind.getLocalName());
+ ind.addProperty(HAS_LOCAL_NAME, ind.getLocalName());
}
// Add CMS objects
@@ -58,7 +70,7 @@ public class IndexingHelper {
*/
String name = getCMSObjectName(subject);
if (!name.equals("")) {
- Statement s = ResourceFactory.createStatement(subject, SearchVocabulary.HAS_LOCAL_NAME,
+ Statement s = ResourceFactory.createStatement(subject, HAS_LOCAL_NAME,
ResourceFactory.createPlainLiteral(name));
model.add(s);
}
Modified: incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/OntologyResourceSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/OntologyResourceSearch.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/OntologyResourceSearch.java (original)
+++ incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/OntologyResourceSearch.java Tue Jan 31 13:43:54 2012
@@ -33,7 +33,6 @@ import org.apache.stanbol.contenthub.sea
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeyword;
import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeywordSearch;
-import org.apache.stanbol.contenthub.servicesapi.search.vocabulary.SearchVocabulary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -128,7 +127,7 @@ public class OntologyResourceSearch impl
userOntologyURI));
}
this.userOntology = userGraph;
- this.userGraphIndexBuilder = new IndexBuilderString(SearchVocabulary.HAS_LOCAL_NAME);
+ this.userGraphIndexBuilder = new IndexBuilderString(IndexingHelper.HAS_LOCAL_NAME);
this.userGraphIndexBuilder.indexStatements(userGraph.listStatements());
// Do not forget to set the default index just before the query execution according to its context
// LARQ.setDefaultIndex(index);
Modified: incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/QueryFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/QueryFactory.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/QueryFactory.java (original)
+++ incubator/stanbol/trunk/contenthub/search/related/src/main/java/org/apache/stanbol/contenthub/search/related/ontologyresource/QueryFactory.java Tue Jan 31 13:43:54 2012
@@ -17,7 +17,7 @@
package org.apache.stanbol.contenthub.search.related.ontologyresource;
-import org.apache.stanbol.contenthub.servicesapi.search.vocabulary.SearchVocabulary;
+import org.apache.stanbol.contenthub.servicesapi.Constants;
import com.hp.hpl.jena.query.Query;
@@ -31,7 +31,7 @@ public final class QueryFactory {
private static final String OWL = "PREFIX owl: <http://www.w3.org/2002/07/owl#>";
private static final String RDF = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>";
private static final String PF = "PREFIX pf: <http://jena.hpl.hp.com/ARQ/property#>";
- private static final String SEARCH = "PREFIX ss: <" + SearchVocabulary.getUri() + ">";
+ private static final String SEARCH = "PREFIX ss: <" + Constants.SEARCH_URI + ">";
private static final String CMS = "PREFIX cms: <http://www.apache.org/stanbol/cms#>";
public static final Query getClassQuery(String keyword) {
Modified: incubator/stanbol/trunk/contenthub/servicesapi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/pom.xml?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/pom.xml (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/pom.xml Tue Jan 31 13:43:54 2012
@@ -58,19 +58,6 @@
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.entityhub.servicesapi</artifactId>
</dependency>
-
-<!-- <dependency> -->
-<!-- <groupId>com.sun.xml.bind</groupId> -->
-<!-- <artifactId>jaxb-impl</artifactId> -->
-<!-- </dependency> -->
- <dependency>
- <groupId>com.hp.hpl.jena</groupId>
- <artifactId>jena</artifactId>
- </dependency>
- <dependency>
- <groupId>com.hp.hpl.jena</groupId>
- <artifactId>arq</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.core</artifactId>
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/Constants.java Tue Jan 31 13:43:54 2012
@@ -16,19 +16,31 @@
*/
package org.apache.stanbol.contenthub.servicesapi;
-import org.apache.stanbol.contenthub.servicesapi.enhancements.vocabulary.EnhancementGraphVocabulary;
-
/**
+ * Class keeping the constants that are used in various places of Contenthub.
+ *
* @author anil.sinaci
- *
+ *
*/
public class Constants {
-
+
+ /**
+ * Default encoding
+ */
public static final String DEFAULT_ENCODING = "UTF-8";
-
+
+ /**
+ * The URI of the global enhancement graph. All enhancements are stored in this graph.
+ */
+ public static final String ENHANCEMENTS_GRAPH_URI = "org.apache.stanbol.enhancer.standalone.store.enhancements";
+
+ /**
+ * The URI of ???
+ */
public static final String ENHANCER_ENTITIY_CACHE_GRAPH_URI = "enhancerEntityCache";
+
public static final String[] RESERVED_GRAPH_URIs = {ENHANCER_ENTITIY_CACHE_GRAPH_URI,
- EnhancementGraphVocabulary.ENHANCEMENTS_GRAPH_URI};
+ ENHANCEMENTS_GRAPH_URI};
public static boolean isGraphReserved(String graphURI) {
for (String uri : RESERVED_GRAPH_URIs) {
@@ -36,4 +48,6 @@ public class Constants {
}
return false;
}
+
+ public static final String SEARCH_URI = "http://stanbol.apache.org/contenthub/search/";
}
Added: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/AbstractContenthubException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/AbstractContenthubException.java?rev=1238518&view=auto
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/AbstractContenthubException.java (added)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/exception/AbstractContenthubException.java Tue Jan 31 13:43:54 2012
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.servicesapi.exception;
+
+/**
+ * Abstract exception class to be used as a parent in various types of other Contenthub exceptions.
+ *
+ * @author anil.sinaci
+ *
+ */
+public abstract class AbstractContenthubException extends Exception {
+
+ private static final long serialVersionUID = -2303415622874917355L;
+
+ protected AbstractContenthubException(String msg) {
+ super(msg);
+ }
+
+ protected AbstractContenthubException(Throwable cause) {
+ super(cause);
+ }
+
+ protected AbstractContenthubException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDPathException.java Tue Jan 31 13:43:54 2012
@@ -16,11 +16,13 @@
*/
package org.apache.stanbol.contenthub.servicesapi.ldpath;
-import org.apache.stanbol.contenthub.servicesapi.AbstractContenthubException;
+import org.apache.stanbol.contenthub.servicesapi.exception.AbstractContenthubException;
/**
+ * Exception to be thrown in LDPath related operations of Contenthub.
+ *
* @author anil.sinaci
- *
+ *
*/
public class LDPathException extends AbstractContenthubException {
@@ -32,7 +34,7 @@ public class LDPathException extends Abs
public LDPathException(String msg) {
super(msg);
}
-
+
/**
* @param cause
*/
@@ -47,5 +49,5 @@ public class LDPathException extends Abs
public LDPathException(String msg, Throwable cause) {
super(msg, cause);
}
-
+
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgram.java Tue Jan 31 13:43:54 2012
@@ -17,8 +17,10 @@
package org.apache.stanbol.contenthub.servicesapi.ldpath;
/**
+ * Simple bean class representing the LDPath programs. Contains the program itself together with its name.
+ *
* @author anil.sinaci
- *
+ *
*/
public class LDProgram {
@@ -29,18 +31,21 @@ public class LDProgram {
this.name = name;
this.ldPathProgram = ldPathProgram;
}
-
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
+
public String getLdPathProgram() {
return ldPathProgram;
}
+
public void setLdPathProgram(String ldPathProgram) {
this.ldPathProgram = ldPathProgram;
}
-
+
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramCollection.java Tue Jan 31 13:43:54 2012
@@ -21,6 +21,9 @@ import java.util.List;
import java.util.Map;
/**
+ * A collection class for the managed LDPath programs in the Contenthub. Operates on a {@link Map} keeping the
+ * <name,program> pairs.
+ *
* @author anil.sinaci
*
*/
@@ -28,26 +31,52 @@ public class LDProgramCollection {
private Map<String,String> nameProgramMap;
+ /**
+ * Creates an {@link LDProgramCollection} based on a provide {@link Map} keeping <name,program> pairs.
+ *
+ * @param nameProgramMap
+ * On which the {@link LDProgramCollection} will be initialized.
+ */
public LDProgramCollection(Map<String,String> nameProgramMap) {
this.nameProgramMap = nameProgramMap;
}
+ /**
+ * This method returns the list of LDPath programs stored in the scope of Contenthub.
+ *
+ * @return {@link List} of {@link LDProgram}s.
+ */
public List<LDProgram> asList() {
List<LDProgram> list = new ArrayList<LDProgram>();
- for(Map.Entry<String,String> entry : nameProgramMap.entrySet()) {
+ for (Map.Entry<String,String> entry : nameProgramMap.entrySet()) {
list.add(new LDProgram(entry.getKey(), entry.getValue()));
}
return list;
}
+ /**
+ * This method returns the programs stored in the scope of Contenthub as a {@link Map}.
+ *
+ * @return {@link Map} keeping the <name,program> pairs.
+ */
public Map<String,String> asMap() {
return this.nameProgramMap;
}
-
+
+ /**
+ * This method returns the names of LDPath programs stored in the scope of Contenthub.
+ *
+ * @return {@link List} of program names.
+ */
public List<String> getProgramNames() {
return new ArrayList<String>(nameProgramMap.keySet());
}
-
+
+ /**
+ * This method returns the LDPath programs themselves that are stored in the scope of Contenthub.
+ *
+ * @return {@link List} of programs.
+ */
public List<String> getPrograms() {
return new ArrayList<String>(nameProgramMap.values());
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/ldpath/LDProgramManager.java Tue Jan 31 13:43:54 2012
@@ -22,50 +22,87 @@ import java.util.Map;
import org.apache.clerezza.rdf.core.MGraph;
+/**
+ * This interface provides create, retrieve, delete operations for LDPath programs to be managed in the scope
+ * of Contenthub.
+ *
+ * @author anil.sinaci
+ *
+ */
public interface LDProgramManager {
- /**
- * Saves program to persistent storage with given name and initialize Solr Core with same name
- * @param programName name of the submitted program, also will be name of corresponding Solr Core
- * @param ldPathProgram LDPath Program in the form of {@link String}
- * @throws LDPathException is thrown while parsing program and creating Solr Core
- */
- public void submitProgram(String programName, String ldPathProgram) throws LDPathException;
-
- /**
- * Saves program to persistent storage with given name and initialize Solr Core with same name
- * @param programName name of the submitted program, also will be name of corresponding Solr Core
- * @param ldPathProgram LDPath Program in the form of {@link java.io.Reader}
- * @throws LDPathException is thrown while parsing program and creating Solr Core
- */
- public void submitProgram(String programName, Reader ldPathProgram) throws LDPathException;
-
- /**
- * Checks whether a program-core pair exist with given name or not
- * @param programName name of the program/core
- * @return {@link true} if a program with given name exists; {@link false} otherwise
- */
- public boolean isManagedProgram(String programName);
-
- /**
- * Retrieves the program managed by {@link ProgramManager} with given name
- * @param programName name of the program that will be retrieved
- * @return requested program as String, if such program does not exist, returns {@link false}
- */
- public String getProgramByName(String programName);
-
- /**
- * Deletes both the program and the corresponding Solr Core
- * @param programName name of the program-core pair to be deleted
- */
- public void deleteProgram(String programName);
-
- /**
- * Used to retrieve names and programs of all currently managed program-core pairs
- * @return All managed programs with their names as {@link LDProgramCollection}
- */
- public LDProgramCollection retrieveAllPrograms();
-
- public Map<String,Collection<?>> executeProgram(String programName, MGraph graph) throws LDPathException;
+ /**
+ * Saves LDPath program to persistent storage with given name and initializes a new Solr core with the
+ * same name
+ *
+ * @param programName
+ * name of the submitted program, also will be name of corresponding Solr Core
+ * @param ldPathProgram
+ * LDPath Program in the form of {@link String}
+ * @throws LDPathException
+ * is thrown while parsing program and creating Solr Core
+ */
+ public void submitProgram(String programName, String ldPathProgram) throws LDPathException;
+
+ /**
+ * Saves LDPath program to persistent storage with given name and initializes a new Solr core with the
+ * same name
+ *
+ * @param programName
+ * name of the submitted program, also will be name of corresponding Solr Core
+ * @param ldPathProgram
+ * LDPath Program in the form of {@link java.io.Reader}
+ * @throws LDPathException
+ * is thrown while parsing program and creating Solr Core
+ */
+ public void submitProgram(String programName, Reader ldPathProgram) throws LDPathException;
+
+ /**
+ * Checks whether a program-core pair exists with given name or not
+ *
+ * @param programName
+ * name of the program/core
+ * @return {@link true} if a program with given name exists; {@link false} otherwise
+ */
+ public boolean isManagedProgram(String programName);
+
+ /**
+ * Retrieves the program managed by {@link ProgramManager} with given name
+ *
+ * @param programName
+ * name of the program that will be retrieved
+ * @return requested program as String, if such program does not exist, returns {@link false}
+ */
+ public String getProgramByName(String programName);
+
+ /**
+ * Deletes both the program and the corresponding Solr Core
+ *
+ * @param programName
+ * name of the program-core pair to be deleted
+ */
+ public void deleteProgram(String programName);
+
+ /**
+ * Used to retrieve names and programs of all currently managed program-core pairs
+ *
+ * @return All managed programs as {@link LDProgramCollection}
+ */
+ public LDProgramCollection retrieveAllPrograms();
+
+ /**
+ * This method first tries to obtain the program itself through the given <code>programName</code> and if
+ * the program is obtained it is executed on the given <code>graph</code>.
+ *
+ * @param programName
+ * name of the program to be executed
+ * @param graph
+ * a Clerezza graph on which the specified program will be executed
+ * @return the {@link Map} containing the results obtained by executing the given program on the given
+ * graph. Keys of the map corresponds to fields in the program and values of the map corresponds
+ * to results obtained for the field specified in the key.
+ * @throws LDPathException
+ */
+ public Map<String,Collection<?>> executeProgram(String programName, MGraph graph) throws LDPathException;
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/SearchException.java Tue Jan 31 13:43:54 2012
@@ -16,9 +16,11 @@
*/
package org.apache.stanbol.contenthub.servicesapi.search;
-import org.apache.stanbol.contenthub.servicesapi.AbstractContenthubException;
+import org.apache.stanbol.contenthub.servicesapi.exception.AbstractContenthubException;
/**
+ * Exception to be thrown in search related operations of Contenthub.
+ *
* @author anil.sinaci
*
*/
@@ -39,7 +41,7 @@ public class SearchException extends Abs
public SearchException(Throwable cause) {
super(cause);
}
-
+
/**
* @param msg
* @param cause
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/FeaturedSearch.java Tue Jan 31 13:43:54 2012
@@ -20,25 +20,128 @@ import java.util.List;
import org.apache.solr.common.params.SolrParams;
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
+import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeywordSearch;
+import org.apache.stanbol.contenthub.servicesapi.search.solr.SolrSearch;
/**
- * @author anil.sinaci
+ * This interface provides search functionalities over the submitted content items to the Contenthub. It
+ * mainly uses the two main search components of Contenthub which are {@link SolrSearch} and
+ * {@link RelatedKeywordSearch}. The main aim of the interface to provide user with a unified search
+ * functionality which returns results containing fetched documents from underlying Solr cores together with
+ * the related keywords that are obtained from various types of sources.
*
+ * @author anil.sinaci
+ * @see SolrSearch
+ * @see RelatedKeywordSearch
*/
public interface FeaturedSearch {
+ /**
+ * This method returns a {@link SearchResult} as a unified search response. The response contains content
+ * items retrieved from the default index of Contenthub for the given <code>queryTerm</code>. It also
+ * consists of related keywords which are obtained from the available {@link RelatedKeywordSearch}
+ * instances. To obtain related keywords, the given query term is tokenized with
+ * {@link #tokenizeEntities(String)}. And then, related keyword searchers are queried for all the query
+ * tokens. Furthermore, the {@link SearchResult} includes Solr facets that are obtained for the obtained
+ * content items.
+ *
+ * @param queryTerm
+ * Query term for which the unified response will be obtained
+ * @return {@link SearchResult} for the given query term. For details of the response see
+ * {@link SearchResult}.
+ * @throws SearchException
+ */
SearchResult search(String queryTerm) throws SearchException;
-
+
+ /**
+ * This method returns a {@link SearchResult} as a unified search response. The response contains content
+ * items retrieved from the index, which is accessed using the given <code>ldProgramName</code>, of
+ * Contenthub for the given <code>queryTerm</code>. This name corresponds to a Solr Core name within
+ * Contenthub. It also consists of related keywords that are obtained from the available
+ * {@link RelatedKeywordSearch} instances. This method also takes an ontology URI. Using the URI, actual
+ * ontology is retrieved and it is used as related keyword source. To obtain related keywords, the given
+ * query term is tokenized with {@link #tokenizeEntities(String)}. And then, related keyword searchers are
+ * queried for all the query tokens. Furthermore, the {@link SearchResult} includes Solr facets that are
+ * obtained for the obtained content items.
+ *
+ * @param queryTerm
+ * Query term for which the unified response will be obtained
+ * @param ontologyURI
+ * URI of an ontology in which related keywords will be searched
+ * @param ldProgramName
+ * LDPath program name which is used to obtained the corresponding Solr core which will be
+ * searched for the given query term
+ * @return {@link SearchResult} for the given query term. For details of the response see
+ * {@link SearchResult}.
+ * @throws SearchException
+ */
SearchResult search(String queryTerm, String ontologyURI, String ldProgramName) throws SearchException;
-
+
+ /**
+ * This methods returns a {@link SearchResult} as a unified search response. The response contains content
+ * items retrieved from the default index of Contenthub after executing the given <code>solrQuery</code>.
+ * It also consists of related keywords that are obtained from the available {@link RelatedKeywordSearch}
+ * instances. To obtain related keywords, first the meaningful query terms are extracted from the Solr
+ * query and then they are tokenized with {@link #tokenizeEntities(String)}. And then, related keyword
+ * searchers are queried for all the query tokens. Furthermore, the {@link SearchResult} includes Solr
+ * facets that are obtained for the obtained content items.
+ *
+ * @param solrQuery
+ * for which the search results will be obtained
+ * @return a unified response in a {@link SearchResult} containing actual content items, related keywords
+ * and facets for the obtained content items.
+ * @throws SearchException
+ */
SearchResult search(SolrParams solrQuery) throws SearchException;
-
+
+ /**
+ * This methods returns a {@link SearchResult} as a unified search response. The response contains content
+ * items retrieved from the index, which is accessed using the given <code>ldProgramName</code>, of
+ * Contenthub for the given <code>queryTerm</code>. This name corresponds to a Solr Core name within
+ * Contenthub. It also consists of related keywords that are obtained from the available
+ * {@link RelatedKeywordSearch} instances. This method also takes an ontology URI. Using the URI, actual
+ * ontology is obtained and it is used as related keyword source. To obtain related keywords, first the
+ * meaningful query terms are extracted from the Solr query and then they are tokenized with
+ * {@link #tokenizeEntities(String)}. And then, related keyword searchers are queried for all the query
+ * tokens. Furthermore, the {@link SearchResult} includes Solr facets that are obtained for the obtained
+ * content items.
+ *
+ * @param solrQuery
+ * for which the search results will be obtained
+ * @return a unified response in a {@link SearchResult} containing actual content items, related keywords
+ * and facets for the obtained content items.
+ * @throws SearchException
+ */
SearchResult search(SolrParams solrQuery, String ontologyURI, String ldProgramName) throws SearchException;
- List<String> getFacetNames() throws SearchException;
-
- List<String> getFacetNames(String ldProgramName) throws SearchException;
-
+ /**
+ * This method obtains the available field names of the default index of Contenthub.
+ *
+ * @return {@link List} of field names related index
+ * @throws SearchException
+ */
+ List<String> getFieldNames() throws SearchException;
+
+ /**
+ * This method obtains the available field names of the index, corresponding to the given
+ * <code>ldProgramName</code> of Contenthub. This name corresponds to a Solr Core name within Contenthub.
+ *
+ * @param ldProgramName
+ * Name of the index for which the field names will be obtained.
+ * @return {@link List} of field names related index
+ * @throws SearchException
+ */
+ List<String> getFieldNames(String ldProgramName) throws SearchException;
+
+ /**
+ * This method tokenizes the given query term with the help of Stanbol Enhancer. The query term is fed to
+ * Enhancer and labels of obtained named entities are search in the original query term and if any found
+ * they are treated as a single query term.
+ *
+ * @param queryTerm
+ * To be tokenized
+ * @return {@link List} of query tokens of the given <code>queryTerm</code>.
+ */
List<String> tokenizeEntities(String queryTerm);
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/ResultantDocument.java Tue Jan 31 13:43:54 2012
@@ -16,15 +16,47 @@
*/
package org.apache.stanbol.contenthub.servicesapi.search.featured;
+/**
+ * This interface contains "getter" methods for a search result that can be passed in a {@link SearchResult}
+ * object. A resultant document corresponds to a content item stored in Contenthub.
+ *
+ * @author suat
+ *
+ */
public interface ResultantDocument {
-
+ /**
+ * Returns the URI of the content item corresponding to this search result.
+ *
+ * @return URI of the search result
+ */
String getLocalId();
+ /**
+ * Returns the dereferencable URI of the content item corresponding to this search result. This URI of the
+ * HTML interface of the content item.
+ *
+ * @return Dereferencable URI of the search result
+ */
String getDereferencableURI();
+ /**
+ * Returns the mime type of the content item corresponding to this search result
+ *
+ * @return Mime type of the search result
+ */
String getMimetype();
+ /**
+ * Returns the count of the enhancements of the content item corresponding to this search result
+ *
+ * @return Enhancement count of the search result
+ */
long getEnhancementCount();
+ /**
+ * Returns the title of the content item corresponding to the this search result
+ *
+ * @return Title of the search result
+ */
String getTitle();
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/featured/SearchResult.java Tue Jan 31 13:43:54 2012
@@ -21,16 +21,29 @@ import java.util.Map;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeyword;
+import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeywordSearchManager;
/**
- * This interface defines the structure of a search result returned by
- * {@link Search#search(String[], String, List, Map)}. All results of a search operation are encapsulated.
+ * This interface defines the structure of a unified search result returned by {@link FeaturedSearch} and
+ * {@link RelatedKeywordSearchManager} interfaces. The results contain {@link ResultantDocument}s which are
+ * retrieved from underlying Solr cores, {@link RelatedKeyword}s about the search query and {@link FacetField}
+ * s for the obtained resultant documents. {@link FacetField}s keep information of possible facet values and
+ * corresponding documents counts matching with the facet value. All search results of a search operation are
+ * encapsulated within this interface.
+ * <p>
*
* @author anil.sinaci
*
*/
public interface SearchResult {
+ /**
+ * Returns the resultant documents for the query term that is specified for the search operation. These
+ * resultant documents correspond to content items stored in the underlying Solr cores which are managed
+ * by the Contenthub.
+ *
+ * @return {@link List} of {@link ResultantDocument} encapsulated in this search result
+ */
List<ResultantDocument> getResultantDocuments();
/**
@@ -41,12 +54,35 @@ public interface SearchResult {
*/
List<FacetField> getFacets();
+ /**
+ * Returns the {@link RelatedKeyword}s for the query term that is specified for the search operation.
+ *
+ * @return A {@link Map} containing the {@link RelatedKeyword}s. Keys of the map represents different
+ * tokens that are produced from the original query term. Value of a key is another {@link Map}.
+ * Keys of this inner map represents sources/categories of the related keywords. Values of the
+ * inner map keeps {@link List} of {@link RelatedKeyword}s.
+ */
Map<String,Map<String,List<RelatedKeyword>>> getRelatedKeywords();
-
+
+ /**
+ * Setter for the resultant documents list
+ *
+ * @param resultantDocuments
+ */
void setDocuments(List<ResultantDocument> resultantDocuments);
+ /**
+ * Setter for the facets list
+ *
+ * @param facets
+ */
void setFacets(List<FacetField> facets);
-
+
+ /**
+ * Setter for the related keywords
+ *
+ * @param relatedKeywords
+ */
void setRelatedKeywords(Map<String,Map<String,List<RelatedKeyword>>> relatedKeywords);
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeyword.java Tue Jan 31 13:43:54 2012
@@ -16,25 +16,40 @@
*/
package org.apache.stanbol.contenthub.servicesapi.search.related;
+/**
+ * This interface defines the structure of a keyword which is related to the query term of a search operation.
+ *
+ * @author suat
+ *
+ */
public interface RelatedKeyword {
+ /**
+ * @return Lexical value of the related keyword.
+ */
String getKeyword();
-
+
+ /**
+ * @return Score of the related keyword
+ */
double getScore();
-
+
+ /**
+ * @return Source of the related keyword
+ */
String getSource();
-
- /*
- * To enumerate the source for a related keyword
+
+ /**
+ * To enumerate the source for a related keyword
*/
public enum Source {
-
+
UNKNOWN("Unknown"),
-
+
WORDNET("Wordnet"),
-
+
ONTOLOGY("Ontology");
-
+
private final String name;
private Source(String n) {
@@ -44,7 +59,7 @@ public interface RelatedKeyword {
@Override
public final String toString() {
return this.name;
- }
+ }
}
-
+
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearch.java Tue Jan 31 13:43:54 2012
@@ -21,9 +21,36 @@ import java.util.Map;
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
+/**
+ * Related keyword searcher for a given query keyword.
+ *
+ * @author suat
+ *
+ */
public interface RelatedKeywordSearch {
+ /**
+ * This method searches for related keywords for the given <code>keyword</code>.
+ *
+ * @param keyword
+ * The query keyword for which related keywords will be obtained.
+ * @return a {@link Map} containing the related keywords. Keys of this map represents sources/categories
+ * of the related keywords. Values of the map keeps {@link List} of {@link RelatedKeyword}s.
+ * @throws SearchException
+ */
Map<String,List<RelatedKeyword>> search(String keyword) throws SearchException;
+ /**
+ * This method searches for related keywords for the given <code>keyword</code>. It also takes URI of an
+ * ontology which will be used as a related keyword source while searching through ontology resources.
+ *
+ * @param keyword
+ * The query keyword for which related keywords will be obtained.
+ * @param ontologyURI
+ * URI of the ontology in which related keyword will be searched
+ * @return a {@link Map} containing the related keywords. Keys of this map represents sources/categories
+ * of the related keywords. Values of the map keeps {@link List} of {@link RelatedKeyword}s.
+ * @throws SearchException
+ */
Map<String,List<RelatedKeyword>> search(String keyword, String ontologyURI) throws SearchException;
}
Modified: incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java?rev=1238518&r1=1238517&r2=1238518&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java (original)
+++ incubator/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/search/related/RelatedKeywordSearchManager.java Tue Jan 31 13:43:54 2012
@@ -16,18 +16,102 @@
*/
package org.apache.stanbol.contenthub.servicesapi.search.related;
+import java.util.List;
+import java.util.Map;
+
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
import org.apache.stanbol.contenthub.servicesapi.search.featured.SearchResult;
+/**
+ * This manager interface provides methods for searching related keywords for a query term. These methods
+ * returns the related keyword results encapsulated in {@link SearchResult} objects.<br>
+ * <br>
+ * Three types of sources are offered for related keywords which are <i>Wordnet</i>, <i>a specified
+ * ontology</i> and <i>referenced sites</i> managed by Stanbol Entityhub. Currently, this interface provides
+ * separate services for each type of source, but please note that in the future a more elegant approach may
+ * replace this one.
+ *
+ * @author anil.sinaci
+ *
+ */
public interface RelatedKeywordSearchManager {
-
+
+ /**
+ * Queries all the {@link RelatedKeywordSearch} instances with the given <code>keyword</code> and
+ * aggregates the results.
+ *
+ * @param keyword
+ * Keyword for which related keywords will be obtained
+ * @return a {@link SearchResult} instance which encapsulates the related keyword {@link Map}. This map
+ * would have a single key which is the given <code>keyword</code>. The value corresponding to the
+ * key is another map. Its keys represent the different related keyword sources e.g Wordnet,
+ * dbpedia, etc. Values of inner map contain {@link List} of {@link RelatedKeyword}s obtained from
+ * that certain source.
+ * @throws SearchException
+ */
SearchResult getRelatedKeywordsFromAllSources(String keyword) throws SearchException;
+ /**
+ * Queries all the {@link RelatedKeywordSearch} instances with the given <code>keyword</code> and
+ * aggregates the results. It takes URI of an ontology which is passed to related keyword searchers which
+ * process the ontology.
+ *
+ * @param keyword
+ * Keyword for which related keywords will be obtained
+ * @param ontologyURI
+ * URI of an ontology to be searched for related keywords
+ * @return a {@link SearchResult} instance which encapsulates the related keyword {@link Map}. This map
+ * would have a single key which is the given <code>keyword</code>. The value corresponding to the
+ * key is another map. Its keys represent the different related keyword sources e.g Wordnet,
+ * dbpedia, etc. Values of inner map contain {@link List} of {@link RelatedKeyword}s obtained from
+ * a certain source.
+ * @throws SearchException
+ */
SearchResult getRelatedKeywordsFromAllSources(String keyword, String ontologyURI) throws SearchException;
-
+
+ /**
+ * Searches related keywords in the Wordnet database for the given <code>keyword</code>.
+ *
+ * @param keyword
+ * Keyword for which related keywords will be obtained
+ * @return a {@link SearchResult} instance which encapsulates the related keyword {@link Map}. This map
+ * would have a single key which is the given <code>keyword</code>. The value corresponding to the
+ * key is another map. It also has a single key which indicates the "Wordnet" source. Value
+ * corresponding to this key contains {@link List} of {@link RelatedKeyword}s obtained from
+ * Wordnet.
+ * @throws SearchException
+ */
SearchResult getRelatedKeywordsFromWordnet(String keyword) throws SearchException;
-
+
+ /**
+ * Searches related keywords from the ontology specified by <code>ontologyURI</code> for the given
+ * <code>keyword</code>.
+ *
+ * @param keyword
+ * Keyword for which related keywords will be obtained
+ * @param ontologyURI
+ * URI of an ontology to be searched for related keywords
+ * @return a {@link SearchResult} instance which encapsulates the related keyword {@link Map}. This map
+ * would have a single key which is the given <code>keyword</code>. The value corresponding to the
+ * key is another map. It also has a single key which indicates the "Ontology" source. Value
+ * corresponding to this key contains {@link List} of {@link RelatedKeyword}s obtained from the
+ * ontology.
+ * @throws SearchException
+ */
SearchResult getRelatedKeywordsFromOntology(String keyword, String ontologyURI) throws SearchException;
-
- SearchResult getRelatedKeywordsFromReferencedCites(String keyword) throws SearchException;
+
+ /**
+ * Searches related keywords in the the referenced sites managed by Stanbol Entityhub for the given
+ * <code>keyword</code>.
+ *
+ * @param keyword
+ * Keyword for which related keywords will be obtained
+ * @return a {@link SearchResult} instance which encapsulates the related keyword {@link Map}. This map
+ * would have a single key which is the given <code>keyword</code>. The value corresponding to the
+ * key is another map. Its keys represent the different related keyword sources i.e referenced
+ * sites. Values of inner map contain {@link List} of {@link RelatedKeyword}s obtained from a
+ * certain source.
+ * @throws SearchException
+ */
+ SearchResult getRelatedKeywordsFromReferencedSites(String keyword) throws SearchException;
}