Write a program that asks the user for a word. Next, open up the movie reviews.txt file and examine every review one at a time. If a review contains the desired word you should make a note of the review score in an accumulator variable. Finally, produce some output that tells your user how that word was used across all reviews as well as the classification for this word (any score of 2.0 or higher can be considered

Answers

Answer 1

Answer:

import numpy as np

word = input("Enter a word: ")

acc = []

with open("Downloads/record-collection.txt", "r") as file:

   lines = file.readlines()

   for line in lines:

       if word in line:

           line = line.strip()

           acc.append(int(line[0]))

   if np.mean(acc) >= 2:

       print(f"The word {word} is a positive word")

       print(f"{word} appeared {len(acc)} times")

       print(f"the review of the word {word} is {round(np.mean(acc), 2)}")

   else:

       print(f"the word {word} is a negative word with review\

{round(np.mean(acc), 2)}")

Explanation:

The python program gets the text from the review file, using the user input word to get the definition of reviews based on the word, whether positive or negative.

The program uses the 'with' keyword to open the file and created the acc variable to hold the reviews gotten. The mean of the acc is calculated with the numpy mean method and if the mean is equal to or greater than 2 it is a positive word, else negative.


Related Questions

What line of code makes the character pointer studentPointer point to the character variable userStudent?char userStudent = 'S';char* studentPointer;

Answers

Answer:

char* studentPointer = &userStudent;

Explanation:

Pointers in C are variables used to point to the location of another variable. To declare pointer, the data type must be specified (same as the variable it is pointing to), followed by an asterisk and then the name of the pointer. The reference of the target variable is also assigned to the pointer to allow direct changes from the pointer variable.

A series of gentle often open-ended inquiries that allow the client to progressively examine the assumptions and interpretations here she is made about the victimization experience is called:_____.

Answers

Answer:

Trauma Narrative

Explanation:

Given that Trauma narrative is a form of narrative or carefully designed strategy often used by psychologists to assists the survivors of trauma to understand the meaning or realization of their experiences. It is at the same time serves as a form of openness to recollections or memories considered to be painful.

Hence, A series of gentle often open-ended inquiries that allow the client to progressively examine the assumptions and interpretations he or she is made about the victimization experience is called TRAUMA NARRATIVE

Pointers are addresses and have a numerical value. You can print out the value of a pointer as cout << (unsigned)(p). Write a program to compare p, p + 1, q, and q + 1, where p is an int* and q is a double*. Explain the results.

Answers

Answer:

#include <iostream>

using namespace std;

int main() {

  int i = 2;

  double j = 3;

 

  int *p = &i;

  double *q = &j;

 

  cout << "p = " << p << ", p+1 = " << p+1 << endl;

  cout << "q = " << q << ", q+1 = " << q+1 << endl;

  return 0;

}

Explanation:

In C++, pointers are variables or data types that hold the location of another variable in memory. It is denoted by asterisks in between the data type and pointer name during declaration.

The C++ source code above defines two pointers, "p" which is an integer pointer and "q", a double. The reference of the variables i and j are assigned to p and q respectively and the out of the pointers are the location of the i and j values in memory.

Other Questions
help quick!! correct answer please i have a bad grade in this class lol A patient comes to you with complaints of muscle weakness, muscle spasms, and twitches in the left arm. He does not have loss of sensation, pain, tingling, or numbness. The nerve conduction test and EMG test have abnormal results. Which structure is most likely the location of the problem: SENSORY NEURONS, MOTOR NEURONS, BRAIN, OR SPINAL CORD?Explain your choice Which event from chapter 7 of Holes is related as a flashback?Stanleys shovel not making a dent on the groundStanley jumping on the back of the blade with both feetStanleys grandfather falling in love with Myra MenkeStanleys shovel fitting into the hole HELP MEEEE I RLLY CANT KEEP DOING THIS I WILL GIVE BRAINLIEST PLS ANSWER CORRECTLY !!!! (1 point)11. About a month before an election, you receive a call with a recorded message from a localpolitician asking for her vote. This is an example which kind of advertising?O direct marketingdirect mailO telemarketingO robocall Determine whether the origin is included in the shaded region and whether the shaded region is above or below the line for the graph of the following inequality: (5 points)y > one half x + 2The origin is not included in the shaded region and the shaded area is above the line.The origin is not included in the shaded region and the shaded area is below the line.The origin is included in the shaded region and the shaded area is above the line.The origin is included in the shaded region and the shaded area is below the line. Can someone one help me pls! Its due today!! 1. Why do we exist2. Explain your answerPleases explain I need to know the reason 4 existence Read the text and question carefully and choose the option with the best answer to the question.Mi abuela de noventa y cinco aos necesita estar tranquila, y no necesita estar preocupada. A ella le encantan las flores. Ella no es atltica.What can some friends suggest her to try, on a beginner's level? (1 point)O Quieres correr con nosotras?O Quieres practicar las artes marciales con nosotras?Quieres hacer yoga con nosotras hoy en el jardn?O Quieres patinar con nosotras hoy en la tarde? A golfer hits a golf ball with a club. The mass of the ball is 0.05 kg. The ball accelerates at 2000 m/s2. What is the net force, to the nearest newton, that accelerates the ball? Using the prompt and your knowledge of history, which of these led to expanded trade between East Africa and EastAsia?A)creation of junk shipsB)invention of the compassC)invention of "arabic" numeralsD)greater knowledge of monsoon winds What Phase is water at 120 degrees Celsius? Julie works at a pizza place in Phoenix. She receives a 15% discount on any pizza that she buys. If a large pizza costs $14.00, what is the amount of Julies discount? What is the final cost of her pizza? How has disease increased the rise of civilization? Which source of stress at school would most likely cause a student to lose focus and motivation?O taking a difficut courseO getting a part in a playO having a fight with a friendO trying out for the basketball team Write 6-8 sentences about your favorite building What is the value of x? 31. It is always faster to make digital art than traditional art. true or false ashley's tricycle has two different wheel sizes: one larger wheel and two smaller wheels. As Ashley travels the distance between her house and her neighbor's house on the tricycle, the larger wheel rotates 4 times, and each of the small wheels rotate 12 times. If half the circumference of the larger wheel is 2 inches more than the circumference of one of the smaller wheels, what is the distance, in inches, traveled by the tricycle between ashley's house and her neighbors house?A. 4 inchesb. 48c. 60d. 16