Skip to content

Instantly share code, notes, and snippets.

View kylebgorman's full-sized avatar

Kyle Gorman kylebgorman

View GitHub Profile
@kylebgorman
kylebgorman / triangle.py
Created December 21, 2013 01:39
Triangular (square) matrix class for Python, using only half as much memory. Supports decent portions of what you'd expect for a numpy object
#!/usr/bin/env python -O
#
# Copyright (c) 2013 Kyle Gorman
#
# 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
@kylebgorman
kylebgorman / treeify.py
Last active May 13, 2021 04:27
convert PTB-style parse tree (essentially, an sexps) to the format for LaTeX's `qtree`/`tikz-qtree` library
#!/usr/bin/env python
# treeify.py: convert PTB parse to LaTeX's `qtree`/`tikz-qtree` format
#
# NB: this only works for documents with a single tree, due to a limitation
# with `nltk.tree`.
import fileinput
from nltk import Tree
@kylebgorman
kylebgorman / mcnemar.py
Last active August 11, 2025 04:29
Compute McNemar's test (two two-sided variants) in Python
import scipy.stats
def mcnemar_p(n1: int, n2: int) -> float:
"""Computes McNemar's test.
Args:
n1: the number of "wins" for the first condition.
n2: the number of "wins" for the second condition.
@kylebgorman
kylebgorman / dense-search.py
Created October 11, 2015 03:19
dense crossword puzzle search
#!/usr/bin/env python
# Python 3.5 or greater, but probably backportable with minimal effort.
"""Creates dense crossword puzzle fills.
This module provides code to fill dense cross-word puzzles. It is a work
in progress.
We represent words in a puzzle as a square matrix of bytes.
@kylebgorman
kylebgorman / bktree.py
Created November 4, 2015 02:48
Burkhard-Keller trees
# Copyright (c) 2014-2015 Kyle Gorman <[email protected]>
#
# 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:
#
@kylebgorman
kylebgorman / wcm.py
Created November 4, 2015 02:49
Stole-Gammon word complexity measure (WCM)
#!/usr/bin/env python
#
# Copyright (c) 2014 Kyle Gorman
#
# 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
@kylebgorman
kylebgorman / ratio.pyx
Last active October 8, 2019 15:58
Log-likelihood ratio test in Cython, using scipy for distribution functions.
"""Functions for computing log-likelihood ratio statistics."""
from libc.math cimport log
from scipy.stats import binom
from scipy.stats import chi2
cpdef double LLR(int c_a, int c_b, int c_ab, int n):
@kylebgorman
kylebgorman / McFarlaneEtAl_MazeData-Deidentified.csv
Last active September 21, 2019 21:49
Deidentified maze data
Study.ID CA VIQ DX Activity Content Filler REP REV FS Cued Not.Cued
CSLU-001 5.6667 124 TD Conversation 24 31 2 5 17 36 50
CSLU-001 5.6667 124 TD Picture Description 1 2 0 0 1 2 3
CSLU-001 5.6667 124 TD Play 21 6 3 8 10 6 27
CSLU-001 5.6667 124 TD Wordless Picture Book 8 2 0 4 4 2 10
CSLU-002 6.5 124 TD Conversation 3 10 3 0 0 10 13
CSLU-002 6.5 124 TD Picture Description 5 3 2 1 2 3 8
CSLU-002 6.5 124 TD Play 8 8 3 2 3 9 15
CSLU-002 6.5 124 TD Wordless Picture Book 2 2 0 0 2 2 4
CSLU-007 7.5 108 TD Conversation 25 21 4 4 17 29 38
@kylebgorman
kylebgorman / Simple-linear-models-for-NLP.ipynb
Created July 19, 2017 20:43
Lecture on simple linear models for NLP applications, given to the Portland PUG sometime in late 2014 or early 2015
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebgorman
kylebgorman / WALS131A.R
Last active January 22, 2023 16:27
Tests the hypothesis that vigesimal (base-20) number systems are more common at tropical latitudes
#!/usr/bin/env Rscript
# WALS131A.R
# Kyle Gorman <[email protected]>
#
# Tests the hypothesis that vigesimal (base-20) number systems are more common
# at tropical latitudes. Thanks to Richard Sproat for suggesting this
# hypothesis.
#
# The data is read directly from WALS (#131A):
#