Author: siren Date: Wed May 31 12:58:22 2006 New Revision: 410650 URL: http://svn.apache.org/viewvc?rev=410650&view=rev Log: initial import of ontology web extension
Added: lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/build.xml lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/lib/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/plugin.xml lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/conf/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/conf/tiles-defs.xml lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/controller/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/controller/OntologyProposerController.java lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/resources/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/test/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/web-query-propose-ontology/ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/web-query-propose-ontology/propose.jsp Modified: lucene/nutch/trunk/contrib/web2/plugins/build.xml Modified: lucene/nutch/trunk/contrib/web2/plugins/build.xml URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/build.xml?rev=410650&r1=410649&r2=410650&view=diff ============================================================================== --- lucene/nutch/trunk/contrib/web2/plugins/build.xml (original) +++ lucene/nutch/trunk/contrib/web2/plugins/build.xml Wed May 31 12:58:22 2006 @@ -15,6 +15,7 @@ <ant dir="web-more" target="deploy"/> <ant dir="web-resources" target="deploy"/> <ant dir="web-clustering" target="deploy"/> + <ant dir="web-query-propose-ontology" target="deploy"/> </target> <!-- ====================================================== --> @@ -34,6 +35,7 @@ <ant dir="web-resources" target="clean"/> <ant dir="web-more" target="clean"/> <ant dir="web-clustering" target="clean"/> + <ant dir="web-query-propose-ontology" target="clean"/> </target> </project> Added: lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/build.xml URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/build.xml?rev=410650&view=auto ============================================================================== --- lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/build.xml (added) +++ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/build.xml Wed May 31 12:58:22 2006 @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<project name="web-query-propose-ontology" default="jar-core"> + <import file="../build-plugin.xml" /> + <property name="nutch.root" location="${root}/../../../../" /> + <target name="init-plugin"> + <echo>Copying resources templates</echo> + <copy todir="${build.classes}/resources"> + <fileset dir="${resources.dir}" includes="**/*" /> + </copy> + <echo>Copying UI configuration</echo> + <copy todir="${build.classes}"> + <fileset dir="src/conf" includes="**/*"/> + </copy> + <echo>Copying UI templates</echo> + <copy todir="${deploy.dir}/web"> + <fileset dir="src/web" includes="**/*"/> + </copy> + </target> +</project> Added: lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/plugin.xml URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/plugin.xml?rev=410650&view=auto ============================================================================== --- lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/plugin.xml (added) +++ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/plugin.xml Wed May 31 12:58:22 2006 @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin + id="web-query-propose-ontology" + name="Ontology query proposer" + version="1.0.0" + provider-name="apache.org"> + + <runtime> + <library name="web-query-propose-ontology.jar"> + <export name="*"/> + </library> + </runtime> + + <requires> + <import plugin="nutch-extensionpoints"/> + <import plugin="ontology"/> + </requires> + + <extension id="org.apache.nutch.webapp.extension.UIExtensionPoint" + name="Nutch ui extension point" + point="org.apache.nutch.webapp.extension.UIExtensionPoint"> + <implementation id="web-query-propose-ontology" + class="org.apache.nutch.webapp.extension.UIExtension.VoidImplementation"/> + </extension> + +</plugin> Added: lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/conf/tiles-defs.xml URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/conf/tiles-defs.xml?rev=410650&view=auto ============================================================================== --- lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/conf/tiles-defs.xml (added) +++ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/conf/tiles-defs.xml Wed May 31 12:58:22 2006 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" + "http://struts.apache.org/dtds/tiles-config_1_1.dtd"> +<tiles-definitions> + <definition name="propose" controllerClass="org.apache.nutch.webapp.controller.OntologyProposerController" path="/plugin/web-query-propose-ontology/propose.jsp"/> +</tiles-definitions> \ No newline at end of file Added: lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/controller/OntologyProposerController.java URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/controller/OntologyProposerController.java?rev=410650&view=auto ============================================================================== --- lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/controller/OntologyProposerController.java (added) +++ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/java/org/apache/nutch/webapp/controller/OntologyProposerController.java Wed May 31 12:58:22 2006 @@ -0,0 +1,71 @@ +/* + * Copyright 2006 The Apache Software Foundation + * + * Licensed 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.nutch.webapp.controller; + +import java.io.IOException; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.nutch.ontology.Ontology; +import org.apache.nutch.webapp.common.ServiceLocator; +import org.apache.nutch.webapp.common.Startable; +import org.apache.struts.tiles.ComponentContext; + +public class OntologyProposerController extends NutchController implements Startable { + + public static final String ATTR_NAME="queryPropose"; + + static Ontology ontology; + + public void nutchPerform(ComponentContext tileContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws ServletException, IOException { + + ServiceLocator locator=getServiceLocator(request); + + if (ontology != null) { + LOG.info("Calling ontology with parameter:" + locator.getSearch().getQueryString()); + request.setAttribute(ATTR_NAME, ontology.subclasses(locator.getSearch().getQueryString())); + } + } + + /* + * (non-Javadoc) + * @see org.apache.nutch.webapp.common.Startable#start(javax.servlet.ServletContext) + */ + public void start(ServletContext servletContext) { + + ServiceLocator locator=getServiceLocator(servletContext); + + try { + String urls = locator.getConfiguration().get("extension.ontology.urls"); + ontology = new org.apache.nutch.ontology.OntologyFactory(locator.getConfiguration()).getOntology(); + + LOG.info("Initializing Ontology with urls:" + urls); + + //FIXME initialization code should be in Ontology instead + if (urls==null || urls.trim().equals("")) { + // ignored siliently + } else { + ontology.load(urls.split("\\s+")); + } + } catch (Exception e) { + LOG.info("Exception occured while initializing Ontology" + e); + } + } +} Added: lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/web-query-propose-ontology/propose.jsp URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/web-query-propose-ontology/propose.jsp?rev=410650&view=auto ============================================================================== --- lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/web-query-propose-ontology/propose.jsp (added) +++ lucene/nutch/trunk/contrib/web2/plugins/web-query-propose-ontology/src/web/web-query-propose-ontology/propose.jsp Wed May 31 12:58:22 2006 @@ -0,0 +1,16 @@ +<%@ page session="false"%> +<%@ taglib prefix="tiles" uri="http://jakarta.apache.org/struts/tags-tiles"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%> +<% +// 20041129, Mike Pan and John Xing +// Displays query-refinement hypertext based on ontology. +// Try to be simple here. No mixing with other features such as clustering. +// Please check refine-query-init.jsp, which does necessary initialization. +%> +<div id="refine">Refine your search: +<c:forEach var="propose" items="${queryPropose}"> + <a href="search.do?query=<c:out value="${propose}"/>"> + <c:out value="${propose}"/> + </a> | +</c:forEach> ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 _______________________________________________ Nutch-cvs mailing list Nutch-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nutch-cvs