TokenizerInterface.php 824 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2014 Carsten Brandt
  4. * @license https://github.com/cebe/js-search/blob/master/LICENSE
  5. * @link https://github.com/cebe/js-search#readme
  6. */
  7. namespace cebe\jssearch;
  8. /**
  9. * Interface for all Tokenizers.
  10. *
  11. * @author Carsten Brandt <mail@cebe.cc>
  12. */
  13. interface TokenizerInterface
  14. {
  15. /**
  16. * Tokenizes a string and returns an array of the following format:
  17. *
  18. * ```
  19. * [['word', 2], ['other', 1]]
  20. * ```
  21. *
  22. * where the first part is the token string and the second is a weight value.
  23. *
  24. * @param string $string the string to tokenize
  25. * @return array
  26. */
  27. public function tokenize($string);
  28. /**
  29. * Returns a javascript equivalent of [[tokenize]] that will be used
  30. * on client side to tokenize the search query.
  31. * @return string
  32. */
  33. public function tokenizeJs();
  34. }