This section should be carried out by you using your regular Operating System (Windows, macOS, or perhaps Linux) plus Jupyter. _______________ Open up the area after section in this MS Word file and...

1 answer below »
Please see instructions in the word document for this assignment


This section should be carried out by you using your regular Operating System (Windows, macOS, or perhaps Linux) plus Jupyter. _______________ Open up the area after section in this MS Word file and type in (or paste) your answer(s) and your comments. Section Use Python 3 based Jupyter Notebook on your regular Operating System (Windows, macOS, or perhaps Linux). You are not expected to be an expert in Python 3, because I want you to find a Python 3 program on the Internet and then use it —but, hopefully, you have, at least, an introductory Python 3 background. You will be running wordcount written in Python 3 (if you can only find an appropriate program in Python 2, you would have to convert it to Python 3) to process a text document. The text document is the US Constitution and is available at: https://www.usconstitution.net/const.txt or https://www.constitution.org/cons/constitu.txt (amongst other places). The wordcount program should have the following characteristics: · Remove punctuation from the source file (but be careful with apostrophe-s at the end of word, e.g, state’s) · Lowercase all words · Eliminate stop words with a set of stopwords preferably provided in a separate file · Stem the words — optional extra — stemming is the process of reducing a word into its stem, i.e. its root form (there are Python ways of doing this), but this is an optional extra and not a full requirement. This is quite tough, and I am not expecting any students will be able to complete it. · Sort in order of frequency of occurrence of the words found with the highest occurrences coming first Suggested steps (but you are free to choose your own steps): __1.You will use Jupyter Notebook installed on your host operating system (Windows, macOS, Linux). Thus, make sure that it is installed (or still installed) and available to use. (If you must reinstall, go to http://anaconda.com/install and install a version with Python 3 64-bit.) __2.Find an appropriate Python 3 program on the Internet. Check that it has the appropriate characteristics — or add them from elsewhere. State where you found [all] the program(s). __3.Get the text copy of the US Constitution as the text that you will analyze and load it to your host operating system (Windows, macOS, …). __4.Start a fresh, new Jupyter notebook that you will run locally on your host operating system. __5.Using Markdown, explain the parts of the program as you develop and run it. This is an important part of using the Jupyter Notebook that we will use for Step One. __6.Read in your stopwords file. __7.Read and process your text file (US Constitution, text). __8.Output the top 20 words occurring in the text directly from the Python program such as, for instance: President123 Congress 99 … __9.Optional extra: Create a Word Cloud of the top 20 or so words. __10.Send me your .ipynb file as a second attachment when you email me this completed documentation file. I might like to run it too.
Answered Same DayMay 17, 2021

Answer To: This section should be carried out by you using your regular Operating System (Windows, macOS, or...

Aditya answered on May 18 2021
152 Votes
Untitled Folder/.ipynb_checkpoints/Untitled-checkpoint.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import wordcount"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Top 20 Occuring Words\n",
"{\n",
" \"shall\": 306,\n",
" \"and\": 264,\n",
" \"to\": 202,\n",
" \"in\": 147,\n",
" \"states\": 113,\n",
" \"president\": 106,\n",
" \"by\": 101,\n",
" \"a\": 97,\n",
" \"united\": 85,\n",
" \"any\": 79,\n",
" \"state\": 75,\n",
" \"have\": 64,\n",
" \"congress\": 57,\n",
" \"not\": 44,\n",
" \"may\": 44,\n",
" \"which\": 43,\n",
" \"no\": 42,\n",
" \"all\": 41,\n",
" \"on\": 39,\n",
" \"this\": 37\n",
"}\n"
]
}
],
"source": [
"wordcount.main()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygmen
ts_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Untitled Folder/__pycache__/my.cpython-37.pyc
Untitled Folder/__pycache__/wordcount.cpython-37.pyc
Untitled Folder/my.py
def main():# this is the main function which reads the UsConstitution.txt file
word_list = []
file = open("stopwords.txt", "r") # opening the UsConstitution file in read mode
line = file.readline()
while line:
line = file.readline()
word_list.append(line.strip('\n'))
file.close()
print (word_list)
Untitled Folder/stopwords.txt
ourselves
hers
between
yourself
but
again
there
about
once
during
out
very
having
with
they
own
an
be
some
for
do
its
yours
such
into
of
most
itself
other
off
is
s
am
or
who
as
from
him
each
the
themselves
until
below
are
we
these
your
his
through
don
nor
me
were
her
more
himself
Untitled Folder/Untitled.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import wordcount"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Top 20 Occuring Words\n",
"{\n",
" \"shall\": 306,\n",
" \"and\": 264,\n",
" \"to\": 202,\n",
" \"in\": 147,\n",
" \"states\": 113,\n",
" \"president\": 106,\n",
" \"by\": 101,\n",
" \"a\": 97,\n",
" \"united\": 85,\n",
" \"any\": 79,\n",
" \"state\": 75,\n",
" \"have\": 64,\n",
" \"congress\": 57,\n",
" \"not\": 44,\n",
" \"may\": 44,\n",
" \"which\": 43,\n",
" \"no\": 42,\n",
" \"all\": 41,\n",
" \"on\": 39,\n",
" \"this\": 37\n",
"}\n"
]
}
],
"source": [
"wordcount.main()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Untitled Folder/UsConstitution.txt
Provided by USConstitution.net
------------------------------
[Note: Repealed text is not noted in this version. Spelling errors have been
corrected in this version. For an uncorrected, annotated version of the
Constitution, visit http://www.usconstitution.net/const.html ]
We the People of the United States, in Order to form a more perfect Union,
establish Justice, insure domestic Tranquility, provide for the common
defence, promote the general Welfare, and secure the Blessings of Liberty to
ourselves and our Posterity, do ordain and establish this Constitution for the
United States of America.
Article 1.
Section 1
All legislative Powers herein granted shall be vested in a Congress of the
United States, which shall consist of a Senate and House of Representatives.
Section 2
The House of Representatives shall be composed of Members chosen every second
Year by the People of the several States, and the Electors in each State shall
have the Qualifications requisite for Electors of the most numerous Branch of
the State Legislature.
No Person shall be a Representative who shall not have attained to the Age of
twenty five Years, and been seven Years a Citizen of the United States, and who
shall not, when elected, be an Inhabitant of that State in which he shall be
chosen.
Representatives and direct Taxes shall be apportioned among the several States
which may be included within this Union, according to their respective Numbers,
which shall be determined by adding to the whole Number of free Persons,
including those bound to Service for a Term of Years, and excluding Indians not
taxed, three fifths of all other Persons.
The actual Enumeration shall be made within three Years after the first Meeting
of the Congress of the United States, and within every subsequent Term of ten
Years, in such Manner as they shall by Law direct. The Number of
Representatives shall not exceed one for every thirty Thousand, but each State
shall have at Least one Representative; and until such enumeration shall be
made, the State of New Hampshire shall be entitled to choose three,
Massachusetts eight, Rhode Island and Providence Plantations one, Connecticut
five, New York six, New Jersey four, Pennsylvania eight, Delaware one, Maryland
six, Virginia ten, North Carolina five, South Carolina five and Georgia three.
When vacancies happen in the Representation from any State, the Executive
Authority thereof shall issue Writs of Election to fill such Vacancies.
The House of Representatives shall choose their Speaker and other Officers; and
shall have the sole Power of Impeachment.
Section 3
The Senate of the United States shall be composed of two Senators from each
State, chosen by the Legislature thereof, for six Years; and each Senator shall
have one Vote.
Immediately after they shall be assembled in Consequence of the first Election,
they shall be divided as equally as may be into three Classes. The Seats of the
Senators of the first Class shall be vacated at the Expiration of the second
Year, of the second Class at the Expiration of the fourth Year, and of the
third Class at the Expiration of the sixth Year, so that one third may be
chosen every second Year; and if Vacancies happen by Resignation, or otherwise,
during the Recess of the Legislature of any State, the Executive thereof may
make temporary Appointments until the next Meeting of the Legislature, which
shall then fill such Vacancies.
No person shall be a Senator who shall not have attained to the Age of thirty
Years, and been nine Years a Citizen of the United States, and who shall not,
when elected, be an Inhabitant of that State for which he shall be chosen.
The Vice President of the United States shall be President of the Senate, but
shall have no Vote, unless they be equally divided.
The Senate shall choose their other Officers, and also a President pro tempore,
in the absence of the Vice President, or when he shall exercise the Office of
President of the United States.
The Senate shall have the sole Power to try all Impeachments. When sitting for
that Purpose, they shall be on Oath or Affirmation. When the President of the
United States is tried, the Chief Justice shall preside: And no Person shall be
convicted without the Concurrence of two thirds of the Members present.
Judgment in Cases of Impeachment shall not extend further than to removal from
Office, and disqualification to hold and enjoy any Office of honor, Trust or
Profit under the United States: but the Party convicted shall nevertheless be
liable and subject to Indictment, Trial, Judgment and Punishment, according to
Law.
Section 4
The Times, Places and Manner of holding Elections for Senators and
Representatives, shall be prescribed in each State by the Legislature thereof;
but the Congress may at any time by Law make or alter such Regulations, except
as to the Place of Choosing Senators.
The Congress shall assemble at least once in every Year, and such Meeting shall
be on the first Monday in December, unless they shall by Law appoint a
different Day.
Section 5
Each House shall be the Judge of the Elections, Returns and Qualifications of
its own Members, and a Majority of each shall constitute a Quorum to do
Business; but a smaller number may adjourn from day to day, and may be
authorized to compel the Attendance of absent Members, in such Manner, and
under such Penalties as each House may provide.
Each House may determine the Rules of its Proceedings, punish its Members for
disorderly Behavior, and, with the Concurrence of two-thirds, expel a Member.
Each House shall keep a Journal of its Proceedings, and from time to time
publish the same, excepting such Parts as may in their Judgment require
Secrecy; and the Yeas and Nays of the Members of either House on any question
shall, at the Desire of one fifth of those Present, be entered on the Journal.
Neither House, during the Session of Congress, shall, without the Consent of
the other, adjourn for more than three days, nor to any other Place than that
in which the two Houses shall be sitting.
Section 6
The Senators and Representatives shall receive a Compensation for their
Services, to be ascertained by Law, and paid out of the Treasury of the United
States. They shall in all Cases, except Treason, Felony and Breach of the
Peace, be privileged from Arrest during their Attendance at the Session of
their respective Houses, and in going to and returning from the same; and for
any Speech or Debate in either House, they shall not be questioned in any other
Place.
No Senator or Representative shall, during the Time for which he was elected,
be appointed to any civil Office under the Authority of the United States which
shall have been created, or the Emoluments whereof shall have been increased
during such time; and no Person holding any Office under the United States,
shall be a Member of either House during his Continuance in Office.
Section 7
All bills for raising Revenue shall originate in the House of Representatives;
but the Senate may propose or concur with Amendments as on other Bills.
Every Bill which shall have passed the House of Representatives and the Senate,
shall, before it become a Law, be presented to the President of the United
States; If he approve he shall sign it, but if not he shall return it, with his
Objections to that House in which it shall have originated, who shall enter the
Objections at large on their Journal, and proceed to reconsider it. If after
such Reconsideration two thirds of that House shall agree to pass the Bill, it
shall be sent, together with the Objections, to the other House, by which it
shall likewise be reconsidered, and if approved by two thirds of that House, it
shall become a Law. But in all such Cases the Votes of both Houses shall be
determined by Yeas and Nays, and the Names of the Persons voting for and
against the Bill shall be entered on the Journal of each House respectively. If
any Bill shall not be returned by the President within ten Days (Sundays
excepted) after it shall have been presented to him, the Same shall be a Law,
in like Manner as if he had signed it, unless the Congress by their Adjournment
prevent its Return, in which Case it shall not be a Law.
Every Order, Resolution, or Vote to which the Concurrence of the Senate and
House of Representatives may be necessary (except on a question of Adjournment)
shall be presented to the President of the United States; and before the Same
shall take Effect, shall be approved by him, or being disapproved by him, shall
be repassed by two thirds of the Senate and House of Representatives, according
to the Rules and Limitations prescribed in the Case of a Bill.
Section 8
The Congress shall have Power To lay and collect Taxes, Duties, Imposts and
Excises, to pay the Debts and provide for the common Defence and general
Welfare of the United States; but all Duties, Imposts and Excises shall be
uniform throughout the United States;
To borrow money on the credit of the United States;
To regulate Commerce with foreign Nations, and among the several States, and
with the Indian Tribes;
To establish an uniform Rule of Naturalization, and uniform Laws on the subject
of Bankruptcies throughout the United States;
To coin Money, regulate the Value thereof, and of foreign Coin, and fix the
Standard of Weights and Measures;
To provide for the Punishment of counterfeiting the Securities and current Coin
of the United States;
To establish Post Offices and Post Roads;
To promote the Progress of Science and useful Arts, by securing for limited
Times to Authors and Inventors the exclusive Right to their respective Writings
and Discoveries;
To constitute Tribunals inferior to the supreme Court;
To define and punish Piracies and Felonies committed on the high Seas, and
Offenses against the Law of Nations;
To declare War, grant Letters of Marque and Reprisal, and make Rules concerning
Captures on Land and Water;
To raise and support Armies, but no Appropriation of Money to that Use shall be
for a longer Term than two Years;
To provide and maintain a Navy;
To make Rules for the Government and Regulation of the land and naval Forces;
To provide for calling forth the Militia to execute the Laws of the Union,
suppress Insurrections and repel Invasions;
To provide for organizing, arming, and disciplining, the Militia, and for
governing such Part of them as may be employed in the Service of the United
States, reserving to the States respectively, the Appointment of the Officers,
and the Authority of training the Militia according to the discipline
prescribed by Congress;
To exercise exclusive Legislation in all Cases whatsoever, over such District
(not exceeding ten Miles square) as may, by Cession of particular States, and
the acceptance of Congress, become the Seat of the Government of the United
States, and to exercise like Authority over all Places purchased by the Consent
of the Legislature of the State in which the Same shall be, for the Erection of
Forts, Magazines, Arsenals, dock-Yards, and other needful Buildings; And
To make all Laws which shall be necessary and proper for carrying into
Execution the foregoing Powers, and all...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here