Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def remove_name_prepositions(name):
- """returns a name without its prepositions
- Parameters
- ----------
- name: string
- Full name
- Returns
- -------
- string
- Raises
- ------
- None
- Examples
- --------
- >>> nome = 'Dezêncio Feverêncio de Oitenta e Cinco'
- >>> print(remove_name_prepositions(nome))
- Dezêncio Feverêncio Oitenta Cinco
- See Also
- --------
- -
- """
- name = str(name)
- prepositions = ("do","da","dos","das","de","di","du","e")
- new_word = []
- for token in name.split():
- if token.lower() not in prepositions:
- new_word.append(token)
- return ' '.join(new_word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement