Skip to content

Commit

Permalink
wednesday lecture
Browse files Browse the repository at this point in the history
  • Loading branch information
cab938 committed Sep 10, 2019
1 parent 6d27d71 commit 259838f
Show file tree
Hide file tree
Showing 3 changed files with 2,735 additions and 15 deletions.
113 changes: 98 additions & 15 deletions 190911_regular_expressions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
"slide_type": "fragment"
}
},
"outputs": [],
Expand All @@ -155,7 +155,7 @@
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
"slide_type": "fragment"
}
},
"source": [
Expand Down Expand Up @@ -305,11 +305,12 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"pattern='G..d'\n",
"re.search(pattern, 'Goodness!')"
]
},
Expand Down Expand Up @@ -373,11 +374,12 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"pattern=\"\\D\\d\\d\\d\\D\\s\\d\\d\\d-\\d\\d\\d\\d\"\n",
"# But we see it's not an ideal pattern...\n",
"re.search(pattern,\":306p 262-2905\")"
]
Expand All @@ -404,7 +406,7 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"outputs": [],
Expand Down Expand Up @@ -475,7 +477,7 @@
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"source": [
Expand Down Expand Up @@ -515,11 +517,12 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# what's going to happen!?\n",
"print(len('a'))\n",
"print(len('a\\b'))\n",
"print('a\\b')\n",
Expand Down Expand Up @@ -575,7 +578,7 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"outputs": [],
Expand Down Expand Up @@ -632,7 +635,7 @@
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"outputs": [],
Expand Down Expand Up @@ -716,7 +719,7 @@
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"source": [
Expand Down Expand Up @@ -788,7 +791,8 @@
},
"outputs": [],
"source": [
"# Insert fun 🇨🇦🏒 activity here."
"# Insert fun 🇨🇦🏒 activity here.\n",
"# save data as datasets/wiki.txt"
]
},
{
Expand Down Expand Up @@ -824,7 +828,7 @@
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"source": [
Expand Down Expand Up @@ -853,7 +857,7 @@
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "slide"
}
},
"source": [
Expand All @@ -867,9 +871,88 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": []
"source": [
"# read in the wiki text\n",
"with open(\"datasets/wiki.txt\",\"r\") as file:\n",
" wiki=file.read()\n",
"\n",
"# can you write a better regex to pull out titles from that datafile?\n",
"for item in re.finditer(\"???\",wiki):\n",
" print(item.groupdict())"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"* Last topic I'll touch on in capture groups: thus far the focus has been on returning and labeling the capture groups\n",
"* What if we want to match on the group, but don't want to see it come back?\n",
"* (like \\[edit\\])\n",
"* We can use non capturing groups\n",
" * `(?:...)` Match but don't return the group"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"* Here's an example from the New York Times which covers health tweets on news items"
]
},
{
"cell_type": "code",
"execution_count": 227,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# get a list of all of the hashtags that are included in this data\n",
"with open(\"datasets/nytimeshealth.txt\",\"r\") as file:\n",
" health=file.read()\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"* Lets see an example using data from wikipedia on US universities which are buddhist-based"
]
},
{
"cell_type": "code",
"execution_count": 228,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"# Get a list of dicts where each university 'name', 'city', and 'state' are labeled as such\n",
"with open(\"datasets/buddhist.txt\",\"r\") as file:\n",
" wiki=file.read()\n"
]
},
{
"cell_type": "markdown",
Expand Down
22 changes: 22 additions & 0 deletions datasets/buddhist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Buddhist universities and colleges in the United States
From Wikipedia, the free encyclopedia
Jump to navigationJump to search

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Buddhist universities and colleges in the United States" – news · newspapers · books · scholar · JSTOR (December 2009) (Learn how and when to remove this template message)
There are several Buddhist universities in the United States. Some of these have existed for decades and are accredited. Others are relatively new and are either in the process of being accredited or else have no formal accreditation. The list includes:

Dhammakaya Open University – located in Azusa, California, part of the Thai Wat Phra Dhammakaya[1]
Dharmakirti College – located in Tucson, Arizona Now called Awam Tibetan Buddhist Institute (http://awaminstitute.org/)
Dharma Realm Buddhist University – located in Ukiah, California
Ewam Buddhist Institute – located in Arlee, Montana
Naropa University is located in Boulder, Colorado (Accredited by the Higher Learning Commission)
Institute of Buddhist Studies – located in Berkeley, California
Maitripa College – located in Portland, Oregon
Soka University of America – located in Aliso Viejo, California
University of the West – located in Rosemead, California
Won Institute of Graduate Studies – located in Glenside, Pennsylvania
References[edit]
^ Banchanon, Phongphiphat (3 February 2015). รู้จัก "เครือข่ายธรรมกาย" [Getting to know the Dhammakaya network]. Forbes Thailand (in Thai). Retrieved 11 November 2016.
External links[edit]
List of Buddhist Universities and Colleges in the world
Loading

0 comments on commit 259838f

Please sign in to comment.