update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
23
.config/Code/User/History/-4c5aef8e/aZFe.py
Normal file
23
.config/Code/User/History/-4c5aef8e/aZFe.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
stop_words = (" a ", " an ", " and ", " are ", " as ", " at ", " be ", " but ", " by ", " for ", " if ", " in ", " is ", " it ", " of ", " on ", " or ", " so ", " that ", " the ", " to ", " with ")
|
||||
punctuation_marks = (".", ",", "?", "!", ":", ";", "'", "\"", "''", "(", ")", "[", "]", "{", "}", "-", "—", "...", "/", "\\", "&", "*", "@", "#", "_", "~", "|", "<", ">", "=", "+")
|
||||
|
||||
def removePunctuationMarks(text: str) -> str:
|
||||
for mark in punctuation_marks:
|
||||
text = text.replace(mark, '')
|
||||
return text
|
||||
|
||||
def removeStopWords(text: str) -> str:
|
||||
for word in stop_words:
|
||||
text = text.replace(word, ' ')
|
||||
return text
|
||||
|
||||
def main():
|
||||
print('welcome')
|
||||
sentence = input('enter a sentence:\n')
|
||||
sentence = removePunctuationMarks(sentence)
|
||||
sentence = removeStopWords(sentence)
|
||||
|
||||
print('sentence with removed stuff is:\n', sentence)
|
||||
|
||||
if __name__== "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue