lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dor...@apache.org
Subject svn commit: r544685 - in /lucene/java/trunk: CHANGES.txt src/demo/demo-build.template src/demo/org/apache/lucene/demo/SearchFiles.java
Date Tue, 05 Jun 2007 23:52:06 GMT
Author: doronc
Date: Tue Jun  5 16:52:05 2007
New Revision: 544685

URL: http://svn.apache.org/viewvc?view=rev&rev=544685
Log:
LUCENE-909: Demo targets for running the demo.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/demo/demo-build.template
    lucene/java/trunk/src/demo/org/apache/lucene/demo/SearchFiles.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=544685&r1=544684&r2=544685
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Jun  5 16:52:05 2007
@@ -265,6 +265,8 @@
 
  6. LUCENE-907: Include LICENSE.TXT and NOTICE.TXT in the META-INF dirs of
     demo war, demo jar, and the contrib jars. (Michael Busch)
+    
+ 7. LUCENE-909: Demo targets for running the demo. (Doron Cohen)
 
 ======================= Release 2.1.0 2007-02-14 =======================
 

Modified: lucene/java/trunk/src/demo/demo-build.template
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/demo/demo-build.template?view=diff&rev=544685&r1=544684&r2=544685
==============================================================================
--- lucene/java/trunk/src/demo/demo-build.template (original)
+++ lucene/java/trunk/src/demo/demo-build.template Tue Jun  5 16:52:05 2007
@@ -90,9 +90,72 @@
   <target name="clean"
     description="Removes contents of build directory">
     <delete dir="${build.dir}"/>
+    <delete dir="${common.dir}/demo-text-dir"/>
+    <delete dir="${common.dir}/demo-html-dir"/>
   </target>
 
-	
+  <!-- ================================================================== -->
+  <!-- R U N  T E X T  I N D E X I N G  D E M O                           -->
+  <!-- ================================================================== -->
+  <!--                                                                    -->
+  <!-- ================================================================== -->
+  <target name="demo-index-text" depends="jar-demo"
+	description="Run text indexing demo (index the sources of the demo).">
+    <echo>----- (1) Prepare dir ----- </echo>
+    <echo>cd ${common.dir} </echo>
+    <echo>rmdir demo-text-dir </echo>
+    <delete dir="${common.dir}/demo-text-dir"/>
+    <echo>mkdir demo-text-dir </echo>
+    <mkdir dir="${common.dir}/demo-text-dir"/>
+    <echo>cd demo-text-dir </echo>
+    <echo>----- (2) Index the files located under ${common.dir}/src ----- </echo>
+    <invoke-java class="IndexFiles" params="${common.dir}/src/demo" paramsDisplay="../src/demo"
type="text"/>
+  </target>
+
+  <!-- ================================================================== -->
+  <!-- R U N  T E X T  S E A R C H  D E M O                               -->
+  <!-- ================================================================== -->
+  <!--                                                                    -->
+  <!-- ================================================================== -->
+  <target name="demo-search-text" depends="jar-demo"
+	description="Run interactive search demo.">
+    <echo>----- Interactive search ----- </echo>
+    <echo>cd demo-text-dir </echo>
+    <invoke-java class="SearchFiles" params="-index index" paramsDisplay="-index index"
type="text"/>
+  </target>
+
+
+  <!-- ================================================================== -->
+  <!-- R U N  H T M L  I N D E X I N G  D E M O                           -->
+  <!-- ================================================================== -->
+  <!--                                                                    -->
+  <!-- ================================================================== -->
+  <target name="demo-index-html" depends="jar-demo"
+	description="Run html indexing demo (index the javadocs).">
+    <echo>----- (1) Prepare dir ----- </echo>
+    <echo>cd ${common.dir} </echo>
+    <echo>rmdir demo-html-dir </echo>
+    <delete dir="${common.dir}/demo-html-dir"/>
+    <echo>mkdir demo-html-dir </echo>
+    <mkdir dir="${common.dir}/demo-html-dir"/>
+    <echo>cd demo-html-dir </echo>
+    <echo>----- (2) Index the files located under ${common.dir}/src ----- </echo>
+    <invoke-java class="IndexFiles" params="${common.dir}/docs/api" paramsDisplay="../docs/api"
type="html"/>
+  </target>
+
+  <!-- ================================================================== -->
+  <!-- R U N  H T M L  S E A R C H  D E M O                               -->
+  <!-- ================================================================== -->
+  <!--                                                                    -->
+  <!-- ================================================================== -->
+  <target name="demo-search-html" depends="jar-demo"
+	description="Run interactive search demo.">
+    <echo>----- Interactive search ----- </echo>
+    <echo>cd demo-html-dir </echo>
+    <invoke-java class="SearchFiles" params="-index index" paramsDisplay="-index index"
type="html"/>
+  </target>
+
+
   <!--+
       | M A C R O S
       +-->
@@ -112,6 +175,28 @@
         target="${javac.target}">
         <nested/>
       </javac>
+    </sequential>
+  </macrodef>
+
+  <macrodef name="invoke-java">
+    <attribute name="class"/>
+    <attribute name="params"/>
+    <attribute name="paramsDisplay"/>
+    <attribute name="type"/>
+    <sequential>
+      <echo>java -classpath "../${core.name}.jar;../${demo.name}.jar" org.apache.lucene.demo.@{class}
@{paramsDisplay} </echo>
+      <java classname="org.apache.lucene.demo.@{class}"
+            dir="${common.dir}/demo-@{type}-dir"
+            fork="true"
+            failonerror="true"
+            maxmemory="128m"
+      >
+        <arg value="@{params}"/>
+        <classpath>
+           <pathelement location="${common.dir}/${core.name}.jar"/>
+           <pathelement location="${common.dir}/${demo.name}.jar"/>
+        </classpath>
+      </java>
     </sequential>
   </macrodef>
 

Modified: lucene/java/trunk/src/demo/org/apache/lucene/demo/SearchFiles.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/demo/org/apache/lucene/demo/SearchFiles.java?view=diff&rev=544685&r1=544684&r2=544685
==============================================================================
--- lucene/java/trunk/src/demo/org/apache/lucene/demo/SearchFiles.java (original)
+++ lucene/java/trunk/src/demo/org/apache/lucene/demo/SearchFiles.java Tue Jun  5 16:52:05
2007
@@ -111,13 +111,17 @@
       QueryParser parser = new QueryParser(field, analyzer);
     while (true) {
       if (queries == null)                        // prompt the user
-        System.out.print("Query: ");
+        System.out.println("Enter query: ");
 
       String line = in.readLine();
 
       if (line == null || line.length() == -1)
         break;
 
+      line = line.trim();
+      if (line.length() == 0)
+        break;
+      
       Query query = parser.parse(line);
       System.out.println("Searching for: " + query.toString(field));
 
@@ -161,7 +165,7 @@
           break;
         
         if (hits.length() > end) {
-          System.out.print("more (y/n) ? ");
+          System.out.println("more (y/n) ? ");
           line = in.readLine();
           if (line.length() == 0 || line.charAt(0) == 'n')
             break;



Mime
View raw message