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...
Write the code in python only. You will need the graphics library for this assignment. Please...
Write the code in python only. You will need the graphics library for this assignment. Please download the library and place it in the same file as your solution. Draw a 12" ruler on the screen. A ruler is basically a rectangular outline with tick marks extending from the top edge. The tick marks should be drawn at each quarter-inch mark. Below the tick marks, your ruler should show large integers at each full-inch position.
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...
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.
Use Python to solve: show all code: 2) For the last assignment you had to write...
Use Python to solve: show all code: 2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. The program output looked like this: Balance after year 1 is $ 1060.0 Balance after year 2 is $ 1123.6 Balance after year 3 is $ 1191.02 Balance after year 4 is $ 1262.48 Balance after...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT