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
# -*- coding: utf-8 -*- | |
""" | |
replacer.py: | |
2013-04-29 | |
(c) 2013 Richard Careaga, all rights reserved. | |
Subject to license terms and conditions at | |
http://richard-careaga.com/lic2013.txt | |
install this script to your pythonista.app top-level directory |
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
# KJVurl.py | |
# convert a list of verse citations, one to a line in the form 'Judges 2:2' into markdown formatted links to the corresponding verse in an online service | |
# this example depends on a correspondence of the url to the verse by simple substitution of a hyphen for each blank or colon | |
# for iOS7 pythonista, due to reliance on clipboard module | |
import re | |
import clipboard | |
# site whose citation scheme will be usef | |
baseref = "http://www.kingjamesbibleonline.org/" |
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
#!/usr/bin/python | |
""" | |
Author: Richard Careaga | |
Date: 2014-07-10 | |
Title: NOAAscrape.py | |
Description: Download temperature time series data and save to CSV file | |
Example results (date, temperature, difference from 1901-2000 mean for month): | |
"1895-01-15",26.69,-3.43 | |
"1896-01-15",31.48,1.36 |
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
from collections import defaultdict | |
def str_md(lexicon,key, value): | |
"""Generic append key, value to lexicon""" | |
lexicon.setdefault(key,value) | |
# Desired sort order | |
complist = ['Red', 'Apple', 'Green', 'Tea', 'Purple', 'Haze'] | |
# Dictionary order | |
alphalist = sorted(complist) | |
# Create empty dictionary |
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
x <- c("dplyr", "ggmap", "ggplot2", "RColorBrewer", "rgdal", "classInt", "RCurl", "grid","gridExtra") | |
lapply(x, library, character.only = TRUE) | |
no_ylab = ylab("") | |
no_xlab = xlab("") | |
plain_theme = theme(axis.text=element_blank()) + theme(panel.background = element_blank(), panel.grid = element_blank(), axis.ticks = element_blank()) | |
remove.farflung = function(.df) { | |
subset(.df, |
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
Alabama | 01 | AL | |
---|---|---|---|
Alaska | 02 | AK | |
Arizona | 04 | AZ | |
Arkansas | 05 | AR | |
California | 06 | CA | |
Colorado | 08 | CO | |
Connecticut | 09 | CT | |
Delaware | 10 | DE | |
District of Columbia | 11 | DC | |
Florida | 12 | FL |
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
intervals = function(.df, ...){ | |
argList = match.call(expand.dots=FALSE)$... | |
for(i in 1:length(argList)){ | |
colName <- argList[[i]] | |
series_colName = eval(substitute(colName), envir=.df, enclos=parent.frame()) | |
min <- min(series_colName) | |
max <- max(series_colName) | |
diff <- max - min | |
std <- sd(series_colName) | |
equal.interval <- seq(min, max, by = diff/6) |
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
x = c("ggplot2", "classInt", "dplyr", "rgdal", "maptools", "mapproj", "rgeos", "RCurl") | |
lapply(x, library, character.only = TRUE) | |
intervals = function(.df, ...){ | |
argList = match.call(expand.dots=FALSE)$... | |
for(i in 1:length(argList)){ | |
colName <- argList[[i]] | |
series_colName = eval(substitute(colName), envir=.df, enclos=parent.frame()) | |
min <- min(series_colName) | |
max <- max(series_colName) | |
diff <- max - min |
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
> ls(pattern = 'all') | |
[1] "allid" "allpct" "allpop" | |
> objs <- ls(pattern = 'all') | |
> str(objs) | |
chr [1:3] "allid" "allpct" "allpop" | |
> class(objs) | |
[1] "character" | |
> mode(objs) | |
[1] "character" | |
> typeof(objs) |
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
import nltk | |
from nltk.chunk import * | |
from nltk.chunk.util import * | |
from nltk.chunk.regexp import * | |
from nltk import Tree | |
cp = nltk.RegexpParser('CHUNK: {<NN> <VB> <IN> <NN>}') | |
bucket = [] | |
brown = nltk.corpus.brown | |
for sent in brown.tagged_sents(): |
OlderNewer