O'Reilly logo

Python 2.6 Text Processing Beginner's Guide by Jeff McNeil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - measuring index benefit

We'll use the following test script to measure the amount of time taken for each query. The provided utilities return XML data and we do not want to count the time needed by the system to structure the document.

  1. Create a new Python file and name it search_for.py. Enter the following listing as it appears:
    import sys
    import time
    from nucular import Nucular
    	
    # create an instance.
    session = Nucular.Nucular(sys.argv[1])
    query = session.Query()
    query.anyWord(sys.argv[2])
    start = time.time()
    d = query.resultDictionaries()
    print "Query Duration: %f" % (time.time() - start)
    print "Results: %d" % len(d)
    
  2. Run the example by passing in the search term mcneil, your results should be as follows.
     (text_processing)$ python ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required