Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- source = """This is the input string, example for the markov chain repeater. and this will be the source for what is to come as a result of the program"""
- def s_format(_string):
- table = str.maketrans('','',"""!@#$%^&*()_+-=~`[]{}\\|;:",./<>?""")
- return _string.lower().translate(table)
- def make_dict(_string):
- word_dict = dict()
- words = _string.split()
- for i, word in enumerate(words):
- try:
- word_dict[word] = words[i + 1]
- except IndexError:
- word_dict[word] = '.'
- return word_dict
- def main():
- formatted = s_format(source)
- wd = make_dict(formatted)
- print(wd)
- main()
Advertisement
Add Comment
Please, Sign In to add comment