Skip to content

Instantly share code, notes, and snippets.

View rbhttchr's full-sized avatar

Rini Bhattacharya Mehta rbhttchr

View GitHub Profile
@rbhttchr
rbhttchr / wikipedia_section_loop.py
Created January 29, 2021 01:26 — forked from alexanderholt/wikipedia_section_loop.py
For when pages have different names for the same type of section.
import wikipedia
import numpy as np
# you'll need to get the exact names of the titles of the pages beforehand
example_titles =
['Algol (film)','Dr. Jekyll and Mr. Hyde (1920 Haydon film)',
'Figures of the Night', 'The Invisible Ray (1920 serial)', 'The Man from Beyond',
'Black Oxen','Aelita','The Hands of Orlac (1924 film)']
# create a list of all the names you think/know the section might be called
@rbhttchr
rbhttchr / wikipedia_section.py
Created January 29, 2021 01:26 — forked from alexanderholt/wikipedia_section.py
Pull specific section of Wikipedia page using wikipedia python package
# get the section of a page. In this case the Plot description of Metropolis
section = wikipedia.WikipediaPage('Metropolis (1927 film)').section('Plot')
# that will return fairly clean text, but the next line of code
# will help clean that up.
section = section.replace('\n','').replace("\'","")
@rbhttchr
rbhttchr / wikipedia_summary.py
Created January 29, 2021 01:26 — forked from alexanderholt/wikipedia_summary.py
Get the Summary of a given Wikipedia Page
import wikipedia
print(wikipedia.WikipediaPage(title = 'Metropolis (1927 film)').summary)
@rbhttchr
rbhttchr / wikipedia_scrape_lists.py
Created January 29, 2021 01:24 — forked from alexanderholt/wikipedia_scrape_lists.py
Helpful for scraping list pages on Wikipedia that you can then use to feed into the API to query specific pages
import wikipedia
import requests
from bs4 import BeautifulSoup
import time
import numpy as np
# first pull the HTML from the page that links to all of the pages with the links.
# in this case, this page gives the links list pages of sci-fi films by decade.
# just go to https://en.wikipedia.org/wiki/Lists_of_science_fiction_films
# to see what I'm pulling from.
@rbhttchr
rbhttchr / wikitable.ipynb
Created January 17, 2021 22:12 — forked from nikhilkumarsingh/wikitable.ipynb
Reading Wikipedia Tables using Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rbhttchr
rbhttchr / sudoku.py
Created September 4, 2020 18:24 — forked from markusrenepae/sudoku.py
This is a sudoku-solving code snippet. Used for my Medium article.
import pyautogui as pag
import time
import copy
sudoku = [[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
@rbhttchr
rbhttchr / .block
Created July 17, 2020 12:50 — forked from d3noob/.block
Sankey Diagram with v5
license: mit
@rbhttchr
rbhttchr / .block
Created April 10, 2020 17:11
zoomable, draggable force layout with labels
license: mit
border: yes
@rbhttchr
rbhttchr / README.md
Created April 9, 2020 03:39 — forked from emeeks/README.md
An online tool for interactive teaching of network visualization and representation principles.

The range sliders at the top change the values for the force-directed algorithm and the buttons load new graphs and apply various techniques. This will hopefully serve as a tool for teaching network analysis and visualization principles during my Gephi courses and general Networks in the Humanities presentations.

Notice this includes a pretty straightforward way to load CSV node and edge lists as exported from Gephi.

It also includes a pathfinding algorithm built for the standard data structure of force-directed networks in D3. This requires the addition of .id attributes for the nodes, however.

Now with Clustering Coefficients!

Also, it loads images for nodes but the images are not in the gist. The code also refers to different network types but the data files on Gist only refer to the transportation network.

@rbhttchr
rbhttchr / stop_words.txt
Created March 1, 2020 01:50 — forked from DarrenN/stop_words.txt
Naively parse a text removing stopwords
'tis
'twas
a
aah
aaron
abandon
abandoned
abbott
abby
abe