Question

In: Computer Science

HOW WOULD YOU WRITE THIS IN PYTHON? SHOW THIS IN PYTHON CODE PLEASE # DEFINE 'all_keywords',...

HOW WOULD YOU WRITE THIS IN PYTHON?
SHOW THIS IN PYTHON CODE PLEASE
# DEFINE 'all_keywords', A LIST COMPRISED OF ALL OUR NEGATIVE SEARCH KEYWORDS AS REQUIRED BY THE PROJECT
# FOR EACH ELEMENT IN 'full_list' (THE LIST OF LISTS YOU WOULD HAVE CREATD ABOVE THE PREVIOUS LINE)
#       INITIALIZE THE SET 'detected_keywords' TO EMPTY
#       DEFINE VARIABLE 'current_reviewer' FROM CURRENT ELEMENT OF 'full_list' BY EXTRACTING ITS FIRST SUB-ELEMENT,...
#       ...CONVERTING IT TO A STRING, AND THEN STRIPPING THE SUBSTRING '<Author>' OFF THIS STRING
#       GENERATE THE LIST 'separated_words' COMPRISED OF EACH SEPARATE WORD IN THIS REVIEWER'S COMMENTS, BY EXTRACTING THE SECOND SUB-ELEMENT...
#       ...FROM THE CURRENT ELEMENT AND EXECUTING THE '.split' METHOD ON IT
#       FOR EACH ELEMENT IN 'separated_words'
#               FOR EACH ELEMENT IN 'all_keywords'
#                       if LOWER-CASE OF 'all_keywords' IS CONTAINED IN LOWER-CASE OF 'separated_words'
#                               ADD THE CURRENT ELEMENT OF 'all_keywords' TO THE SET 'detected_keywords'
#       IF LENGTH OF 'detected_keywords' IS MORE THAN ZERO
#               PRINT A LINE SUCH AS -- XYZ USED THE FOLLOWING KEYWORDS: {'bad,'rough'}
#       ELSE
#               PRINT A LINE SUCH AS -- XYZ DID NOT USE ANY NEGATIVE KEYWORDS.

Solutions

Expert Solution

SOLUTION:

EXPLANATION: Explanation is done in the code itself Thank you

## negative Words list
all_keywords=["bad","rough","not-good","not-acceptable","irresponsible","not-working","adverse","damage","faulty","evil","damage","adverse","annoying"]

full_list=[["vinu","the producct i have purchased is annoying and bad"],["abhi","it is annoying and damage even"],["devathi","The people are irresponsible and it is not-acceptable"]]
## list to store the reviewer and thier comments

for element in full_list:
##pass through every reviewer comment
detected_keywords= set()
##set to store negative words used
current_reviewer=element[0]
##string to store the reviewer name
separated_words=element[1].split(" ")
##split the entire string into words

##check the every word used by reviewer is in the negative words or not
for word in separated_words:
for badWords in all_keywords:
##for case in sensitive matching convert both of them to lower case
if(word.lower() == badWords.lower()):
##if any word is found add it to the detected words list
detected_keywords.add(word)
  
if(len(detected_keywords)>0):
##if there are any detected words print them
print(current_reviewer," USED THE FOLLOWING KEYWORDS : ",detected_keywords)
else:
## if any negative word is not found
print(current_reviewer," DID NOT USE ANY NEGATIVE KEYWORDS ")
  
CODE IMAGE:

OUTPUT:


Related Solutions

Hi there, please write code in Python 3 and show what input you used for the...
Hi there, please write code in Python 3 and show what input you used for the program. I've been stuck on this for hours! (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here;...
Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
please answer this in a simple python code 1. Write a Python program to construct the...
please answer this in a simple python code 1. Write a Python program to construct the following pattern (with alphabets in the reverse order). It will print the following if input is 5 that is, print z one time, y two times … v five times. The maximum value of n is 26. z yy xxx wwww vvvvvv
Please write in Python code please: Write a program that asks the user to enter 5...
Please write in Python code please: Write a program that asks the user to enter 5 test scores between 0 and 100. The program should display a letter grade for each score and the average test score. You will need to write the following functions, including main: calc_average – The function should accept a list of 5 test scores as an input argument, and return the average of the scores determine_grade – The function should accept a test score as...
can you please convert this python code into java? Python code is as shown below: #...
can you please convert this python code into java? Python code is as shown below: # recursive function def row_puzzle_rec(row, pos, visited):    # if the element at the current position is 0 we have reached our goal    if row[pos] == 0:        possible = True    else:        # make a copy of the visited array        visited = visited[:]        # if the element at the current position has been already visited then...
PYTHON PLEASE!! ALSO: if you can include an explanation of what the code means that would...
PYTHON PLEASE!! ALSO: if you can include an explanation of what the code means that would be appreciated 8.19 LAB*: Program: Soccer team roster (Dictionaries) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers and the ratings in a...
How would you define a manager? How would you define an organization? Please cite your sources....
How would you define a manager? How would you define an organization? Please cite your sources. Give an example of a strong manager and an organization that you worked with in the past or presently.
Please write in Python code please Write a program that creates a dictionary containing course numbers...
Please write in Python code please Write a program that creates a dictionary containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (key) Room Number (value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary containing course numbers and the names of the instructors that teach each course. The dictionary should have the following key-value pairs: Course...
Please write in Python code Write a program that stores the following data in a tuple:...
Please write in Python code Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to display a menu to the user, with the following 4 options: 1 – Display minimum 2 – Display maximum 3 – Display total 4 – Display average 5 – Quit Make your program loop back to this menu until the user chooses option 5. Write code for all 4 other menu choices
Using python as the coding language please write the code for the following problem. Write a...
Using python as the coding language please write the code for the following problem. Write a function called provenance that takes two string arguments and returns another string depending on the values of the arguments according to the table below. This function is based on the geologic practice of determining the distance of a sedimentary rock from the source of its component grains by grain size and smoothness. First Argument Value Second Argument Value Return Value "coarse" "rounded" "intermediate" "coarse"...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT