Created
December 4, 2020 02:02
-
-
Save sufianj/f8d68c4f132e6a45751ea75cabb97d08 to your computer and use it in GitHub Desktop.
knowledge-graph-programming-example.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "knowledge-graph-programming-example.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"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.7" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/sufianj/f8d68c4f132e6a45751ea75cabb97d08/knowledge-graph-programming-example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "-_MNFKNYyrDH" | |
}, | |
"source": [ | |
"# **Scientific Birthdays Example**\n", | |
"\n", | |
"This is copied from the python notebook example for lecture 5.4 Knowledge Graph Programming, of the OpenHPI lecture \"Knowledge Graphs 2020\".\n", | |
"\n", | |
"*Please make a copy of this notebook to try out your own adaptions via \"File -> Save Copy in Drive\"*" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "SHxdpQlK7pcg" | |
}, | |
"source": [ | |
"First, we have to install the **sparqlwrapper library** before we can use it with the notebook." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "SDrJejgTvAE9" | |
}, | |
"source": [ | |
"!pip install -q sparqlwrapper #install SPARQLwrapper" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "ZRzOrb06zKfH" | |
}, | |
"source": [ | |
"We are going to use a few libraries:\n", | |
"\n", | |
"\n", | |
"\n", | |
"* **datetime** for date formatting and interpretation\n", | |
"* **SPARQLWrapper** to execute SPARQL queries and to import the results into python\n", | |
"\n", | |
"Thus, we will import them now.\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "SJXrilamub6T" | |
}, | |
"source": [ | |
"from datetime import datetime\n", | |
"from SPARQLWrapper import SPARQLWrapper, JSON, XML, N3, RDF" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "8zIgKA2pznsI" | |
}, | |
"source": [ | |
"We will use DBpedia (http://dbpedia.org/sparql) as our SPARQL endpoint" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "ASV8cGgcvuR-" | |
}, | |
"source": [ | |
"sparql = SPARQLWrapper(\"http://dbpedia.org/sparql\") #determine SPARQL endpoint" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "0fmehvshztYt" | |
}, | |
"source": [ | |
"Next comes the query example from the lecture and its execution" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "uRSTc_aqv7vG" | |
}, | |
"source": [ | |
"#SPARQL query to be executed\n", | |
"sparql.setQuery(\"\"\"\n", | |
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n", | |
"PREFIX dbo: <http://dbpedia.org/ontology/>\n", | |
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n", | |
"PREFIX dc: <http://purl.org/dc/elements/1.1/>\n", | |
"\n", | |
"Select distinct ?birthdate ?thumbnail ?scientist ?name ?description WHERE {\n", | |
"?scientist rdf:type dbo:Scientist ;\n", | |
" dbo:birthDate ?birthdate ;\n", | |
" rdfs:label ?name ;\n", | |
" rdfs:comment ?description \n", | |
" FILTER ((lang(?name)=\"en\")&&(lang(?description)=\"en\")&&(STRLEN(STR(?birthdate))>6)&&(SUBSTR(STR(?birthdate),6)=SUBSTR(STR(bif:curdate('')),6))) .\n", | |
" OPTIONAL { ?scientist dbo:thumbnail ?thumbnail . }\n", | |
"} ORDER BY ?birthdate\n", | |
"\"\"\")\n", | |
"\n", | |
"sparql.setReturnFormat(JSON) # Return format is JSON\n", | |
"results = sparql.query().convert() # execute SPARQL query and write result to \"results\"" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "CrscD2mAz5Md" | |
}, | |
"source": [ | |
"The results are now formatted in HTML encoding to be displayed nicely in a browser" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "_xp1YyQ2wU50", | |
"outputId": "1bbc98b3-6a13-4c09-efcc-1443b6899327" | |
}, | |
"source": [ | |
"# Create HTML output\n", | |
"print('<html><head><title>Scientific Birthdays of Today</title></head>')\n", | |
"\n", | |
"#extract Weekday %A / Month %B / Day of the Month %d by formatting today's date accordingly\n", | |
"date = datetime.today().strftime(\"%A %B %d\")\n", | |
"print('<body><h1>Scientific Birthdays of {}</h1>'.format(date))\n", | |
"\n", | |
"print('<ul>')\n", | |
"\n", | |
"for result in results[\"results\"][\"bindings\"]:\n", | |
"\tif (\"scientist\" in result):\n", | |
"\t #Create a Wikipedia Link\n", | |
" \t\twikiurl = \"http://en.wikipedia.org/wiki/\" + result[\"scientist\"][\"value\"].split('/')[-1]\n", | |
"\telse:\n", | |
"\t\twikiurl = 'NONE' \n", | |
"\tif (\"name\" in result):\n", | |
" \t\tname = result[\"name\"][\"value\"]\n", | |
"\telse:\n", | |
"\t\tname = 'NONE' \t\t\n", | |
"\tif (\"birthdate\" in result):\n", | |
"\t\tbirthdate = result[\"birthdate\"][\"value\"]\n", | |
"\telse:\n", | |
"\t\tbirthdate = 'NONE' \n", | |
"\tif (\"description\" in result):\n", | |
"\t\tdescription = result[\"description\"][\"value\"]\n", | |
"\telse:\n", | |
"\t\tdescription = ' ' \n", | |
"\tif (\"thumbnail\" in result):\n", | |
"\t\tpic = result[\"thumbnail\"][\"value\"]\n", | |
"\telse:\n", | |
"\t\tpic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png' \t\n", | |
"\n", | |
"\n", | |
"\t#parse date as datetime\n", | |
"\tdt = datetime.strptime(birthdate, '%Y-%m-%d')\n", | |
" \n", | |
"#\tprint '<li><b>{}</b> -- <a href=\"{}\">{}</a>, {} </li>'.format(dt.year, url, name, description)\n", | |
"\tprint('<li><b>{}</b> -- <img src=\"{}\" height=\"60px\"> <a href=\"{}\">{}</a>, {} </li>'.format(dt.year, pic.replace(\"300\", \"60\"), wikiurl, name, description))\n", | |
"\n", | |
"print('</ul>')\n", | |
"print('</body></html>')" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"<html><head><title>Scientific Birthdays of Today</title></head>\n", | |
"<body><h1>Scientific Birthdays of Friday December 04</h1>\n", | |
"<ul>\n", | |
"<li><b>1810</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Thomas_Minott_Peters.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Thomas_Minott_Peters\">Thomas Minott Peters</a>, Thomas Minott Peters (December 4, 1810 – June 14, 1888) was an American lawyer and botanist who studied the flora of the Southern United States. Peters was born December 4, 1810 in Clarksville, Tennessee. His family moved to Leighton, now in Colbert County, Alabama in 1819. He briefly attended LaGrange College (located on the top of the LaGrange Mountain in Leighton, Alabama, which is now a famous historical site) and graduated from the University of Alabama with a bachelor’s degree in 1834 and a master’s degree in 1836; being admitted to practice law that same year. He served in the Alabama House of Representatives (1845–1846) and the Alabama Senate (1847–1848). He was elected to represent Lawrence County, Alabama as by that time he had moved to Moulton, Alabama. Even though he owned slav </li>\n", | |
"<li><b>1816</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Benjamin_SillimanJr2.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Benjamin_Silliman_Jr.\">Benjamin Silliman Jr.</a>, Benjamin Silliman Jr. (December 4, 1816 – January 14, 1885) was a professor of chemistry at Yale University and instrumental in developing the oil industry. His father Benjamin Silliman Sr., also a famous Yale chemist, developed the process of fractional distillation that enabled the economical production of kerosene. In 1855, Silliman Jr. wrote a report for $526.08 on Pennsylvania rock oil and its usefulness as an illuminant that convinced investors to back George Bissell's search for oil. </li>\n", | |
"<li><b>1834</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Carl_Georg_Lange_by_Peter_Most.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Carl_Lange_(physician)\">Carl Lange (physician)</a>, Carl Georg Lange (4 December 1834 – 29 May 1900) was a Danish physician who made contributions to the fields of neurology, psychiatry, and psychology. Born to a wealthy family in Vordingborg, Denmark, Lange attended medical school at the University of Copenhagen and graduated in 1859 with a reputation for brilliance. After publishing on the neurological pathologies of aphasia, bulbar palsy, tabes dorsalis, and pathologies of the spinal cord, he achieved world fame with his 1885 work \"On Emotions: A Psycho-Physiological Study\". In it, he posited that all emotions are developed from, and can be reduced to, physiological reactions to stimuli. Seemingly independently, the American William James had published a similar work the year before, but unlike James, Lange specifically stated that vasom </li>\n", | |
"<li><b>1859</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Yoichiro_Hirase_1859-1925.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Yoichirō_Hirase\">Yoichirō Hirase</a>, Yoichirō Hirase (平瀬 與一郎 Hirase Yoichirō, December 4, 1859 – May 25, 1925) was a Japanese malacologist. His son, Shintarō Hirase, (1884-1939) was also a malacologist. The majority of his collection of molluscs were destroyed during World War II. </li>\n", | |
"<li><b>1867</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Charles_Herty.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Charles_Herty\">Charles Herty</a>, Charles Holmes Herty, Sr. (December 4, 1867 – July 27, 1938) was an American academic, scientist, and businessman. Serving in academia as a chemistry professor to begin his career, Herty concurrently promoted collegiate athletics including creating the first varsity football team at the University of Georgia. His academic research gravitated towards applied chemistry where he revolutionized the turpentine industry in the United States. While serving as the president of the American Chemical Society, Herty became a national advocate for the nascent American chemical industry and left academia to preside over the Synthetic Organic Chemical Manufacturers' Association (SOCMA) and the Chemical Foundation. He was also instrumental in the creation of the National Institutes of Health. Towards the </li>\n", | |
"<li><b>1882</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Estrella_Eleanor_Carothers.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Eleanor_Carothers\">Eleanor Carothers</a>, Estella Eleanor Carothers (4 December 1882 – 1957), known primarily as Eleanor Carothers, was an American zoologist, geneticist, and cytologist known for her work with grasshoppers. She discovered important physical evidence for the concept of independent assortment, vital to modern understanding of genetics. </li>\n", | |
"<li><b>1885</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/CSIRO_ScienceImage_2015_George_Julius_David_Rivett_and_Arnold_Richardson.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/David_Rivett\">David Rivett</a>, Sir Albert Cherbury David Rivett, KCMG (4 December 1885 – 1 April 1961) was an Australian chemist and science administrator. </li>\n", | |
"<li><b>1886</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Bieberbach,Ludwig_1930_Jena.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Ludwig_Bieberbach\">Ludwig Bieberbach</a>, Ludwig Georg Elias Moses Bieberbach (German: [ˈbiːbɐˌbaχ]; 4 December 1886 – 1 September 1982) was a German mathematician. </li>\n", | |
"<li><b>1888</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/R._C._Majumdar\">R. C. Majumdar</a>, Ramesh Chandra Majumdar (4 December 1888 – 11 February 1980) was a respected historian and professor of Indian history. </li>\n", | |
"<li><b>1891</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Stuart_W._Frost.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Stuart_W._Frost\">Stuart W. Frost</a>, Stuart W. Frost (1891 - 1980) was a professor of entomology at The Pennsylvania State University, University Park, Pennsylvania. He was born in Tarrytown, New York, and graduated from Cornell University. He was a specialist in leaf-mining flies (Diptera). The Frost Entomological Museum at Penn State was named in his honor. </li>\n", | |
"<li><b>1897</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Myron_Mathisson\">Myron Mathisson</a>, Myron Mathisson (December 4, 1897 – September 13, 1940) was a theoretical physicist of Polish and Jewish descent. He is known for his work in general relativity, for developing a new method to analyze the properties of fundamental solutions of linear hyperbolic partial differential equations, and proved, in a special case, the Hadamard conjecture on the class of equations that satisfy the Huygens principle. </li>\n", | |
"<li><b>1897</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Robert_Redfield\">Robert Redfield</a>, Robert Redfield (December 4, 1897 – October 16, 1958) was an American anthropologist and ethnolinguist. Redfield graduated from the University of Chicago with Communication Studies, eventually with a J.D. from its law school and then a Ph.D. in cultural anthropology, which he began to teach in 1927. After a series of published field studies from Mexican communities (Tepoztlán in Morelos and Chan Kom in Yucatán), in 1953 he published The Primitive World and its Transformation and in 1956, Peasant Society and Culture. Moving further into a broader synthesis of disciplines, Dr Redfield embraced a forum for interdisciplinary thought that included archeology, anthropological linguistics, physical anthropology, cultural anthropology, and ethnology. </li>\n", | |
"<li><b>1898</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Kariamanickam_Srinivasa_Krishnan\">Kariamanickam Srinivasa Krishnan</a>, Sir Kariamanickam Srinivasa Krishnan, FRS, (4 December 1898 – 14 June 1961) was an Indian physicist. He was a co-discoverer of Raman scattering, for which his mentor C. V. Raman was awarded the 1930 Nobel Prize in Physics. </li>\n", | |
"<li><b>1899</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Ethel_Currie\">Ethel Currie</a>, Dr Ethel Dobbie Currie FRSE FGS FGSG (1899-1963) was a distinguished Scottish geologist. </li>\n", | |
"<li><b>1908</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Alfred_Hershey.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Alfred_Hershey\">Alfred Hershey</a>, Alfred Day Hershey (December 4, 1908 – May 22, 1997) was an American Nobel Prize–winning bacteriologist and geneticist. He was born in Owosso, Michigan and received his B.S. in chemistry at Michigan State University in 1930 and his Ph.D. in bacteriology in 1934, taking a position shortly thereafter at the Department of Bacteriology at Washington University in St. Louis. </li>\n", | |
"<li><b>1909</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Herbert_Wechsler\">Herbert Wechsler</a>, Herbert Wechsler (December 4, 1909 – April 26, 2000) was a legal scholar and former director of the American Law Institute (ALI). He is most widely known for his constitutional law scholarship and for the creation of the Model Penal Code. The Journal of Legal Studies has identified Wechsler as one of the most cited legal scholars of the 20th century. </li>\n", | |
"<li><b>1913</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Zenith_Space_Commander_600.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Robert_Adler\">Robert Adler</a>, Robert Adler (December 4, 1913 – February 15, 2007) was an Austrian-born American inventor who held numerous patents.He worked for Zenith retiring as the company's Vice President and Director of Research. His work included developing early sound based remote controls for televisions, which were the standard for 25 years until replaced by IR remotes that could transmit more complex commands. </li>\n", | |
"<li><b>1914</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Charlotte_C._Campbell\">Charlotte C. Campbell</a>, Charlotte Catherine Campbell (December 4, 1914 – October 8, 1993) was an American medical mycologist. </li>\n", | |
"<li><b>1918</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Dr._Leland_C._Clark_Jr_2005.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Leland_Clark\">Leland Clark</a>, Leland C. Clark Jr. (December 4, 1918 – September 25, 2005) was an American biochemist born in Rochester, New York. He is most well known as the inventor of the Clark electrode, a device used for measuring oxygen in blood, water and other liquids. Clark is considered the \"father of biosensors\", and the modern-day glucose sensor used daily by millions of diabetics is based on his research. He conducted pioneering research on heart-lung machines in the 1940s and '50s and was holder of more than 25 patents. Although he developed a fluorocarbon-based liquid that could be breathed successfully by mice in place of air, his lifelong goal of developing artificial blood remained unfulfilled at the time of his death. He is the inventor of Oxycyte, a third-generation perfluorocarbon (PFC) therapeutic </li>\n", | |
"<li><b>1922</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/A._V._Balakrishnan\">A. V. Balakrishnan</a>, Alampallam Venkatachalaiyer Balakrishnan was an American applied mathematician and professor at the University of California, Los Angeles. He was a recipient of the Richard E. Bellman Control Heritage Award which is the highest recognition of professional achievement for US control systems engineers and scientists in 2001 for \"pioneering contributions to stochastic and distributed systems theory, optimization, control, and aerospace flight systems research\". </li>\n", | |
"<li><b>1924</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Frank_Press_Jerusalem1953.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Frank_Press\">Frank Press</a>, Frank Press (born December 4, 1924) is an American geophysicist. An advisor to four U.S. Presidents, he later served two consecutive terms as President of the U.S. National Academy of Sciences (1981-1993). He is the author of 160 scientific papers and co-author of the textbooks Earth and Understanding Earth. </li>\n", | |
"<li><b>1925</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Joseph_R._Applegate\">Joseph R. Applegate</a>, Joseph Roye Applegate (December 4, 1925 – October 18, 2003) was the first black faculty member at the Massachusetts Institute of Technology. He was a linguistics expert who started working at MIT in 1955 and worked on machine translation. In the 1960s he started working at Howard University and became a professor emeritus of African Studies and it was there that he started the nation’s first Ph.D. program in African Studies. </li>\n", | |
"<li><b>1925</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Albert_Bandura_Psychologist.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Albert_Bandura\">Albert Bandura</a>, Albert Bandura OC (/bænˈdʊərə/; born December 4, 1925) is a psychologist who is the David Starr Jordan Professor Emeritus of Social Science in Psychology at Stanford University. For almost six decades, he has been responsible for contributions to the field of education and to many fields of psychology, including social cognitive theory, therapy, and personality psychology, and was also influential in the transition between behaviorism and cognitive psychology. He is known as the originator of social learning theory and the theoretical construct of self-efficacy, and is also responsible for the influential 1961 Bobo doll experiment. </li>\n", | |
"<li><b>1928</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Masao_Ito\">Masao Ito</a>, Masao Ito (伊藤 正男 Itō Masao, born December 4, 1928) is a Japanese neuroscientist, and director of the Riken Brain Science Institute. He won the 2006 Gruber Prize in Neuroscience and the 1996 Japan Prize. He was elected a Foreign Member of the Royal Society in 1992. </li>\n", | |
"<li><b>1930</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Ted_Stevens_at_International_Arctic_Research_Center.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Syun-Ichi_Akasofu\">Syun-Ichi Akasofu</a>, Syun-Ichi Akasofu (赤祖父 俊一 Akasofu Shun'ichi, born December 4, 1930, Saku, Nagano, Japan) is the founding director of the International Arctic Research Center of the University of Alaska Fairbanks (UAF), serving in that position from the center's establishment in 1998 until January 2007. Previously he had been director of the university's Geophysical Institute from 1986. </li>\n", | |
"<li><b>1935</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Anders_Thor\">Anders Thor</a>, Anders Johan Thor (1935–2012) was a Swedish scientist and teacher most notable for hisleadership in international standardization of quantities and units. He is one of the creators of binary prefixes and the IUPAC Green Book. Thor obtained a Master’s of Science degree in electrical engineering in 1959 and the licentiate in mechanics and mathematics in 1964, both at the Royal Institute of Technology (KTH) in Stockholm. From 1962-65 Thor was lecturer in mechanics at KTH and became a professor in 1965. </li>\n", | |
"<li><b>1938</b> -- <img src=\"http://en.wikipedia.org/wiki/Special:FilePath/Durie-Mason-2010-04.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Mason_Durie_(psychiatrist)\">Mason Durie (psychiatrist)</a>, Sir Mason Harold Durie KNZM (born 4 December 1938) is a New Zealand professor of Māori Studies and research academic at Massey University. He is known for his contributions to Māori health. </li>\n", | |
"<li><b>1940</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/JoAnn_Hardin_Morgan.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/JoAnn_H._Morgan\">JoAnn H. Morgan</a>, JoAnn Hardin Morgan (December 4, 1940) is an American aerospace engineer who was a trailblazer in the United States space flight program as the first female engineer at the National Aeronautics and Space Administration (NASA) John F. Kennedy Space Center and the first woman to serve as a senior executive at Kennedy Space Center. For her work at NASA, Morgan was honored by U.S. President Bill Clinton as a Meritorious Executive in 1995 and 1998. Prior to her retirement in 2003, she held various leadership positions over 40 years in the manned space flight programs at NASA. Morgan served as the director of the External Relations and Business Development during her final years at the space center. </li>\n", | |
"<li><b>1941</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/György_Berencsi_on_a_conference_arranged_for_his_70th_birthday.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/György_Berencsi\">György Berencsi</a>, György Berencsi 3rd (4 December 1941 – 25 April 2013) was a Hungarian virologist. He was the Head of the Department of Virology at the \"Béla Johan\" National Centre for Epidemiology and professor at the Semmelweis University in Budapest. </li>\n", | |
"<li><b>1943</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Elizabeth_M_Whelan_clip_2.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Elizabeth_Whelan\">Elizabeth Whelan</a>, Elizabeth M. Whelan (/ˈhwiːlən/; December 4, 1943 – September 11, 2014) was an American epidemiologist best known for challenging government regulations of the consumer products, food, and pharmaceuticals industries that arose from what she said was faulty science. In 1978, she founded the American Council on Science and Health (ACSH) to provide a formal foundation for her work. She also wrote, or co-wrote, more than 20 books and over 300 articles in scientific journals and lay publications. </li>\n", | |
"<li><b>1943</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Nanny_Wermuth\">Nanny Wermuth</a>, Nanny Wermuth (born 4 December 1943) is the Professor emerita of Statistics, Chalmers University of Technology/University of Gothenburg. Her research interests are Multivariate statistical models and their properties, especially graphical Markov models, as well as their applications in the life sciences and in the natural sciences. </li>\n", | |
"<li><b>1945</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Michael_Gerzon\">Michael Gerzon</a>, Michael Anthony Gerzon (4 December 1945 – 6 May 1996) is probably best known for his work on Ambisonics and for his work on digital audio. He also made a large number of recordings, many in the field of free improvisation in which he had a particular interest. </li>\n", | |
"<li><b>1946</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Tessaleno_Devezas\">Tessaleno Devezas</a>, Tessaleno Campos Devezas (born 4 December 1946, Rio de Janeiro) is a physicist, systems theorist, and materials scientist known by his contributions to the long waves theory in socioeconomic development, technological evolution, as well as world system analysis. </li>\n", | |
"<li><b>1949</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Paula_England\">Paula England</a>, Paula S. England (born 4 December 1949), is an American sociologist and Professor at New York University. Her research has focused on gender inequality in the labor market, the family, and sexuality. She has also studied class differences in contraception and nonmarital births. </li>\n", | |
"<li><b>1950</b> -- <img src=\"http://en.wikipedia.org/wiki/Special:FilePath/Dr_Prabhat_C_Chandra.jpeg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Prabhat_C._Chandra\">Prabhat C. Chandra</a>, Prabhat C Chandra (born 4 December 1950) is an Indian geophysicist. Since 1973, he has done extensive work in the field of hydrogeophysics, which encompasses groundwater exploration, development and management with specialization in groundwater geophysics using various geophysical methods. </li>\n", | |
"<li><b>1952</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Dennis_A._Dougherty\">Dennis A. Dougherty</a>, Dennis A. Dougherty (born December 4, 1952 in Harrisburg, Pennsylvania) is the George Grant Hoag Professor of Chemistry at California Institute of Technology. His research applies physical organic chemistry to systems of biological importance. Dougherty utilizes a variety of approaches to further our understanding of the human brain, including the in vivo nonsense suppression methodology for incorporating unnatural amino acids into a variety of ion channels for structure-function studies. </li>\n", | |
"<li><b>1952</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Mark_A._McDaniel\">Mark A. McDaniel</a>, Mark A. McDaniel (born 1952) is an American psychology researcher in the area of human learning and memory. He is one of the most influential researchers in prospective memory, but also well known for other basic research in memory and learning, cognitive aging, as well as applying cognitive psychology to education. McDaniel has published over 100 peer-reviewed articles, book chapters, and edited books. His research in memory and cognition has received over two million dollars in grant support from NIH and NASA. </li>\n", | |
"<li><b>1952</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Mike_Hudak\">Mike Hudak</a>, Michael John Hudak is an environmental researcher and author, Sierra Club activist, radio broadcaster, and public speaker concerned with the environmental damage (and harm to free-living animals, or wildlife) that ranching inflicts on US public land (mostly in the Western states). He is an author of Western Turf Wars: The Politics of Public Lands Ranching (which focuses on grazing issues) and its companion series of web-based videos. In 1999, he founded the nonprofit Public Lands Without Livestock. </li>\n", | |
"<li><b>1956</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/Claire_Wallace.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Claire_Wallace\">Claire Wallace</a>, Claire Wallace is Professor of Sociology at the University of Aberdeen and was President of the European Sociological Association between 2007 and 2009 where she helped to organise the Annual Conference in Lisbon in 2009 and in Glasgow in 2007. She has also been editor in chief of the international journal European Societies between 2001 and 2006. Claire Wallace has published more than 100 peer-reviewed publications. </li>\n", | |
"<li><b>1973</b> -- <img src=\"http://commons.wikimedia.org/wiki/Special:FilePath/RobertHeathJr.jpg?width=60\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Robert_W._Heath_Jr.\">Robert W. Heath Jr.</a>, Robert W. Heath Jr. is an American electrical engineer, researcher, educator, leading wireless technology expert, and a Cullen Trust Endowed Professor in the Department of Electrical and Computer Engineering at The University of Texas at Austin. He is also the president and CEO of MIMO Wireless Inc. He is the former Director of the Wireless Networking and Communications Group. </li>\n", | |
"<li><b>1976</b> -- <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png\" height=\"60px\"> <a href=\"http://en.wikipedia.org/wiki/Adlène_Hicheur\">Adlène Hicheur</a>, Adlène Hicheur (born 4 December 1976) is a particle physicist with dual Algerian and French citizenship. After his master of theoretical physics in Lyon, he joined LAPP (Laboratoire d'Annecy le Vieux de Physique des Particules) to work on the BaBar experiment, located at the Stanford Linear Accelerator Center. His thesis, defended in 2003, was about the production of high energy Eta prime mesons in the decays of B mesons. After that he was a Postdoctorate in England at the Rutherford Appleton Laboratory, where he worked on the ATLAS experiment at LHC. He then joined the high energy physics department of École Polytechnique Fédérale de Lausanne (EPFL) and works currently on the LHCb experiment. </li>\n", | |
"</ul>\n", | |
"</body></html>\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "0SXWT2eP-Yaf" | |
}, | |
"source": [ | |
"Now, do exactly the same, but write output into a file on your local computer (to be displayed in your browser)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "Kvv0vRcn0jHV" | |
}, | |
"source": [ | |
"#uncomment this if you use colab\n", | |
"#from google.colab import files\n", | |
"\n", | |
"with open('birthday.html', 'w') as f:\n", | |
"\t# Create HTML output\n", | |
"\tf.write('<html><head><title>Scientific Birthdays of Today</title></head>')\n", | |
"\n", | |
"\t#extract Weekday %A / Month %B / Day of the Month %d by formatting today's date accordingly\n", | |
"\tdate = datetime.today().strftime(\"%A %B %d\")\n", | |
"\tf.write('<body><h1>Scientific Birthdays of {}</h1>'.format(date))\n", | |
"\n", | |
"\tf.write('<ul>')\n", | |
"\n", | |
"\tfor result in results[\"results\"][\"bindings\"]:\n", | |
"\t\tif (\"scientist\" in result):\n", | |
"\t\t\t#Create a Wikipedia Link\n", | |
"\t\t\twikiurl = \"http://en.wikipedia.org/wiki/\" + result[\"scientist\"][\"value\"].split('/')[-1]\n", | |
"\t\telse:\n", | |
"\t\t\twikiurl = 'NONE' \n", | |
"\t\tif (\"name\" in result):\n", | |
"\t\t\tname = result[\"name\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tname = 'NONE' \t\t\n", | |
"\t\tif (\"birthdate\" in result):\n", | |
"\t\t\tbirthdate = result[\"birthdate\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tbirthdate = 'NONE' \n", | |
"\t\tif (\"description\" in result):\n", | |
"\t\t\tdescription = result[\"description\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tdescription = ' ' \n", | |
"\t\tif (\"thumbnail\" in result):\n", | |
"\t\t\tpic = result[\"thumbnail\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tpic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png' \t\n", | |
"\n", | |
"\t\t#parse date as datetime\n", | |
"\t\tdt = datetime.strptime(birthdate, '%Y-%m-%d')\n", | |
" \n", | |
"\t\tf.write('<li><b>{}</b> <ul><li><img src=\"{}\" height=\"60px\"> <a href=\"{}\">{}</a>, {} </li></ul></li>'.format(dt.year, pic.replace(\"300\", \"60\"), wikiurl, name, description))\n", | |
"\tf.write('</ul>')\n", | |
"\tf.write('</body></html>')\n", | |
" \n", | |
"#uncomment this if you use colab\n", | |
"# files.download('birthday.html')" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "b2NmCIJYb4b2" | |
}, | |
"source": [ | |
"Probably, it looks abit nicer in a table..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "G1vp6PaVJC6G" | |
}, | |
"source": [ | |
"#uncomment this if you use colab\n", | |
"#from google.colab import files\n", | |
"\n", | |
"with open('birthday.html', 'w') as f:\n", | |
"\t# Create HTML output\n", | |
"\tf.write('<html><head><title>Scientific Birthdays of Today</title></head>')\n", | |
"\n", | |
"\t#extract Weekday %A / Month %B / Day of the Month %d by formatting today's date accordingly\n", | |
"\tdate = datetime.today().strftime(\"%A %B %d\")\n", | |
"\t# f.write('<body><h1>Scientific Birthdays of {}</h1>'.format(date))\n", | |
"\n", | |
"\tf.write('<table style=\"width:75%\">')\n", | |
"\n", | |
"\tfor result in results[\"results\"][\"bindings\"]:\n", | |
"\t\tif (\"scientist\" in result):\n", | |
"\t\t\t#Create a Wikipedia Link\n", | |
"\t\t\twikiurl = \"http://en.wikipedia.org/wiki/\" + result[\"scientist\"][\"value\"].split('/')[-1]\n", | |
"\t\telse:\n", | |
"\t\t\twikiurl = 'NONE' \n", | |
"\t\tif (\"name\" in result):\n", | |
"\t\t\tname = result[\"name\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tname = 'NONE' \t\t\n", | |
"\t\tif (\"birthdate\" in result):\n", | |
"\t\t\tbirthdate = result[\"birthdate\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tbirthdate = 'NONE' \n", | |
"\t\tif (\"description\" in result):\n", | |
"\t\t\tdescription = result[\"description\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tdescription = ' ' \n", | |
"\t\tif (\"thumbnail\" in result):\n", | |
"\t\t\tpic = result[\"thumbnail\"][\"value\"]\n", | |
"\t\telse:\n", | |
"\t\t\tpic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Question_mark2.svg/71px-Question_mark2.svg.png' \n", | |
"\n", | |
"\t\t#parse date as datetime\n", | |
"\t\tdt = datetime.strptime(birthdate, '%Y-%m-%d')\n", | |
" \n", | |
"\t\tf.write('<tr><td><b>{}</b></td> <td style=\"text-center: justify;\"><img src=\"{}\" height=\"60px\"></td><td style=\"text-align: justify;\"><a href=\"{}\">{}</a>, {} </td></tr>'.format(dt.year, pic.replace(\"300\", \"60\"), wikiurl, name, description))\n", | |
"\tf.write('</table>')\n", | |
"\tf.write('</body></html>')\n", | |
" \n", | |
"#uncomment this if you use colab\n", | |
"#files.download('birthday.html')" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "dgvXet3ie-0i" | |
}, | |
"source": [ | |
"" | |
], | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment