lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r963446 [2/2] - in /lucene/pylucene/branches/python_3: ./ samples/LuceneInAction/ samples/LuceneInAction/lia/advsearching/ samples/LuceneInAction/lia/analysis/ samples/LuceneInAction/lia/analysis/keyword/ samples/LuceneInAction/lia/analysis...
Date Mon, 12 Jul 2010 19:33:47 GMT
Modified: lucene/pylucene/branches/python_3/test/test_Sort.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/python_3/test/test_Sort.py?rev=963446&r1=963445&r2=963446&view=diff
==============================================================================
--- lucene/pylucene/branches/python_3/test/test_Sort.py (original)
+++ lucene/pylucene/branches/python_3/test/test_Sort.py Mon Jul 12 19:33:45 2010
@@ -14,7 +14,7 @@
 
 import math
 
-from itertools import izip
+
 from random import randint
 from unittest import TestCase, main
 from lucene import *
@@ -34,15 +34,15 @@ class SortTestCase(TestCase):
 
         self.data = [
     #      tracer  contents         int            float           string   custom   i18n
              long                  double,                short,                byte,   
       custom parser encoding'
-        [   "A",   "x a",           "5",           "4f",           "c",    "A-3",   u"p\u00EAche",
     "10",                  "-4.0",                "3",                  "126",          "J"
 ],
+        [   "A",   "x a",           "5",           "4f",           "c",    "A-3",   "p\u00EAche",
     "10",                  "-4.0",                "3",                  "126",          "J"
 ],
         [   "B",   "y a",           "5",           "3.4028235E38", "i",    "B-10",  "HAT",
            "1000000000",          "40.0",                "24",                 "1",     
      "I"  ],
-        [   "C",   "x a b c",       "2147483647",  "1.0",          "j",    "A-2",   u"p\u00E9ch\u00E9",
"99999999",            "40.00002343",         "125",                "15",           "H"  ],
+        [   "C",   "x a b c",       "2147483647",  "1.0",          "j",    "A-2",   "p\u00E9ch\u00E9",
"99999999",            "40.00002343",         "125",                "15",           "H"  ],
         [   "D",   "y a b c",       "-1",          "0.0f",         "a",     "C-0",   "HUT",
            str(Long.MAX_VALUE),  str(Double.MIN_VALUE), str(Short.MIN_VALUE), str(Byte.MIN_VALUE),
"G"  ],
         [   "E",   "x a b c d",     "5",           "2f",           "h",     "B-8",   "peach",
          str(Long.MIN_VALUE),  str(Double.MAX_VALUE), str(Short.MAX_VALUE), str(Byte.MAX_VALUE),
"F"  ],
-        [   "F",   "y a b c d",     "2",           "3.14159f",     "g",     "B-1",   u"H\u00C5T",
       "-44",                "343.034435444",       "-3",                 "0",           
"E"  ],
+        [   "F",   "y a b c d",     "2",           "3.14159f",     "g",     "B-1",   "H\u00C5T",
       "-44",                "343.034435444",       "-3",                 "0",           
"E"  ],
         [   "G",   "x a b c d",     "3",           "-1.0",         "f",     "C-100", "sin",
            "323254543543",       "4.043544",            "5",                  "100",    
     "D"  ],
-        [   "H",   "y a b c d",     "0",           "1.4E-45",      "e",     "C-88",  u"H\u00D8T",
       "1023423423005",      "4.043545",            "10",                 "-50",         
"C"  ],
-        [   "I",   "x a b c d e f", "-2147483648", "1.0e+0",       "d",     "A-10",  u"s\u00EDn",
       "332422459999",       "4.043546",            "-340",               "51",          
"B"  ],
+        [   "H",   "y a b c d",     "0",           "1.4E-45",      "e",     "C-88",  "H\u00D8T",
       "1023423423005",      "4.043545",            "10",                 "-50",         
"C"  ],
+        [   "I",   "x a b c d e f", "-2147483648", "1.0e+0",       "d",     "A-10",  "s\u00EDn",
       "332422459999",       "4.043546",            "-340",               "51",          
"B"  ],
         [   "J",   "y a b c d e f", "4",           ".5",           "b",     "C-7",   "HOT",
            "34334543543",        "4.0000220343",        "300",                "2",      
     "A"  ],
         [   "W",   "g",             "1",           None,           None,    None,    None,
             None,                 None,                  None,                 None,    
      None  ],
         [   "X",   "g",             "1",           "0.1",          None,    None,    None,
             None,                 None,                  None,                 None,    
      None  ],
@@ -58,7 +58,7 @@ class SortTestCase(TestCase):
         writer.setMaxBufferedDocs(2)
         writer.setMergeFactor(1000)
 
-        for i in xrange(len(self.data)):
+        for i in range(len(self.data)):
             if (i % 2 == 0 and even) or (i % 2 == 1 and odd):
                 doc = Document()
                 doc.add(Field("tracer", self.data[i][0], Field.Store.YES,
@@ -115,7 +115,7 @@ class SortTestCase(TestCase):
         writer.setMaxBufferedDocs(4)
         writer.setMergeFactor(97)
         
-        for i in xrange(NUM_STRINGS):
+        for i in range(NUM_STRINGS):
             doc = Document()
             num = self.getRandomCharString(self.getRandomNumber(2, 8), 48, 52)
             doc.add(Field("tracer", num, Field.Store.YES, Field.Index.NO))
@@ -139,7 +139,7 @@ class SortTestCase(TestCase):
   
     def getRandomNumberString(self, num, low, high):
 
-        return ''.join([self.getRandomNumber(low, high) for i in xrange(num)])
+        return ''.join([self.getRandomNumber(low, high) for i in range(num)])
   
     def getRandomCharString(self, num):
 
@@ -148,7 +148,7 @@ class SortTestCase(TestCase):
     def getRandomCharString(self, num,  start, end):
         
         return ''.join([chr(self.getRandomNumber(start, end))
-                        for i in xrange(num)])
+                        for i in range(num)])
   
     def getRandomNumber(self, low, high):
   
@@ -255,22 +255,22 @@ class SortTestCase(TestCase):
             doc2 = searcher.doc(scoreDoc.doc)
             v = doc2.getValues("tracer")
             v2 = doc2.getValues("tracer2")
-            for _v, _v2 in izip(v, v2):
+            for _v, _v2 in zip(v, v2):
                 if last is not None:
-                    _cmp = cmp(_v, last)
+                    _cmp = (_v > last) - (_v < last)
                     if _cmp < 0: # ensure first field is in order
                         fail = True
-                        print "fail:", _v, "<", last
+                        print("fail:", _v, "<", last)
 
                     if _cmp == 0: # ensure second field is in reverse order
-                        _cmp = cmp(_v2, lastSub)
+                        _cmp = (_v2 > lastSub) - (_v2 < lastSub)
                         if _cmp > 0:
                             fail = True
-                            print "rev field fail:", _v2, ">", lastSub
+                            print("rev field fail:", _v2, ">", lastSub)
                         elif _cmp == 0: # ensure docid is in order
                             if scoreDoc.doc < lastDocId:
                                 fail = True
-                                print "doc fail:", scoreDoc.doc, ">", lastDocId
+                                print("doc fail:", scoreDoc.doc, ">", lastDocId)
 
                 last = _v
                 lastSub = _v2
@@ -278,7 +278,7 @@ class SortTestCase(TestCase):
                 buff.append(_v + "(" + _v2 + ")(" + str(scoreDoc.doc) + ") ")
 
         if fail:
-            print "topn field1(field2)(docID):", ''.join(buff)
+            print("topn field1(field2)(docID):", ''.join(buff))
 
         self.assert_(not fail, "Found sort results out of order")
   
@@ -305,7 +305,7 @@ class SortTestCase(TestCase):
 
         class longParser(PythonLongParser):
             def parseLong(_self, val):
-                return (val.bytes[0] - ord('A')) * 1234567890L
+                return (val.bytes[0] - ord('A')) * 1234567890
 
         class doubleParser(PythonDoubleParser):
             def parseDouble(_self, val):
@@ -717,7 +717,7 @@ class SortTestCase(TestCase):
             self.full.search(q, tdc)
       
             sds = tdc.topDocs().scoreDocs
-            for i in xrange(1, len(sds)):
+            for i in range(1, len(sds)):
                 self.assert_(sds[i].doc != sds[i - 1].doc)
 
     def testSortWithoutScoreTracking(self):
@@ -818,7 +818,7 @@ class SortTestCase(TestCase):
         bq.setMinimumNumberShouldMatch(1)
 
         for sort in sorts:
-            for tfcOption, actualTFCClass in izip(tfcOptions,
+            for tfcOption, actualTFCClass in zip(tfcOptions,
                                                   actualTFCClasses):
                 tdc = TopFieldCollector.create(sort, 10, tfcOption[0],
                                                tfcOption[1], tfcOption[2],
@@ -965,7 +965,7 @@ class SortTestCase(TestCase):
         """
 
         self.assertEquals(len(m1), len(m2))
-        for key in m1.iterkeys():
+        for key in m1.keys():
             self.assertEquals(m1[key], m2[key], 1e-6)
 
     def getName(self):

Modified: lucene/pylucene/branches/python_3/test/test_StopWords.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/python_3/test/test_StopWords.py?rev=963446&r1=963445&r2=963446&view=diff
==============================================================================
--- lucene/pylucene/branches/python_3/test/test_StopWords.py (original)
+++ lucene/pylucene/branches/python_3/test/test_StopWords.py Mon Jul 12 19:33:45 2010
@@ -34,7 +34,7 @@ class StopWordsTestCase(TestCase):
         try:
             result = StandardTokenizer(Version.LUCENE_CURRENT, self.reader)
             result = StopFilter(True, result, self.stop_set)
-        except Exception, e:
+        except Exception as e:
             self.fail(str(e))
 
 

Modified: lucene/pylucene/branches/python_3/test/test_TermRangeFilter.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/python_3/test/test_TermRangeFilter.py?rev=963446&r1=963445&r2=963446&view=diff
==============================================================================
--- lucene/pylucene/branches/python_3/test/test_TermRangeFilter.py (original)
+++ lucene/pylucene/branches/python_3/test/test_TermRangeFilter.py Mon Jul 12 19:33:45 2010
@@ -393,7 +393,7 @@ class TestTermRangeFilter(BaseTestRangeF
         writer = IndexWriter(farsiIndex, SimpleAnalyzer(), True, 
                              IndexWriter.MaxFieldLength.LIMITED)
         doc = Document()
-        doc.add(Field("content", u"\u0633\u0627\u0628", 
+        doc.add(Field("content", "\u0633\u0627\u0628", 
                       Field.Store.YES, Field.Index.NOT_ANALYZED))
         doc.add(Field("body", "body",
                       Field.Store.YES, Field.Index.NOT_ANALYZED))
@@ -416,10 +416,10 @@ class TestTermRangeFilter(BaseTestRangeF
         # single index Term below should NOT be returned by a
         # TermRangeFilter with a Farsi Collator (or an Arabic one for the
         # case when Farsi is not supported).
-        numHits = search.search(q, TermRangeFilter("content", u"\u062F", u"\u0698", True,
True, collator), 1000).totalHits
+        numHits = search.search(q, TermRangeFilter("content", "\u062F", "\u0698", True, True,
collator), 1000).totalHits
         self.assertEqual(0, numHits, "The index Term should not be included.")
 
-        numHits = search.search(q, TermRangeFilter("content", u"\u0633", u"\u0638", True,
True, collator), 1000).totalHits
+        numHits = search.search(q, TermRangeFilter("content", "\u0633", "\u0638", True, True,
collator), 1000).totalHits
         self.assertEqual(1, numHits, "The index Term should be included.")
         search.close()
 
@@ -432,7 +432,7 @@ class TestTermRangeFilter(BaseTestRangeF
 
         # Danish collation orders the words below in the given order
         # (example taken from TestSort.testInternationalSort() ).
-        words = [u"H\u00D8T", u"H\u00C5T", "MAND"]
+        words = ["H\u00D8T", "H\u00C5T", "MAND"]
         for word in words:
             doc = Document()
             doc.add(Field("content", word, Field.Store.YES,
@@ -454,10 +454,10 @@ class TestTermRangeFilter(BaseTestRangeF
 
         # Unicode order would not include "H\u00C5T" in [ "H\u00D8T", "MAND" ],
         # but Danish collation does.
-        numHits = search.search(q, TermRangeFilter("content", u"H\u00D8T", "MAND", False,
False, collator), 1000).totalHits
+        numHits = search.search(q, TermRangeFilter("content", "H\u00D8T", "MAND", False,
False, collator), 1000).totalHits
         self.assertEqual(1, numHits, "The index Term should be included.")
 
-        numHits = search.search(q, TermRangeFilter("content", u"H\u00C5T", "MAND", False,
False, collator), 1000).totalHits
+        numHits = search.search(q, TermRangeFilter("content", "H\u00C5T", "MAND", False,
False, collator), 1000).totalHits
         self.assertEqual(0, numHits, "The index Term should not be included.")
         search.close()
 

Modified: lucene/pylucene/branches/python_3/test/test_ThaiAnalyzer.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/python_3/test/test_ThaiAnalyzer.py?rev=963446&r1=963445&r2=963446&view=diff
==============================================================================
--- lucene/pylucene/branches/python_3/test/test_ThaiAnalyzer.py (original)
+++ lucene/pylucene/branches/python_3/test/test_ThaiAnalyzer.py Mon Jul 12 19:33:45 2010
@@ -24,22 +24,22 @@ class ThaiAnalyzerTestCase(BaseTokenStre
 
         analyzer = ThaiAnalyzer(Version.LUCENE_CURRENT)
     
-        self._assertAnalyzesTo(analyzer, u"", [])
+        self._assertAnalyzesTo(analyzer, "", [])
 
         self._assertAnalyzesTo(analyzer,
-                               u"การที่ได้ต้องแสดงว่างานดี",
-                               [ u"การ", u"ที่", u"ได้",
u"ต้อง",
-                                 u"แสดง", u"ว่า", u"งาน",
u"ดี" ])
+                               "การที่ได้ต้องแสดงว่างานดี",
+                               [ "การ", "ที่", "ได้",
"ต้อง",
+                                 "แสดง", "ว่า", "งาน",
"ดี" ])
 
         self._assertAnalyzesTo(analyzer,
-                               u"บริษัทชื่อ
XY&Z - คุยกับ xyz@demo.com",
-                               [ u"บริษัท", u"ชื่อ",
u"xy&z", u"คุย", u"กับ", u"xyz@demo.com" ])
+                               "บริษัทชื่อ
XY&Z - คุยกับ xyz@demo.com",
+                               [ "บริษัท", "ชื่อ",
"xy&z", "คุย", "กับ", "xyz@demo.com" ])
 
         # English stop words
         self._assertAnalyzesTo(analyzer,
-                               u"ประโยคว่า The
quick brown fox jumped over the lazy dogs",
-                               [ u"ประโยค", u"ว่า",
u"quick", u"brown", u"fox",
-                                 u"jumped", u"over", u"lazy", u"dogs" ])
+                               "ประโยคว่า The
quick brown fox jumped over the lazy dogs",
+                               [ "ประโยค", "ว่า",
"quick", "brown", "fox",
+                                 "jumped", "over", "lazy", "dogs" ])
 
 
 if __name__ == "__main__":

Modified: lucene/pylucene/branches/python_3/test/test_bug1564.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/python_3/test/test_bug1564.py?rev=963446&r1=963445&r2=963446&view=diff
==============================================================================
--- lucene/pylucene/branches/python_3/test/test_bug1564.py (original)
+++ lucene/pylucene/branches/python_3/test/test_bug1564.py Mon Jul 12 19:33:45 2010
@@ -25,7 +25,7 @@ class Test_Bug1564(unittest.TestCase):
         writer = IndexWriter(self.store, self.analyzer, True,
                              IndexWriter.MaxFieldLength.LIMITED)
         doc = Document()
-        doc.add(Field('all', u'windowpane beplaster rapacious \
+        doc.add(Field('all', 'windowpane beplaster rapacious \
         catatonia gauntlet wynn depressible swede pick dressmake supreme \
         jeremy plumb theoretic bureaucracy causation chartres equipoise \
         dispersible careen heard',



Mime
View raw message