'Take a list of authors and return a list of tokens useful for an
AND search query. This function tries to return tokens in
first name middle names last name order, by assuming that if a comma is
in the author name, the name is in lastname, other names form.'

def get_author_tokens(self, authors, only_first_author=True):

    if authors:
        remove_pat = re.compile(u'[!@#$%^&*(){}`~"\\s\\[\\]/]')
        replace_pat = re.compile(u'[-+.:;,]')
        if only_first_author:
            authors = authors[:1]
        for au in authors:
            has_comma = (u',' in au)
            au = replace_pat.sub(u'    ', au)
            parts = au.split()
            if has_comma:
                parts = (parts[1:] + parts[:1])
            for tok in parts:
                tok = remove_pat.sub(u'', tok).strip()
                if ((len(tok) > 2) and (tok.lower() not in (u'von', u'van', _(u'Unknown').lower()))):
                    (yield tok)
