Skip to content

Instantly share code, notes, and snippets.

Avatar

Allison Parrish aparrish

View GitHub Profile
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active May 8, 2021
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View understanding-word-vectors.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aparrish
aparrish / index.md
Last active Apr 16, 2021
Getting credentials for the Mastodon API with Mastodon.py. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View index.md

Getting credentials for the Mastodon API with Mastodon.py, step by step

Making a bot? Making a bot in Python? Making a bot in Python that uses the Mastodon API? If so, chances are you need to get some credentials. Here's how I did it!

(The following tutorial uses Python 2.7, but if you're using Python 3+ everything should work substantially the same.)

Mastodon.py authentication

I just started using it, but it looks like Mastodon.py is a pretty great library for working with the Mastodon API! However, all of the authentication examples use static files to store credentials, which I don't like—I'm afraid I'll accidentally push them to Github. I like to keep my authentication as close to the actual command that runs the program as possible, so usually I pass them on the command line to the script running my bot. To do this, I need to get the appropriate credentials on their own, as separate strings that I can cut and paste.

@aparrish
aparrish / index.md
Last active Apr 7, 2021
aparrish workshop for machine literacy at sfpc
View index.md

Introduction to Natural Language Processing and Word Vectors

Nothing is more essentially human than linguistic communication. But when programmers, data scientists, and computational linguists work with language, the abstractions they work with sometimes don't line up with your intuitive understanding of spelling and grammar. In this workshop, we'll investigate the state of the art of natural language processing, including: a whirlwind tour of spaCy for parsing English into syntactic constituents; a discussion of techniques for classifying and summarizing documents; and an explanation and demonstration of "word vectors" (like Google's word2vec), an innovative language technology that allows computers to process written language less as discrete units and more like a continuous signal. Workshop participants will develop a number of small projects in text analysis and poetics using a public domain text of their choice. In becoming familiar with contemporary techniques for computational language analysis, cri

@aparrish
aparrish / three_legged_oauth_helper.py
Created Jan 14, 2013
interactive python script to assist in getting access tokens for OAuth v1 APIs. requires python's OAuth2 library (pip install oauth2)
View three_legged_oauth_helper.py
# an interactive python script to assist in getting access tokens for OAuth v1
# APIs. requires python's OAuth2 library (pip install oauth2)
#
# run from the command line like so:
#
# $ python three_legged_oauth_helper.py --consumer_key=<ckey> \
# --consumer_secret=<csecret> \
# --request_token_url=<request_token_url> \
# --authorize_url=<authorize_url> \
# --access_token_url=<access_token_url>
@aparrish
aparrish / spacy_intro.ipynb
Last active Mar 26, 2021
NLP Concepts with spaCy. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View spacy_intro.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aparrish
aparrish / predictive-models.ipynb
Created Jul 9, 2018
Predictive text and text generation notebook. Written for Code Societies at SFPC, summer 2018. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View predictive-models.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aparrish
aparrish / trigrams-that-occur-only-twice.txt
Created Feb 19, 2021
trigrams that occur only twice in the cmu pronouncing dictionary word list, along with the words that contain them (where edit distance between words is greater than 3)
View trigrams-that-occur-only-twice.txt
'ex: l'expansion, l'express
'fa: o'fallon, o'farrell
'go: b'gosh, o'gorman
'la: o'lague, o'laughlin
'ri: b'rith, o'riley
-ac: non-academic, x-acto
-au: non-automotive, port-au-prince
-dr: alcohol-drenched, drip-dry
-ed: cutting-edge, well-educated
-em: non-emergency, pre-emptive
@aparrish
aparrish / semantic_similarity_chatbot.ipynb
Created Jul 17, 2018
Semantic similarity chatbot (with movie dialog). Gist mirror of Colab notebook here: https://colab.research.google.com/drive/1XlmtcyMdPRQC6bw2HQYb3UPtVGKqUJ0a Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View semantic_similarity_chatbot.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aparrish
aparrish / facebook_app_token.py
Last active Feb 6, 2021
simple python script to fetch an access token for a Facebook application (not a user token)
View facebook_app_token.py
# fetch an access token for a Facebook application
#
# run like so:
#
# $ python facebook_app_token.py --app_id=<your app id> --secret=<your secret>
#
# ... where <your app id> is your Facebook application ID, and <your secret>
# is the application secret for that application (both can be retrieved from
# the Facebook developer app)
@aparrish
aparrish / shmarkov.py
Last active Jan 22, 2021
shmarkov.py, a set of functions for simple and concise markov chain text generation in Python. should work in python 2 and python 3
View shmarkov.py
# shmarkov.py, simple and concise markov chain text generation
# Copyright (C) 2018 Allison Parrish
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the “Software”), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions: