In Natural language processing stop words removal is an important task. Stop wor
ID: 3591877 • Letter: I
Question
In Natural language processing stop words removal is an important task. Stop words removal is the process of removing the most common words, for example, common words, such as "an" and "the". Write C program that accepts a sentence and print the sentence after removing all stop words. Using function and string to implement the stop words removal if the list of the stop words are given as below "without", "see", "unless", "due", "also", "must", "might", "will", "may", "can", "much", "every", "the", "in", "other", "this", "the", "many", "any", "an", "or", "for", "in", "an", "an" "is", "a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could","couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had" "hadn't", "has", "hasn't", "have", "haven't", "having","he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i ", " i", "i'd", "i'l1", "i'm", "i've", "if", "in", "into", "is","isn't", "it", "it's", "its". "itself", "let's", "me", "more", "most", "mustn't", "my", "mysef" "no", "nor", "not", "of", "off", "on", "once", "only" "ought", "our" "ours", "ourselves", "out", "over", "own", "same" "shan't" "she", "she'd", "she'll", "she's", "should", "shouldn't"., "so", "some", "such", "than","that", "that's", "their", "theirs" "them", "themselves", "then", "there", "there's", "these", "they" "they'd", "hey'", "they're "they've","this" "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've","were",Explanation / Answer
Exicutable Code:
#include<stdio.h>
#include<string.h>
void main() {
char commonWords[][20] = { "without", "see", "unless", "due", "also", "must", "might", "like", "]", "[", "}", "{", "<", ">", "?", """, "\", "/", ")", "(", "will", "may", "can", "much", "every", "the", "in", "other", "this", "the", "many", "any", "an", "or", "for", "in", "an", "an ", "is", "a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could","couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had", "hadn't", "has", "hasn't", "have", "haven't", "having","he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i ", " i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is","isn't", "it", "it's", "its", "itself", "let's", "me", "more", "most", "mustn't", "my", "myself", "no", "nor", "not", "of", "off", "on", "once", "only", "ought", "our", "ours", "ourselves","out", "over", "own", "same", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "so", "some", "such", "than","that", "that's", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've","this", "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've","were", "weren't", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "who's", "whom","why", "why's", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves","Without", "See", "Unless", "Due", "Also", "Must", "Might", "Like", "Will", "May", "Can", "Much", "Every", "The", "In", "Other", "This", "The", "Many", "Any", "An", "Or", "For", "In", "An", "An ", "Is", "A", "About", "Above", "After", "Again", "Against", "All", "Am", "An", "And", "Any", "Are", "Aren't", "As", "At", "Be", "Because", "Been", "Before", "Being", "Below", "Between", "Both", "But", "By", "Can't", "Cannot", "Could","Couldn't", "Did", "Didn't", "Do", "Does", "Doesn't", "Doing", "Don't", "Down", "During", "Each", "Few", "For", "From", "Further", "Had", "Hadn't", "Has", "Hasn't", "Have", "Haven't", "Having","He", "He'd", "He'll", "He's", "Her", "Here", "Here's", "Hers", "Herself", "Him", "Himself", "His", "How", "How's", "I ", " I", "I'd", "I'll", "I'm", "I've", "If", "In", "Into", "Is","Isn't", "It", "It's", "Its", "Itself", "Let's", "Me", "More", "Most", "Mustn't", "My", "Myself", "No", "Nor", "Not", "Of", "Off", "On", "Once", "Only", "Ought", "Our", "Ours", "Ourselves","Out", "Over", "Own", "Same", "Shan't", "She", "She'd", "She'll", "She's", "Should", "Shouldn't", "So", "Some", "Such", "Than","That", "That's", "Their", "Theirs", "Them", "Themselves", "Then", "There", "There's", "These", "They", "They'd", "They'll", "They're", "They've","This", "Those", "Through", "To", "Too", "Under", "Until", "Up", "Very", "Was", "Wasn't", "We", "We'd", "We'll", "We're", "We've","Were", "Weren't", "What", "What's", "When", "When's", "Where", "Where's", "Which", "While", "Who", "Who's", "Whom","Why", "Why's", "With", "Won't", "Would", "Wouldn't", "You", "You'd", "You'll", "You're", ",",".","''","i","I" };
char sentence[500];
int size, flag = 0, i;
printf("Enter sentence : ");
scanf("%[^ ]s", sentence);
char* token = strtok(sentence, " ");
size = sizeof(commonWords) / sizeof(commonWords[0]);
printf("Sentence after removing all stop words : ");
while (token != NULL) {
flag = 0;
for (i = 0; i < size; i++) {
if (strcmp(token, commonWords[i]) == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
printf("%s ", token);
}
token = strtok(NULL, " ");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.