Created
December 27, 2022 09:19
-
-
Save kshirsagarsiddharth/2aa76cb61e4912a7ecec5b5d86322176 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_stop_words(text): | |
# Split the text into words | |
words = text.split() | |
# Define the stop words | |
stop_words = ['a', 'an', 'and', 'the', 'in', 'of'] | |
# Remove stop words | |
clean_words = [word for word in words if word not in stop_words] | |
# Join the clean words into a single string | |
clean_text = ' '.join(clean_words) | |
return clean_text | |
# Test the function | |
text = "There is an stop word in a word" | |
remove_stop_words(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment