[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - interactiveDemo.py:1.1.2.3
Andreas Jung
andreas@digicool.com
Thu, 14 Feb 2002 17:56:44 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv10759
Modified Files:
Tag: ajung-textindexng-branch
interactiveDemo.py
Log Message:
- some code cleanup
- added --old option to run script against old TextIndex for
performances measurements
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/interactiveDemo.py 1.1.2.2 => 1.1.2.3 ===
-def index_directory(dirname, verbose, timed):
+def index_directory(dirname, verbose, timed, old):
if not dirname: raise RuntimeError,'no directory name'
@@ -35,29 +35,29 @@
ex.useStemmer = None
ex.useOperator = 'and'
ex.lexicon = None
- ex.useGlobbing = 0
+ ex.useGlobbing = 1
ex.nearDistance = 5
ex.useSimilarity = 0
- ex.stopWords = None
+ ex.stopWords = 'default_en.txt'
+# ex.characterMapping = [('a','b')]
CAT = Catalog.Catalog("cat")
CAT.aq_parent = TO('aq_parent')
- TI = TextIndexNG.TextIndexNG('text',ex, caller = CAT)
- if verbose: TI.debugOn()
- else: TI.debugOff()
- TI.timed_statistics = timed
+ if old:
+ TI = TextIndex.TextIndex('text',ex, caller = CAT)
+ else:
+ TI = TextIndexNG.TextIndexNG('text',ex, caller = CAT, verbose=verbose)
+
+ if verbose: TI.debugOn()
+ else: TI.debugOff()
+ TI.timed_statistics = timed
+
CAT.addIndex('text',TI)
CAT.addColumn('text')
CAT.addColumn('path')
- t1 = TO ('this text is a text')
- t2 = TO ('the quick brown fox jumps over the lazy dog because the dog is quick and jumps quick')
-
- CAT.catalogObject(t1 , 't1')
- CAT.catalogObject(t1 , 't2')
-
files = os.listdir(dirname)
files.sort()
@@ -76,8 +76,10 @@
T = TO(data,fname)
CAT.catalogObject(T,fname)
+ diff = time.time() - ts
print "%d files, total size: %d" % (len(files), bytes)
- print "Indexing time: %5.3lf" % (time.time() - ts)
+ print "Indexing time: %5.3lf" % diff
+ print 'Indexingspeed: %5.3lf KB/sec' % (1.0*bytes/diff/1024.0)
for x in dir(ex):
print "%25s = %s" % (x,getattr(ex,x))
@@ -107,19 +109,21 @@
if __name__== '__main__':
opts,args = getopt.getopt(sys.argv[1:],'hd:',['help','directory=',\
- 'verbose','timed'])
+ 'verbose','timed','old'])
directory = None
verbose = 0
timed = 0
+ old = 0
for k,v in opts:
if k in ['-h','--help']: usage(); sys.exit(1)
if k in ['-d','--directory']: directory = v
if k in ['--verbose']: verbose = 1
if k in ['--timed']: timed = 1
+ if k in ['--old']: old = 1
- cat = index_directory(directory, verbose, timed)
+ cat = index_directory(directory, verbose, timed, old)
interactive_mode(cat)