<?php
/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
return $ret;
}
+/**
+ * Extract search token from term
+ * @param $term a utf-8 string that can contain any char
+ * @param an array of elementary tokens
+ */
+function tokenize_job_term($term)
+{
+ $term = mb_strtoupper(replace_accent($term));
+ $term = str_replace(array('/', ',', '(', ')', '"', '&', '»', '«'), ' ', $term);
+ $tokens = explode(' ', $term);
+ static $not_tokens = array('ET','AND','DE','DES','DU','D\'','OU','L\'','LA','LE','LES','PAR','AU','AUX','EN','SUR','UN','UNE','IN');
+ foreach ($tokens as &$t) {
+ if (substr($t, 1, 1) == '\'' && in_array(substr($t, 0, 2), $not_tokens)) {
+ $t = substr($t, 2);
+ }
+ if (strlen($t) == 1 || in_array($t, $not_tokens)) {
+ $t = false;
+ continue;
+ }
+ }
+ return array_filter($tokens);
+}
+
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>