test2.py 541 B

123456789101112131415161718192021222324252627
  1. #
  2. # $Id$
  3. #
  4. from __future__ import print_function
  5. from sphinxapi import *
  6. import sys
  7. docs = ['this is my test text to be highlighted','this is another test text to be highlighted']
  8. words = 'test text'
  9. index = 'forum'
  10. opts = {'before_match':'<b>', 'after_match':'</b>', 'chunk_separator':' ... ', 'limit':400, 'around':15}
  11. cl = SphinxClient()
  12. res = cl.BuildExcerpts(docs, index, words, opts)
  13. if not res:
  14. print ('ERROR: %s\n' % cl.GetLastError())
  15. else:
  16. n = 0
  17. for entry in res:
  18. n += 1
  19. print ('n=%d, res=%s' % (n, entry))
  20. #
  21. # $Id$
  22. #