Revision: 15172
http://gate.svn.sourceforge.net/gate/?rev=15172&view=rev
Author: markagreenwood
Date: 2012-01-22 09:46:41 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
some generics stuff as well as fixing some deprecated warnings
Modified Paths:
--------------
gate/trunk/src/gate/creole/ir/IndexStatistics.java
gate/trunk/src/gate/creole/ir/lucene/LuceneIndexManager.java
gate/trunk/src/gate/creole/ir/lucene/LuceneIndexStatistics.java
gate/trunk/src/gate/creole/ir/lucene/LuceneSearch.java
Modified: gate/trunk/src/gate/creole/ir/IndexStatistics.java
===================================================================
--- gate/trunk/src/gate/creole/ir/IndexStatistics.java 2012-01-22 09:10:48 UTC
(rev 15171)
+++ gate/trunk/src/gate/creole/ir/IndexStatistics.java 2012-01-22 09:46:41 UTC
(rev 15172)
@@ -15,7 +15,7 @@
package gate.creole.ir;
-import java.util.HashMap;
+import java.util.Map;
public interface IndexStatistics{
@@ -27,6 +27,6 @@
public Long getSpecificity(String term);
- public HashMap getTermFrequency(Long docID, String fieldName);
+ public Map getTermFrequency(Long docID, String fieldName);
}
\ No newline at end of file
Modified: gate/trunk/src/gate/creole/ir/lucene/LuceneIndexManager.java
===================================================================
--- gate/trunk/src/gate/creole/ir/lucene/LuceneIndexManager.java
2012-01-22 09:10:48 UTC (rev 15171)
+++ gate/trunk/src/gate/creole/ir/lucene/LuceneIndexManager.java
2012-01-22 09:46:41 UTC (rev 15172)
@@ -32,6 +32,7 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
/** This class represents Lucene implementation of IndexManeager interface.*/
public class LuceneIndexManager implements IndexManager{
@@ -82,7 +83,7 @@
IndexWriter writer = new IndexWriter(
FSDirectory.open(new File(location)),
- new SimpleAnalyzer(),
+ new SimpleAnalyzer(Version.LUCENE_30),
true,
new
IndexWriter.MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH)
);
@@ -116,7 +117,7 @@
try {
IndexWriter writer = new IndexWriter(
FSDirectory.open(new File(indexDefinition.getIndexLocation())),
- new SimpleAnalyzer(),
+ new SimpleAnalyzer(Version.LUCENE_30),
false,
new
IndexWriter.MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH));
writer.optimize();
@@ -174,7 +175,7 @@
IndexWriter writer = new IndexWriter(
FSDirectory.open(new File(location)),
- new SimpleAnalyzer(),
+ new SimpleAnalyzer(Version.LUCENE_30),
false,
new
IndexWriter.MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH)
);
@@ -198,7 +199,8 @@
private org.apache.lucene.document.Document getLuceneDoc(gate.Document
gateDoc){
org.apache.lucene.document.Document luceneDoc =
new org.apache.lucene.document.Document();
- Iterator fields = indexDefinition.getIndexFields();
+ @SuppressWarnings("unchecked")
+ Iterator<IndexField> fields = indexDefinition.getIndexFields();
// luceneDoc.add(Field.Keyword(DOCUMENT_ID,
// gateDoc.getLRPersistenceId().toString()));
@@ -207,7 +209,7 @@
luceneDoc.add(new
Field(DOCUMENT_ID,gateDoc.getLRPersistenceId().toString(),Field.Store.YES,Field.Index.NOT_ANALYZED));
while (fields.hasNext()) {
- IndexField field = (IndexField) fields.next();
+ IndexField field = fields.next();
String valueForIndexing;
if (field.getReader() == null){
Modified: gate/trunk/src/gate/creole/ir/lucene/LuceneIndexStatistics.java
===================================================================
--- gate/trunk/src/gate/creole/ir/lucene/LuceneIndexStatistics.java
2012-01-22 09:10:48 UTC (rev 15171)
+++ gate/trunk/src/gate/creole/ir/lucene/LuceneIndexStatistics.java
2012-01-22 09:46:41 UTC (rev 15172)
@@ -15,10 +15,10 @@
package gate.creole.ir.lucene;
-import java.util.HashMap;
-
import gate.creole.ir.IndexStatistics;
+import java.util.Map;
+
public class LuceneIndexStatistics implements IndexStatistics {
public LuceneIndexStatistics(){
@@ -44,7 +44,7 @@
return null;
}
- public HashMap getTermFrequency(Long docID, String fieldName){
+ public Map getTermFrequency(Long docID, String fieldName){
//NOT IMPLEMENTED YET
return null;
}
Modified: gate/trunk/src/gate/creole/ir/lucene/LuceneSearch.java
===================================================================
--- gate/trunk/src/gate/creole/ir/lucene/LuceneSearch.java 2012-01-22
09:10:48 UTC (rev 15171)
+++ gate/trunk/src/gate/creole/ir/lucene/LuceneSearch.java 2012-01-22
09:46:41 UTC (rev 15172)
@@ -20,6 +20,7 @@
import java.util.Vector;
import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.store.FSDirectory;
@@ -74,15 +75,13 @@
List<QueryResult> result = new Vector<QueryResult>();
try {
- IndexSearcher searcher = new IndexSearcher(
- FSDirectory.open(
- new File(indexedCorpus.getIndexDefinition().getIndexLocation())
- ),
- true);
+ IndexSearcher searcher =
+ new IndexSearcher(IndexReader.open(FSDirectory.open(new File(
+ indexedCorpus.getIndexDefinition().getIndexLocation())), true));
QueryParser parser = new QueryParser(
- Version.LUCENE_29,
+ Version.LUCENE_30,
"body",
- new SimpleAnalyzer());
+ new SimpleAnalyzer(Version.LUCENE_30));
Query luceneQuery = parser.parse(query);
// JP was for lucene 2.2
@@ -96,13 +95,13 @@
int resultlength = hits.length;
- Vector fieldValues = null;
+ Vector<Term> fieldValues = null;
for (int i=0; i<resultlength; i++) {
if (fieldNames != null){
- fieldValues = new Vector();
+ fieldValues = new Vector<Term>();
for (int j=0; j<fieldNames.size(); j++){
- fieldValues.add(new gate.creole.ir.Term(
+ fieldValues.add(new Term(
fieldNames.get(j).toString(),
searcher.doc(hits[i].doc).get(fieldNames.get(j).toString()))
);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs