Question: *Using python to parse the text file. You have to read in the file and separate the lines according to who said them: etc. Use
*Using python to parse the text file. You have to read in the file and separate the lines according to who said them: etc. Use the file format to help you with this. Remember, once you see one of the speakers tags all lines/words belong to that speaker until you see another speakers tag. You can use any text file that have at least two speaker to parse, along with any list for the stop_words.txt
*Once you have the words separated, you must remove all stop words using the provided file stop_Words.txt. You can do this while you are collecting the words as well, but you must remember that you have to read in the stop words from the file and remove any stop word from the texts. Also, remember to remove punctuation from words, just because a word comes at the end of a sentence and has a period at the end of it doesnt make it a different word. Importing string and using string.punctuation is a useful way to specify punctuation.
*You must then count the word frequency in the speakers words. Use a dictionary, where the key is the word and the value is the count.
*Once you have a dictionary for each speaker, you must extract the 40 most frequently used non-stopwords and their counts. Dictionary is unordered you need to create (count,word) tuples, put them in a list, and then sort the list. Put count first in the tuple because sorting (using either sort or sorted) will sort on the first item.
Text file:
MR. LEHRER: Two minutes is up, sir.
PRESIDENT OBAMA: No, I -- I think I've -- I had five seconds before you interrupted me -- was -- (laughter) -- that the irony is that we've seen this model work really well in Massachusetts, because Governor Romney did a good thing, working with Democrats in the state to set up what is essentially the identical model. And as a consequence, people are covered there. It hasn't destroyed jobs. And as a consequence, we now have a system in which we have the opportunity to start bringing down cost, as opposed to just --
MR. ROMNEY: Well, I did with my first statement.
PRESIDENT OBAMA: You did.
MR. ROMNEY: But I'll go on.
PRESIDENT OBAMA: Please elaborate.
MR. ROMNEY: I'll elaborate.
Exactly right.
First of all, I like the way we did it in Massachusetts. I like the fact that in my state, we had Republicans and Democrats come together and work together. What you did instead was to push through a plan without a single Republican vote. As a matter of fact, when Massachusetts did something quite extraordinary, elected a Republican senator to stop "Obamacare," you pushed it through anyway. So entirely on a partisan basis, instead of bringing America together and having a discussion on this important topic, you pushed through something that you and Nancy Pelosi and Harry Reid thought was the best answer and drove it through.
PRESIDENT OBAMA: Governor Romney said this has to be done on a bipartisan basis. This was a bipartisan idea. In fact, it was a Republican idea.
And Governor Romney, at the beginning of this debate, wrote and said, what we did in Massachusetts could be a model for the nation. And I agree that the Democratic legislators in Massachusetts might have given some advice to Republicans in Congress about how to cooperate, but the fact of the matter is, we used the same advisers, and they say it's the same plan.
It -- when Governor Romney talks about this board, for example -- unelected board that we've created -- what this is, is a group of health care experts, doctors, et cetera, to figure out how can we reduce the cost of care in the system overall, because the -- there are two ways of dealing with our health care crisis.
One is to simply leave a whole bunch of people uninsured and let them fend for themselves, to let businesses figure out how long they can continue to pay premiums until finally they just give up and their workers are no longer getting insured, and that's been the trend line. Or, alternatively, we can figure out how do we make the cost of care more effective. And there are ways of doing it.
And the fact of the matter is that when "Obamacare" is fully implemented, we're going to be in a position to show that costs are going down. And over the last two years, health care premiums have gone up, it's true, but they've gone up slower than any time in the last 50 years. So we're already beginning to see progress. In the meantime, folks out there with insurance, you're already getting a rebate.
Let me make one last point. Governor Romney says we should replace it. I'm just going to repeal it, but we can replace it with something. But the problem is he hasn't described what exactly we'd replace it with other than saying we're going to leave it to the states.
But the fact of the matter is that some of the prescriptions that he's offered, like letting you buy insurance across state lines, there's no indication that that somehow is going to help somebody who's got a pre-existing condition be able to finally buy insurance. In fact, it's estimated that by repealing "Obamacare," you're looking at 50 million people losing health insurance at a time when it's vitally important.
MR. LEHRER: Let's let the governor explain what you would do if "Obamacare" is repealed. How would you replace it? What do you have in mind?
MR. ROMNEY: Let -- well, actually -- actually it's -- it's -- it's a lengthy description, but number one, pre-existing conditions are covered under my plan. Number two, young people are able to stay on their family plan. That's already offered in the private marketplace; you don't have -- have the government mandate that for that to occur.
PRESIDENT OBAMA: No, it isn't.
MR. ROMNEY: In my opinion, the government is not effective in -- in bringing down the cost of almost anything. As a matter of fact, free people and free enterprises trying to find ways to do things better are able to be more effective in bringing down the costs than the government will ever be. Your example of the Cleveland clinic is my case in point, along with several others I could describe. This is the private market. These are small -- these are enterprises competing with each other, learning how to do better and better jobs.
Intermountain Health Care does it superbly well.
PRESIDENT OBAMA: They do.
MR. ROMNEY: Mayo Clinic is doing it superbly well, Cleveland Clinic, others. But the right answer is not to have the federal government take over health care and start mandating to the providers across America, telling a patient and a doctor what kind of treatment they can have. That's the wrong way to go. The private market and individual responsibility always work best.
PRESIDENT OBAMA: Let me just point out, first of all, this board that we're talking about can't make decisions about what treatments are given. That's explicitly prohibited in the law.
But let's go back to what Governor Romney indicated, that under his plan he would be able to cover people with pre-existing conditions. Well, actually, Governor, that isn't what your plan does. What your plan does is to duplicate what's already the law, which says if you are out of health insurance for three months then you can end up getting continuous coverage and an insurance company can't deny you if you've -- if it's been under 90 days.
But that's already the law. And that doesn't help the millions of people out there with pre-existing conditions. There's a reason why Governor Romney set up the plan that he did in Massachusetts. It wasn't a government takeover of health care. It was the largest expansion of private insurance. But what it does say is that insurers, you've got to take everybody. Now, that also means that you've got more customers.
But when Governor Romney says that he'll replace it with something but can't detail how it will be in fact replaced, and the reason he set up the system he did in Massachusetts is because there isn't a better way of dealing with the pre-existing conditions problem, it -- it just reminds me of -- you know, he says that he's going to close deductions and loopholes for his tax plan.
That's how it's going to be paid for. But we don't know the details. He says that he's going to replace Dodd-Frank, Wall Street reform. But we don't know exactly which ones. He won't tell us. He now says hes going to replace "Obamacare" and assure that all the good things that are in it are going to be in there and you don't have to worry.
And at some point, I think the American people have to ask themselves, is the reason that Governor Romney is keeping all these plans to replace secret because they're too good? Is -- is it because that somehow middle-class families are going to benefit too much from them? No, the -- the reason is because when we reform Wall Street, when we tackle the problem of pre-existing conditions, then, you know, these are tough problems, and we've got to make choices. And the choices we've made have been ones that ultimately are benefiting middle-class families all across the country.
MR. ROMNEY: -- which is -- which is my experience as a governor is if I come in and -- and lay down a piece of legislation and say it's my way or the highway, I don't get a lot done. What I do is the same way that Tip O'Neill and Ronald Reagan worked together some years ago. When Ronald Reagan ran for office, he laid out the principles that he was going to foster. He said he was going to lower tax rates. He said he was going to broaden the base. You've said the same thing: You're going to simplify the tax code, broaden the base. Those are my principles.
MR. LEHRER: That is a terrific segue to our next segment, and is the role of government. And let's see, role of government and it is -- you are first on this, Mr. President. The question is this. Do you believe -- both of you -- but you have the first two minutes on this, Mr. President -- do you believe there's a fundamental difference between the two of you as to how you view the mission of the federal government?
Stop_Word.txt
an and another any anybody anyhow anyone anything anyway anyways anywhere be became because become becomes becoming been beyond both brief but by c'mon cmon c's c came can can't cant cannot cant cause causes certain certainly changes clearly described despite did didn't didnt different do does doesn't doesnt doing don't dont
Sample Output:
Obama: 48:governor 44:make 35:romney 26:people 25:insurance 21:tax 19:plan 19:medicare 18:money 18:care 17:health 16:years 16:trillion 16:system 16:businesses 15:small 15:deficit 15:cut 15:companies 14:jobs 14:families 13:things 13:taxes 12:education 12:cuts 12:back 11:revenue 11:reason 11:opportunity 11:middleclass 11:middle 11:making 11:folks 11:approach 11:american 10:states 10:spending 10:fact 9:top 9:time Romney : 73:people 39:tax 36:president 35:plan 33:government 32:cut 31:number 31:medicare 23:taxes 22:state 22:percent 22:jobs 22:care 22:america 20:work 19:make 18:years 18:put 18:billion 17:health 17:businesses 16:small 15:lower 15:cost 15:bring 14:business 14:back 13:year 13:time 13:rates 13:place 13:million 13:idea 13:federal 13:economy 12:regulation 12:rate 12:jim 12:insurance 11:trillion
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
