Skip to content

Commit 96f4dae

Browse files
Albert HaoAlbert Hao
Albert Hao
authored and
Albert Hao
committedSep 4, 2019
python additions
1 parent f1db885 commit 96f4dae

File tree

2 files changed

+144
-20
lines changed

2 files changed

+144
-20
lines changed
 

‎.ipynb_checkpoints/Untitled-checkpoint.ipynb

+110-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": null,
14+
"execution_count": 24,
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
1818
"from IPython.core.display import display, HTML\n",
19+
"from newspaper import Article\n",
1920
"import pandas as pd\n",
2021
"import nltk\n",
2122
"import nltk.data\n",
@@ -25,7 +26,9 @@
2526
"from nltk.stem import PorterStemmer\n",
2627
"from sklearn.cluster import KMeans\n",
2728
"from sklearn.feature_extraction.text import CountVectorizer\n",
28-
"from sklearn.feature_extraction.text import TfidfVectorizer"
29+
"from sklearn.feature_extraction.text import TfidfVectorizer\n",
30+
"from newspaper import Article\n",
31+
"tfidf_counter = TfidfVectorizer(analyzer=\"word\", stop_words=stopwords.words(\"english\"))"
2932
]
3033
},
3134
{
@@ -39,20 +42,122 @@
3942
},
4043
{
4144
"cell_type": "code",
42-
"execution_count": null,
45+
"execution_count": 25,
4346
"metadata": {},
4447
"outputs": [],
45-
"source": []
48+
"source": [
49+
"from newspaper import Article\n",
50+
"articles = {\n",
51+
" 'biology': [\"https://www.khanacademy.org/science/biology\",\n",
52+
" \"https://en.wikipedia.org/wiki/Biology\",\n",
53+
" \"https://en.wikipedia.org/wiki/Evolution\",\n",
54+
" \"https://en.wikipedia.org/wiki/Organism\",\n",
55+
" \"https://en.wikipedia.org/wiki/History_of_biology\",\n",
56+
" \"https://en.wikipedia.org/wiki/Cell_theory\",\n",
57+
" \"https://en.wikipedia.org/wiki/Genetics\",\n",
58+
" \"https://www.livescience.com/44549-what-is-biology.html\",\n",
59+
" \"https://www.cliffsnotes.com/study-guides/biology/biology/the-science-of-biology/introduction-to-biology\",\n",
60+
" \"https://quizlet.com/9815027/college-intro-to-biology-flash-cards/\"],\n",
61+
" 'literature': [\n",
62+
" \"https://www.internationalstudent.com/study-literature/what-is-english-literature/\",\n",
63+
" \"https://en.wikipedia.org/wiki/English_literature\",\n",
64+
" \"https://en.wikipedia.org/wiki/Old_English_literature\",\n",
65+
" \"https://en.wikipedia.org/wiki/Middle_English_literature\",\n",
66+
" \"https://en.wikipedia.org/wiki/Elizabethan_literature\",\n",
67+
" \"https://mc.libguides.com/eng/literaryperiods\",\n",
68+
" \"https://en.wikipedia.org/wiki/Category:Literary_concepts\",\n",
69+
" \"https://en.wikipedia.org/wiki/Literature\",\n",
70+
" \"https://quizlet.com/5656059/literature-concepts-prose-flash-cards/\",\n",
71+
" \"https://en.wikipedia.org/wiki/Literary_fiction\"],\n",
72+
" 'physics': [\n",
73+
" \"https://en.wikipedia.org/wiki/Physics\",\n",
74+
" \"https://www.britannica.com/science/physics-science\",\n",
75+
" \"https://en.wikipedia.org/wiki/Kinematics\",\n",
76+
" \"https://courses.lumenlearning.com/boundless-physics/chapter/basics-of-kinematics/\",\n",
77+
" \"https://www.physicsclassroom.com/class/1DKin/Lesson-1/Introduction\",\n",
78+
" \"https://www.physicsclassroom.com/class/newtlaws/Lesson-2/Drawing-Free-Body-Diagrams\",\n",
79+
" \"https://www.physicsclassroom.com/class/circles/Lesson-1/Speed-and-Velocity\",\n",
80+
" \"https://www.physicsclassroom.com/class/circles/Lesson-3/Newton-s-Law-of-Universal-Gravitation\",\n",
81+
" \"https://www.physicsclassroom.com/class/circuits/Lesson-1/Electric-Potential-Difference\",\n",
82+
" \"https://www.physicsclassroom.com/class/refln/Lesson-2/Image-Characteristics\",\n",
83+
" ],\n",
84+
" 'math': [\n",
85+
" \"https://en.wikipedia.org/wiki/Calculus\",\n",
86+
" \"https://en.wikipedia.org/wiki/Algebra\",\n",
87+
" \"https://en.wikipedia.org/wiki/Geometry\",\n",
88+
" \"http://tutorial.math.lamar.edu/Classes/CalcI/CalcI.aspx\",\n",
89+
" \"https://www.mathsisfun.com/algebra/equation-formula.html\",\n",
90+
" \"https://www.mathsisfun.com/algebra/reciprocal.html\",\n",
91+
" \"https://www.mathsisfun.com/fractions-menu.html\",\n",
92+
" \"https://www.mathsisfun.com/associative-commutative-distributive.html\",\n",
93+
" \"https://www.mathsisfun.com/algebra/cross-multiply.html\",\n",
94+
" \"https://www.mathsisfun.com/geometry/index.html\",\n",
95+
" ],\n",
96+
" 'economics': [\n",
97+
" \"https://en.wikipedia.org/wiki/Economics\",\n",
98+
" \"https://www.bls.gov/\",\n",
99+
" \"https://www.federalreserve.gov/\",\n",
100+
" \"https://www.wsj.com/news/economy\",\n",
101+
" \"https://www.marketwatch.com/economy-politics?mod=top_nav\",\n",
102+
" \"https://www.economist.com/economics-a-to-z\",\n",
103+
" \"https://en.wikipedia.org/wiki/Glossary_of_economics\",\n",
104+
" \"https://en.wikipedia.org/wiki/Supply_and_demand\",\n",
105+
" \"https://en.wikipedia.org/wiki/Laffer_curve\",\n",
106+
" \"https://en.wikipedia.org/wiki/Supply-side_economics\",\n",
107+
" ]\n",
108+
"}\n",
109+
"\n",
110+
"results = []\n",
111+
"for subject in articles.keys():\n",
112+
" for url in articles[subject]:\n",
113+
" article = Article(url)\n",
114+
" article.download()\n",
115+
" article.parse()\n",
116+
" results.append({'text': article.text.replace('\\n','.'), 'subject': subject})"
117+
]
46118
},
47119
{
48120
"cell_type": "code",
49-
"execution_count": 3,
121+
"execution_count": 14,
50122
"metadata": {},
51123
"outputs": [],
52124
"source": [
53125
"# Create TF-IDF Vocab"
54126
]
55127
},
128+
{
129+
"cell_type": "code",
130+
"execution_count": 29,
131+
"metadata": {},
132+
"outputs": [
133+
{
134+
"name": "stdout",
135+
"output_type": "stream",
136+
"text": [
137+
"[[0. 0. 0. ... 0. 0. 0. ]\n",
138+
" [0. 0. 0. ... 0. 0. 0. ]\n",
139+
" [0.00728687 0. 0. ... 0. 0. 0. ]\n",
140+
" ...\n",
141+
" [0. 0. 0. ... 0. 0. 0. ]\n",
142+
" [0. 0. 0. ... 0. 0. 0. ]\n",
143+
" [0.0249377 0. 0. ... 0. 0. 0. ]]\n",
144+
"['T', '__abs__', '__add__', '__and__', '__array__', '__array_finalize__', '__array_function__', '__array_interface__', '__array_prepare__', '__array_priority__', '__array_struct__', '__array_ufunc__', '__array_wrap__', '__bool__', '__class__', '__complex__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__lshift__', '__lt__', '__matmul__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__xor__', 'all', 'any', 'argmax', 'argmin', 'argpartition', 'argsort', 'astype', 'base', 'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 'copy', 'ctypes', 'cumprod', 'cumsum', 'data', 'diagonal', 'dot', 'dtype', 'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getfield', 'imag', 'item', 'itemset', 'itemsize', 'max', 'mean', 'min', 'nbytes', 'ndim', 'newbyteorder', 'nonzero', 'partition', 'prod', 'ptp', 'put', 'ravel', 'real', 'repeat', 'reshape', 'resize', 'round', 'searchsorted', 'setfield', 'setflags', 'shape', 'size', 'sort', 'squeeze', 'std', 'strides', 'sum', 'swapaxes', 'take', 'tobytes', 'tofile', 'tolist', 'tostring', 'trace', 'transpose', 'var', 'view']\n"
145+
]
146+
}
147+
],
148+
"source": [
149+
"tfidf_counter = TfidfVectorizer(analyzer=\"word\", stop_words=stopwords.words(\"english\"))\n",
150+
"docs = []\n",
151+
"for i in results:\n",
152+
" for key in i.keys():\n",
153+
" if key == \"text\":\n",
154+
" docs.append(i[key])\n",
155+
"\n",
156+
"tfidf_results = tfidf_counter.fit_transform(docs).toarray()\n",
157+
"print(tfidf_results)\n",
158+
"print(dir(tfidf_counter))"
159+
]
160+
},
56161
{
57162
"cell_type": "code",
58163
"execution_count": 4,

‎Untitled.ipynb

+34-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": 24,
14+
"execution_count": null,
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"cell_type": "code",
36-
"execution_count": 2,
36+
"execution_count": null,
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
@@ -42,9 +42,22 @@
4242
},
4343
{
4444
"cell_type": "code",
45-
"execution_count": 25,
45+
"execution_count": 40,
4646
"metadata": {},
47-
"outputs": [],
47+
"outputs": [
48+
{
49+
"name": "stdout",
50+
"output_type": "stream",
51+
"text": [
52+
"works\n",
53+
"[{'text': 'if you re seeing this message it means we re having trouble loading external resources on our website if you re behind a web filter please make sure that the domains kastatic org and kasandbox org are unblocked ', 'subject': 'biology'}]\n",
54+
"[{'text': 'if you re seeing this message it means we re having trouble loading external resources on our website if you re behind a web filter please make sure that the domains kastatic org and kasandbox org are unblocked ', 'subject': 'biology'}, {'text': 'what is english literature english literature is one of the most popular majors in colleges and universities in the us with a huge number of students enrolling every year due to its diverse nature and numerous graduate opportunities but with such a broad area of study prospective students are often confused about what a degree in english literature actually provides this article explains what an english literature degree looks like and what doors it can open for graduates common uses of an english literature degree include becoming a writer researcher or teacher however there are many other ways to utilize an english literature degree some students use it as a stepping stone to a degree in law or in this day and age some will use it to begin a path in the digital marketing world whichever route you end up on this degree can open doors to many fulfilling career options what is english literature at its very core english literature refers to the study of texts from around the world written in the english language by studying a degree in english literature you will learn how to analyze a multitude of texts and write clearly using several different styles generally literature refers to different types of text including novels non fiction poetry and plays among other forms however literature is a contested term as new mediums for communication provide different types of contemporary literature literature is generally defined as writing with artistic merit however other types of text such as screenplays nonfiction song lyrics and online communication through blogs and other means could now be considered literature under the contemporary understanding of the term the english literature programs in most major us institutions will largely study the traditional literary texts an english literature major will likely examine texts including poetry drama and prose fiction perhaps briefly covering more contested forms of literature in their chosen path studying literature versus reading for pleasure if you choose to study literature in the us you will learn how to read different texts and analyze the style use of different types of language and meaning in depth you will also learn how to write clearly concisely and analytically in stylistically different forms generally literature courses are divided into different focuses british literature american literature world literature and periods pre and post you will have core courses in several of these topics and will also be expected to choose a focus of your own interest such as creative writing or drama you will ultimately gain a much more in depth understanding of the texts you cover than is possible from solo reading and learn how to express your knowledge through written analysis and presentation or class discussion why study english literature studying english literature in the usa will give you a better understanding of the world around you a literature degree provides transferable skills that teach you to deconstruct and analyze in order to provide a critical viewpoint in all areas as an international student studying english literature demonstrates to an employer that you have a strong grasp of the english language and are proficient in professional english there are several different paths for careers in literature as a graduate you can also take graduate courses and become a teacher lecturer or journalist with common crossovers for graduating english students including business law and education or you can use your analytical skills to move into unexpected careers such as marketing advertising or pretty much anything you are willing you adapt to there are also obvious positions available in the publishing industry from editor to proofreader to literary agent many creative writers including novelists poets and screenwriters among others start their careers by gaining an in depth understanding of written english before developing their individual abilities for expression through writing if you want to gain a strong hold on the english language develop your critical analysis of the world around you and study in a degree that will provide you with numerous different career opportunities english literature could be the right pursuit for you ', 'subject': 'literature'}]\n",
55+
"[{'text': 'if you re seeing this message it means we re having trouble loading external resources on our website if you re behind a web filter please make sure that the domains kastatic org and kasandbox org are unblocked ', 'subject': 'biology'}, {'text': 'what is english literature english literature is one of the most popular majors in colleges and universities in the us with a huge number of students enrolling every year due to its diverse nature and numerous graduate opportunities but with such a broad area of study prospective students are often confused about what a degree in english literature actually provides this article explains what an english literature degree looks like and what doors it can open for graduates common uses of an english literature degree include becoming a writer researcher or teacher however there are many other ways to utilize an english literature degree some students use it as a stepping stone to a degree in law or in this day and age some will use it to begin a path in the digital marketing world whichever route you end up on this degree can open doors to many fulfilling career options what is english literature at its very core english literature refers to the study of texts from around the world written in the english language by studying a degree in english literature you will learn how to analyze a multitude of texts and write clearly using several different styles generally literature refers to different types of text including novels non fiction poetry and plays among other forms however literature is a contested term as new mediums for communication provide different types of contemporary literature literature is generally defined as writing with artistic merit however other types of text such as screenplays nonfiction song lyrics and online communication through blogs and other means could now be considered literature under the contemporary understanding of the term the english literature programs in most major us institutions will largely study the traditional literary texts an english literature major will likely examine texts including poetry drama and prose fiction perhaps briefly covering more contested forms of literature in their chosen path studying literature versus reading for pleasure if you choose to study literature in the us you will learn how to read different texts and analyze the style use of different types of language and meaning in depth you will also learn how to write clearly concisely and analytically in stylistically different forms generally literature courses are divided into different focuses british literature american literature world literature and periods pre and post you will have core courses in several of these topics and will also be expected to choose a focus of your own interest such as creative writing or drama you will ultimately gain a much more in depth understanding of the texts you cover than is possible from solo reading and learn how to express your knowledge through written analysis and presentation or class discussion why study english literature studying english literature in the usa will give you a better understanding of the world around you a literature degree provides transferable skills that teach you to deconstruct and analyze in order to provide a critical viewpoint in all areas as an international student studying english literature demonstrates to an employer that you have a strong grasp of the english language and are proficient in professional english there are several different paths for careers in literature as a graduate you can also take graduate courses and become a teacher lecturer or journalist with common crossovers for graduating english students including business law and education or you can use your analytical skills to move into unexpected careers such as marketing advertising or pretty much anything you are willing you adapt to there are also obvious positions available in the publishing industry from editor to proofreader to literary agent many creative writers including novelists poets and screenwriters among others start their careers by gaining an in depth understanding of written english before developing their individual abilities for expression through writing if you want to gain a strong hold on the english language develop your critical analysis of the world around you and study in a degree that will provide you with numerous different career opportunities english literature could be the right pursuit for you ', 'subject': 'literature'}, {'text': 'study of the fundamental properties of matter and energy this article is about the field of science for other uses see physics disambiguation not to be confused with physical science various examples of physical phenomena physics from ancient greek romanized physik epist m lit knowledge of nature from ph sis nature i am an old man now and when i die and go to heaven there are two matters on which i hope for enlightenment one is quantum electrodynamics and the other is the turbulent motion of fluids and about the former i am rather optimistic see also notes references sources ', 'subject': 'physics'}]\n",
56+
"[{'text': 'if you re seeing this message it means we re having trouble loading external resources on our website if you re behind a web filter please make sure that the domains kastatic org and kasandbox org are unblocked ', 'subject': 'biology'}, {'text': 'what is english literature english literature is one of the most popular majors in colleges and universities in the us with a huge number of students enrolling every year due to its diverse nature and numerous graduate opportunities but with such a broad area of study prospective students are often confused about what a degree in english literature actually provides this article explains what an english literature degree looks like and what doors it can open for graduates common uses of an english literature degree include becoming a writer researcher or teacher however there are many other ways to utilize an english literature degree some students use it as a stepping stone to a degree in law or in this day and age some will use it to begin a path in the digital marketing world whichever route you end up on this degree can open doors to many fulfilling career options what is english literature at its very core english literature refers to the study of texts from around the world written in the english language by studying a degree in english literature you will learn how to analyze a multitude of texts and write clearly using several different styles generally literature refers to different types of text including novels non fiction poetry and plays among other forms however literature is a contested term as new mediums for communication provide different types of contemporary literature literature is generally defined as writing with artistic merit however other types of text such as screenplays nonfiction song lyrics and online communication through blogs and other means could now be considered literature under the contemporary understanding of the term the english literature programs in most major us institutions will largely study the traditional literary texts an english literature major will likely examine texts including poetry drama and prose fiction perhaps briefly covering more contested forms of literature in their chosen path studying literature versus reading for pleasure if you choose to study literature in the us you will learn how to read different texts and analyze the style use of different types of language and meaning in depth you will also learn how to write clearly concisely and analytically in stylistically different forms generally literature courses are divided into different focuses british literature american literature world literature and periods pre and post you will have core courses in several of these topics and will also be expected to choose a focus of your own interest such as creative writing or drama you will ultimately gain a much more in depth understanding of the texts you cover than is possible from solo reading and learn how to express your knowledge through written analysis and presentation or class discussion why study english literature studying english literature in the usa will give you a better understanding of the world around you a literature degree provides transferable skills that teach you to deconstruct and analyze in order to provide a critical viewpoint in all areas as an international student studying english literature demonstrates to an employer that you have a strong grasp of the english language and are proficient in professional english there are several different paths for careers in literature as a graduate you can also take graduate courses and become a teacher lecturer or journalist with common crossovers for graduating english students including business law and education or you can use your analytical skills to move into unexpected careers such as marketing advertising or pretty much anything you are willing you adapt to there are also obvious positions available in the publishing industry from editor to proofreader to literary agent many creative writers including novelists poets and screenwriters among others start their careers by gaining an in depth understanding of written english before developing their individual abilities for expression through writing if you want to gain a strong hold on the english language develop your critical analysis of the world around you and study in a degree that will provide you with numerous different career opportunities english literature could be the right pursuit for you ', 'subject': 'literature'}, {'text': 'study of the fundamental properties of matter and energy this article is about the field of science for other uses see physics disambiguation not to be confused with physical science various examples of physical phenomena physics from ancient greek romanized physik epist m lit knowledge of nature from ph sis nature i am an old man now and when i die and go to heaven there are two matters on which i hope for enlightenment one is quantum electrodynamics and the other is the turbulent motion of fluids and about the former i am rather optimistic see also notes references sources ', 'subject': 'physics'}, {'text': 'this article is about the branch of mathematics for other uses see calculus disambiguation branch of mathematics calculus originally called infinitesimal calculus or the calculus of infinitesimals is the mathematical study of continuous change in the same way that geometry is the study of shape and algebra is the study of generalizations of arithmetic operations it has two major branches differential calculus and integral calculus differential calculus concerns instantaneous rates of change and the slopes of curves integral calculus concerns accumulation of quantities and the areas under and between curves these two branches are related to each other by the fundamental theorem of calculus both branches make use of the fundamental notions of convergence of infinite sequences and infinite series to a well defined limit and if f is a function whose derivative is f on the interval a b then a b f x d x f b f a displaystyle int a b f x dx f b f a furthermore for every x in the interval a b d d x a x f t d t f x displaystyle frac d dx int a x f t dt f x this realization made by both newton and leibniz who based their results on earlier work by isaac barrow was key to the proliferation of analytic results after their work became known the fundamental theorem provides an algebraic method of computing many definite integrals without performing limit processes by finding formulas for antiderivatives it is also a prototype solution of a differential equation differential equations relate an unknown function to its derivatives and are ubiquitous in the sciences applications the logarithmic spiral of the nautilus shell is a classical image used to depict the growth and change related to calculus calculus is used in every branch of the physical sciences actuarial science computer science statistics engineering economics business medicine demography and in other fields wherever a problem can be mathematically modeled and an optimal solution is desired it allows one to go from non constant rates of change to the total change or vice versa and many times in studying a problem we know one and are trying to find the other physics makes particular use of calculus all concepts in classical mechanics and electromagnetism are related through calculus the mass of an object of known density the moment of inertia of objects as well as the total energy of an object within a conservative field can be found by the use of calculus an example of the use of calculus in mechanics is newton s second law of motion historically stated it expressly uses the term change of motion which implies the derivative saying the change of momentum of a body is equal to the resultant force acting on the body and is in the same direction commonly expressed today as force mass acceleration it implies differential calculus because acceleration is the time derivative of velocity or second time derivative of trajectory or spatial position starting from knowing how an object is accelerating we use calculus to derive its path maxwell s theory of electromagnetism and einstein s theory of general relativity are also expressed in the language of differential calculus chemistry also uses calculus in determining reaction rates and radioactive decay in biology population dynamics starts with reproduction and death rates to model population changes calculus can be used in conjunction with other mathematical disciplines for example it can be used with linear algebra to find the best fit linear approximation for a set of points in a domain or it can be used in probability theory to determine the probability of a continuous random variable from an assumed density function in analytic geometry the study of graphs of functions calculus is used to find high points and low points maxima and minima slope concavity and inflection points green s theorem which gives the relationship between a line integral around a simple closed curve c and a double integral over the plane region d bounded by c is applied in an instrument known as a planimeter which is used to calculate the area of a flat surface on a drawing for example it can be used to calculate the amount of area taken up by an irregularly shaped flower bed or swimming pool when designing the layout of a piece of property discrete green s theorem which gives the relationship between a double integral of a function around a simple closed rectangular curve c and a linear combination of the antiderivative s values at corner points along the edge of the curve allows fast calculation of sums of values in rectangular domains for example it can be used to efficiently calculate sums of rectangular domains in images in order to rapidly extract features and detect object another algorithm that could be used is the summed area table in the realm of medicine calculus can be used to find the optimal branching angle of a blood vessel so as to maximize flow from the decay laws for a particular drug s elimination from the body it is used to derive dosing laws in nuclear medicine it is used to build models of radiation transport in targeted tumor therapies in economics calculus allows for the determination of maximal profit by providing a way to easily calculate both marginal cost and marginal revenue calculus is also used to find approximate solutions to equations in practice it is the standard way to solve differential equations and do root finding in most applications examples are methods such as newton s method fixed point iteration and linear approximation for instance spacecraft use a variation of the euler method to approximate curved courses within zero gravity environments varieties over the years many reformulations of calculus have been investigated for different purposes non standard calculus imprecise calculations with infinitesimals were widely replaced with the rigorous definition of limit starting in the s meanwhile calculations with infinitesimals persisted and often led to correct results this led abraham robinson to investigate if it were possible to develop a number system with infinitesimal quantities over which the theorems of calculus were still valid in building upon the work of edwin hewitt and jerzy o he succeeded in developing non standard analysis the theory of non standard analysis is rich enough to be applied in many branches of mathematics as such books and articles dedicated solely to the traditional theorems of calculus often go by the title non standard calculus smooth infinitesimal analysis this is another reformulation of the calculus in terms of infinitesimals based on the ideas of f w lawvere and employing the methods of category theory it views all functions as being continuous and incapable of being expressed in terms of discrete entities one aspect of this formulation is that the law of excluded middle does not hold in this formulation constructive analysis constructive mathematics is a branch of mathematics that insists that proofs of the existence of a number function or other mathematical object should give a construction of the object as such constructive mathematics also rejects the law of excluded middle reformulations of calculus in a constructive framework are generally part of the subject of constructive analysis see also lists other related topics references further reading books online books', 'subject': 'math'}]\n",
57+
"[{'text': 'if you re seeing this message it means we re having trouble loading external resources on our website if you re behind a web filter please make sure that the domains kastatic org and kasandbox org are unblocked ', 'subject': 'biology'}, {'text': 'what is english literature english literature is one of the most popular majors in colleges and universities in the us with a huge number of students enrolling every year due to its diverse nature and numerous graduate opportunities but with such a broad area of study prospective students are often confused about what a degree in english literature actually provides this article explains what an english literature degree looks like and what doors it can open for graduates common uses of an english literature degree include becoming a writer researcher or teacher however there are many other ways to utilize an english literature degree some students use it as a stepping stone to a degree in law or in this day and age some will use it to begin a path in the digital marketing world whichever route you end up on this degree can open doors to many fulfilling career options what is english literature at its very core english literature refers to the study of texts from around the world written in the english language by studying a degree in english literature you will learn how to analyze a multitude of texts and write clearly using several different styles generally literature refers to different types of text including novels non fiction poetry and plays among other forms however literature is a contested term as new mediums for communication provide different types of contemporary literature literature is generally defined as writing with artistic merit however other types of text such as screenplays nonfiction song lyrics and online communication through blogs and other means could now be considered literature under the contemporary understanding of the term the english literature programs in most major us institutions will largely study the traditional literary texts an english literature major will likely examine texts including poetry drama and prose fiction perhaps briefly covering more contested forms of literature in their chosen path studying literature versus reading for pleasure if you choose to study literature in the us you will learn how to read different texts and analyze the style use of different types of language and meaning in depth you will also learn how to write clearly concisely and analytically in stylistically different forms generally literature courses are divided into different focuses british literature american literature world literature and periods pre and post you will have core courses in several of these topics and will also be expected to choose a focus of your own interest such as creative writing or drama you will ultimately gain a much more in depth understanding of the texts you cover than is possible from solo reading and learn how to express your knowledge through written analysis and presentation or class discussion why study english literature studying english literature in the usa will give you a better understanding of the world around you a literature degree provides transferable skills that teach you to deconstruct and analyze in order to provide a critical viewpoint in all areas as an international student studying english literature demonstrates to an employer that you have a strong grasp of the english language and are proficient in professional english there are several different paths for careers in literature as a graduate you can also take graduate courses and become a teacher lecturer or journalist with common crossovers for graduating english students including business law and education or you can use your analytical skills to move into unexpected careers such as marketing advertising or pretty much anything you are willing you adapt to there are also obvious positions available in the publishing industry from editor to proofreader to literary agent many creative writers including novelists poets and screenwriters among others start their careers by gaining an in depth understanding of written english before developing their individual abilities for expression through writing if you want to gain a strong hold on the english language develop your critical analysis of the world around you and study in a degree that will provide you with numerous different career opportunities english literature could be the right pursuit for you ', 'subject': 'literature'}, {'text': 'study of the fundamental properties of matter and energy this article is about the field of science for other uses see physics disambiguation not to be confused with physical science various examples of physical phenomena physics from ancient greek romanized physik epist m lit knowledge of nature from ph sis nature i am an old man now and when i die and go to heaven there are two matters on which i hope for enlightenment one is quantum electrodynamics and the other is the turbulent motion of fluids and about the former i am rather optimistic see also notes references sources ', 'subject': 'physics'}, {'text': 'this article is about the branch of mathematics for other uses see calculus disambiguation branch of mathematics calculus originally called infinitesimal calculus or the calculus of infinitesimals is the mathematical study of continuous change in the same way that geometry is the study of shape and algebra is the study of generalizations of arithmetic operations it has two major branches differential calculus and integral calculus differential calculus concerns instantaneous rates of change and the slopes of curves integral calculus concerns accumulation of quantities and the areas under and between curves these two branches are related to each other by the fundamental theorem of calculus both branches make use of the fundamental notions of convergence of infinite sequences and infinite series to a well defined limit and if f is a function whose derivative is f on the interval a b then a b f x d x f b f a displaystyle int a b f x dx f b f a furthermore for every x in the interval a b d d x a x f t d t f x displaystyle frac d dx int a x f t dt f x this realization made by both newton and leibniz who based their results on earlier work by isaac barrow was key to the proliferation of analytic results after their work became known the fundamental theorem provides an algebraic method of computing many definite integrals without performing limit processes by finding formulas for antiderivatives it is also a prototype solution of a differential equation differential equations relate an unknown function to its derivatives and are ubiquitous in the sciences applications the logarithmic spiral of the nautilus shell is a classical image used to depict the growth and change related to calculus calculus is used in every branch of the physical sciences actuarial science computer science statistics engineering economics business medicine demography and in other fields wherever a problem can be mathematically modeled and an optimal solution is desired it allows one to go from non constant rates of change to the total change or vice versa and many times in studying a problem we know one and are trying to find the other physics makes particular use of calculus all concepts in classical mechanics and electromagnetism are related through calculus the mass of an object of known density the moment of inertia of objects as well as the total energy of an object within a conservative field can be found by the use of calculus an example of the use of calculus in mechanics is newton s second law of motion historically stated it expressly uses the term change of motion which implies the derivative saying the change of momentum of a body is equal to the resultant force acting on the body and is in the same direction commonly expressed today as force mass acceleration it implies differential calculus because acceleration is the time derivative of velocity or second time derivative of trajectory or spatial position starting from knowing how an object is accelerating we use calculus to derive its path maxwell s theory of electromagnetism and einstein s theory of general relativity are also expressed in the language of differential calculus chemistry also uses calculus in determining reaction rates and radioactive decay in biology population dynamics starts with reproduction and death rates to model population changes calculus can be used in conjunction with other mathematical disciplines for example it can be used with linear algebra to find the best fit linear approximation for a set of points in a domain or it can be used in probability theory to determine the probability of a continuous random variable from an assumed density function in analytic geometry the study of graphs of functions calculus is used to find high points and low points maxima and minima slope concavity and inflection points green s theorem which gives the relationship between a line integral around a simple closed curve c and a double integral over the plane region d bounded by c is applied in an instrument known as a planimeter which is used to calculate the area of a flat surface on a drawing for example it can be used to calculate the amount of area taken up by an irregularly shaped flower bed or swimming pool when designing the layout of a piece of property discrete green s theorem which gives the relationship between a double integral of a function around a simple closed rectangular curve c and a linear combination of the antiderivative s values at corner points along the edge of the curve allows fast calculation of sums of values in rectangular domains for example it can be used to efficiently calculate sums of rectangular domains in images in order to rapidly extract features and detect object another algorithm that could be used is the summed area table in the realm of medicine calculus can be used to find the optimal branching angle of a blood vessel so as to maximize flow from the decay laws for a particular drug s elimination from the body it is used to derive dosing laws in nuclear medicine it is used to build models of radiation transport in targeted tumor therapies in economics calculus allows for the determination of maximal profit by providing a way to easily calculate both marginal cost and marginal revenue calculus is also used to find approximate solutions to equations in practice it is the standard way to solve differential equations and do root finding in most applications examples are methods such as newton s method fixed point iteration and linear approximation for instance spacecraft use a variation of the euler method to approximate curved courses within zero gravity environments varieties over the years many reformulations of calculus have been investigated for different purposes non standard calculus imprecise calculations with infinitesimals were widely replaced with the rigorous definition of limit starting in the s meanwhile calculations with infinitesimals persisted and often led to correct results this led abraham robinson to investigate if it were possible to develop a number system with infinitesimal quantities over which the theorems of calculus were still valid in building upon the work of edwin hewitt and jerzy o he succeeded in developing non standard analysis the theory of non standard analysis is rich enough to be applied in many branches of mathematics as such books and articles dedicated solely to the traditional theorems of calculus often go by the title non standard calculus smooth infinitesimal analysis this is another reformulation of the calculus in terms of infinitesimals based on the ideas of f w lawvere and employing the methods of category theory it views all functions as being continuous and incapable of being expressed in terms of discrete entities one aspect of this formulation is that the law of excluded middle does not hold in this formulation constructive analysis constructive mathematics is a branch of mathematics that insists that proofs of the existence of a number function or other mathematical object should give a construction of the object as such constructive mathematics also rejects the law of excluded middle reformulations of calculus in a constructive framework are generally part of the subject of constructive analysis see also lists other related topics references further reading books online books', 'subject': 'math'}, {'text': 'social science that analyzes the production distribution and consumption of goods and services for a topical guide to this subject see outline of economics countries by real gdp growth rate in countries in red were in recession economics most major universities and many colleges have a major school or department in which academic degrees are awarded in the subject whether in the liberal arts business or for professional study in the private sector professional economists are employed as consultants and in industry including banking and finance economists also work for various government departments and agencies for example the national treasury central bank or bureau of statistics there are dozens of prizes awarded to economists each year for outstanding intellectual contributions to the field the most prominent of which is the nobel memorial prize in economic sciences though it is not a nobel prize see also general notes references further reading general information institutions and organizations', 'subject': 'economics'}]\n"
58+
]
59+
}
60+
],
4861
"source": [
4962
"from newspaper import Article\n",
5063
"articles = {\n",
@@ -106,19 +119,24 @@
106119
" \"https://en.wikipedia.org/wiki/Supply-side_economics\",\n",
107120
" ]\n",
108121
"}\n",
109-
"\n",
122+
"print(\"works\")\n",
110123
"results = []\n",
111124
"for subject in articles.keys():\n",
112-
" for url in articles[subject]:\n",
125+
" for url in articles[subject][0:1]:\n",
113126
" article = Article(url)\n",
114127
" article.download()\n",
115128
" article.parse()\n",
116-
" results.append({'text': article.text.replace('\\n','.'), 'subject': subject})"
129+
" text = article.text.replace('\\n','.')\n",
130+
" text = re.sub('\\[.*\\]', '', text)\n",
131+
" text = re.sub('[^a-zA-Z]+', ' ', text)\n",
132+
" text = text.lower()\n",
133+
" results.append({'text': text, 'subject': subject})\n",
134+
" print(results)"
117135
]
118136
},
119137
{
120138
"cell_type": "code",
121-
"execution_count": 14,
139+
"execution_count": null,
122140
"metadata": {},
123141
"outputs": [],
124142
"source": [
@@ -127,20 +145,19 @@
127145
},
128146
{
129147
"cell_type": "code",
130-
"execution_count": 27,
148+
"execution_count": 41,
131149
"metadata": {},
132150
"outputs": [
133151
{
134152
"name": "stdout",
135153
"output_type": "stream",
136154
"text": [
137155
"[[0. 0. 0. ... 0. 0. 0. ]\n",
156+
" [0.02238068 0. 0. ... 0.01805659 0. 0. ]\n",
138157
" [0. 0. 0. ... 0. 0. 0. ]\n",
139-
" [0.00728687 0. 0. ... 0. 0. 0. ]\n",
140-
" ...\n",
141-
" [0. 0. 0. ... 0. 0. 0. ]\n",
142-
" [0. 0. 0. ... 0. 0. 0. ]\n",
143-
" [0.0249377 0. 0. ... 0. 0. 0. ]]\n"
158+
" [0. 0.02016431 0. ... 0. 0.02016431 0.02016431]\n",
159+
" [0. 0. 0.10063461 ... 0.08119137 0. 0. ]]\n",
160+
"['abilities', 'abraham', 'academic', 'accelerating', 'acceleration', 'accumulation', 'acting', 'actually', 'actuarial', 'adapt', 'advertising', 'age', 'agencies', 'agent', 'algebra', 'algebraic', 'algorithm', 'allows', 'along', 'also', 'american', 'among', 'amount', 'analysis', 'analytic', 'analytical', 'analytically', 'analyze', 'analyzes', 'ancient', 'angle', 'another', 'antiderivative', 'antiderivatives', 'anything', 'applications', 'applied', 'approximate', 'approximation', 'area', 'areas', 'arithmetic', 'around', 'article', 'articles', 'artistic', 'arts', 'aspect', 'assumed', 'available', 'awarded', 'bank', 'banking', 'barrow', 'based', 'became', 'become', 'becoming', 'bed', 'begin', 'behind', 'best', 'better', 'biology', 'blogs', 'blood', 'body', 'books', 'bounded', 'branch', 'branches', 'branching', 'briefly', 'british', 'broad', 'build', 'building', 'bureau', 'business', 'calculate', 'calculation', 'calculations', 'calculus', 'called', 'career', 'careers', 'category', 'central', 'change', 'changes', 'chemistry', 'choose', 'chosen', 'class', 'classical', 'clearly', 'closed', 'colleges', 'combination', 'common', 'commonly', 'communication', 'computer', 'computing', 'concavity', 'concepts', 'concerns', 'concisely', 'confused', 'conjunction', 'conservative', 'considered', 'constant', 'construction', 'constructive', 'consultants', 'consumption', 'contemporary', 'contested', 'continuous', 'contributions', 'convergence', 'core', 'corner', 'correct', 'cost', 'could', 'countries', 'courses', 'cover', 'covering', 'creative', 'critical', 'crossovers', 'curve', 'curved', 'curves', 'day', 'death', 'decay', 'deconstruct', 'dedicated', 'defined', 'definite', 'definition', 'degree', 'degrees', 'demography', 'demonstrates', 'density', 'department', 'departments', 'depict', 'depth', 'derivative', 'derivatives', 'derive', 'designing', 'desired', 'detect', 'determination', 'determine', 'determining', 'develop', 'developing', 'die', 'different', 'differential', 'digital', 'direction', 'disambiguation', 'disciplines', 'discrete', 'discussion', 'displaystyle', 'distribution', 'diverse', 'divided', 'domain', 'domains', 'doors', 'dosing', 'double', 'dozens', 'drama', 'drawing', 'drug', 'dt', 'due', 'dx', 'dynamics', 'earlier', 'easily', 'economic', 'economics', 'economists', 'edge', 'editor', 'education', 'edwin', 'efficiently', 'einstein', 'electrodynamics', 'electromagnetism', 'elimination', 'employed', 'employer', 'employing', 'end', 'energy', 'engineering', 'english', 'enlightenment', 'enough', 'enrolling', 'entities', 'environments', 'epist', 'equal', 'equation', 'equations', 'euler', 'every', 'examine', 'example', 'examples', 'excluded', 'existence', 'expected', 'explains', 'express', 'expressed', 'expression', 'expressly', 'external', 'extract', 'fast', 'features', 'fiction', 'field', 'fields', 'filter', 'finance', 'find', 'finding', 'fit', 'fixed', 'flat', 'flow', 'flower', 'fluids', 'focus', 'focuses', 'force', 'former', 'forms', 'formulas', 'formulation', 'found', 'frac', 'framework', 'fulfilling', 'function', 'functions', 'fundamental', 'furthermore', 'gain', 'gaining', 'gdp', 'general', 'generalizations', 'generally', 'geometry', 'give', 'gives', 'go', 'goods', 'government', 'graduate', 'graduates', 'graduating', 'graphs', 'grasp', 'gravity', 'greek', 'green', 'growth', 'guide', 'heaven', 'hewitt', 'high', 'historically', 'hold', 'hope', 'however', 'huge', 'ideas', 'image', 'images', 'implies', 'imprecise', 'incapable', 'include', 'including', 'individual', 'industry', 'inertia', 'infinite', 'infinitesimal', 'infinitesimals', 'inflection', 'information', 'insists', 'instance', 'instantaneous', 'institutions', 'instrument', 'int', 'integral', 'integrals', 'intellectual', 'interest', 'international', 'interval', 'investigate', 'investigated', 'irregularly', 'isaac', 'iteration', 'jerzy', 'journalist', 'kasandbox', 'kastatic', 'key', 'know', 'knowing', 'knowledge', 'known', 'language', 'largely', 'law', 'laws', 'lawvere', 'layout', 'learn', 'lecturer', 'led', 'leibniz', 'liberal', 'like', 'likely', 'limit', 'line', 'linear', 'lists', 'lit', 'literary', 'literature', 'loading', 'logarithmic', 'looks', 'low', 'lyrics', 'made', 'major', 'majors', 'make', 'makes', 'man', 'many', 'marginal', 'marketing', 'mass', 'mathematical', 'mathematically', 'mathematics', 'matter', 'matters', 'maxima', 'maximal', 'maximize', 'maxwell', 'meaning', 'means', 'meanwhile', 'mechanics', 'medicine', 'mediums', 'memorial', 'merit', 'message', 'method', 'methods', 'middle', 'minima', 'model', 'modeled', 'models', 'moment', 'momentum', 'motion', 'move', 'much', 'multitude', 'national', 'nature', 'nautilus', 'new', 'newton', 'nobel', 'non', 'nonfiction', 'notes', 'notions', 'novelists', 'novels', 'nuclear', 'number', 'numerous', 'object', 'objects', 'obvious', 'often', 'old', 'one', 'online', 'open', 'operations', 'opportunities', 'optimal', 'optimistic', 'options', 'order', 'org', 'organizations', 'originally', 'others', 'outline', 'outstanding', 'part', 'particular', 'path', 'paths', 'performing', 'perhaps', 'periods', 'persisted', 'ph', 'phenomena', 'physical', 'physics', 'physik', 'piece', 'plane', 'planimeter', 'plays', 'please', 'pleasure', 'poetry', 'poets', 'point', 'points', 'pool', 'popular', 'population', 'position', 'positions', 'possible', 'post', 'practice', 'pre', 'presentation', 'pretty', 'private', 'prize', 'prizes', 'probability', 'problem', 'processes', 'production', 'professional', 'proficient', 'profit', 'programs', 'proliferation', 'prominent', 'proofreader', 'proofs', 'properties', 'property', 'prose', 'prospective', 'prototype', 'provide', 'provides', 'providing', 'publishing', 'purposes', 'pursuit', 'quantities', 'quantum', 'radiation', 'radioactive', 'random', 'rapidly', 'rate', 'rates', 'rather', 'reaction', 'read', 'reading', 'real', 'realization', 'realm', 'recession', 'rectangular', 'red', 'references', 'refers', 'reformulation', 'reformulations', 'region', 'rejects', 'relate', 'related', 'relationship', 'relativity', 'replaced', 'reproduction', 'researcher', 'resources', 'resultant', 'results', 'revenue', 'rich', 'right', 'rigorous', 'robinson', 'romanized', 'root', 'route', 'saying', 'school', 'science', 'sciences', 'screenplays', 'screenwriters', 'second', 'sector', 'see', 'seeing', 'sequences', 'series', 'services', 'set', 'several', 'shape', 'shaped', 'shell', 'simple', 'sis', 'skills', 'slope', 'slopes', 'smooth', 'social', 'solely', 'solo', 'solution', 'solutions', 'solve', 'song', 'sources', 'spacecraft', 'spatial', 'spiral', 'standard', 'start', 'starting', 'starts', 'stated', 'statistics', 'stepping', 'still', 'stone', 'strong', 'student', 'students', 'study', 'studying', 'style', 'styles', 'stylistically', 'subject', 'succeeded', 'summed', 'sums', 'sure', 'surface', 'swimming', 'system', 'table', 'take', 'taken', 'targeted', 'teach', 'teacher', 'term', 'terms', 'text', 'texts', 'theorem', 'theorems', 'theory', 'therapies', 'though', 'time', 'times', 'title', 'today', 'topical', 'topics', 'total', 'traditional', 'trajectory', 'transferable', 'transport', 'treasury', 'trouble', 'trying', 'tumor', 'turbulent', 'two', 'types', 'ubiquitous', 'ultimately', 'unblocked', 'understanding', 'unexpected', 'universities', 'unknown', 'upon', 'us', 'usa', 'use', 'used', 'uses', 'using', 'utilize', 'valid', 'values', 'variable', 'variation', 'varieties', 'various', 'velocity', 'versa', 'versus', 'vessel', 'vice', 'viewpoint', 'views', 'want', 'way', 'ways', 'web', 'website', 'well', 'wherever', 'whether', 'whichever', 'whose', 'widely', 'willing', 'within', 'without', 'work', 'world', 'write', 'writer', 'writers', 'writing', 'written', 'year', 'years', 'zero']\n"
144161
]
145162
}
146163
],
@@ -153,7 +170,9 @@
153170
" docs.append(i[key])\n",
154171
"\n",
155172
"tfidf_results = tfidf_counter.fit_transform(docs).toarray()\n",
156-
"print(tfidf_results)"
173+
"print(tfidf_results)\n",
174+
"\n",
175+
"print(tfidf_counter.get_feature_names())"
157176
]
158177
},
159178
{

0 commit comments

Comments
 (0)
Please sign in to comment.