Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def contains(word,tokens):
- for t in range(len(tokens)):
- if tokens[t] in word:
- return True
- sentence = "Hello mr. smith this is mrs. smith. How are you today? Great!"
- words = sentence.split()
- sentences = []
- new_sentence = ''
- for word in words:
- if not contains(word,['.','?','!']):
- new_sentence += word+' '
- continue
- if word in ['mr.', 'mrs.']:
- new_sentence += word+' '
- continue
- new_sentence += word
- sentences.append(new_sentence)
- new_sentence = ''
- for sentence in sentences:
- print(len(sentence))
- print(sentence)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement