Skip to content

Instantly share code, notes, and snippets.

View nnkennard's full-sized avatar

Neha Kennard nnkennard

View GitHub Profile
@nnkennard
nnkennard / ArrayBasedSorting.java
Created April 22, 2026 00:33
CICS 160 - Reference implementations of sorting algorithms in Java and Python
import java.util.Arrays;
public class ArrayBasedSorting {
static void selectionSort(int[] arr) {
/*
* The index i is the position whose correct value we are seeking.
* i.e. when i=3, we are searching for the value that should end up in
* arr[3].
* At this time, we would already have placed the correct items
@nnkennard
nnkennard / easy_graphics.py
Last active November 1, 2025 15:26
Examples for some easy graphics for COMSC-334.
import termcolor
from termcolor import colored, cprint
# == Connect 4 ================================================================
# This is just a quick mockup of what a Connect Four game state could look
# like. You probably want something more elaborate like what we saw in the
# Pacman project.
connect_4_board = [
@nnkennard
nnkennard / rename_photos.py
Last active May 9, 2024 16:45
Rename photos to date taken (when available)
"""Script to rename photos with their creation time.
I whipped this up quickly to consolidate some photos as my Dropbox filled
up and my computer was dying. It probably has enough code in here to be the
starting point of a more robust script.
If you are very serious about this you should probably use Automator on Mac
or something like A Better Finder Rename 12. I personally did not want to
spend any money on this, and Automator didn't do exactly the thing I wanted.
@nnkennard
nnkennard / triads.py
Last active April 26, 2023 01:50
Triads code for refactoring
'''For the pairs of contiguous articles in singleissue_contiguous_dyads.csv,
find the articles they mutually cite and get all the author/title info we can'''
import pymssql
import sys
import csv, pickle
from collections import defaultdict
import re, Levenshtein
import scipy as sp
"""Neha's 32nd birthday Wordle!
There may still be some bugs! It's ok we had fun. (Andrew also worked on this)
"""
import random
import datetime
from termcolor import colored
import xml.etree.ElementTree as ET
import xmltodict
root = ET.parse('../pubmed23n0001.xml').getroot()
for article_obj in root.findall("PubmedArticle")[:10]:
data_dict = xmltodict.parse(ET.tostring(article_obj))
print(data_dict)
@nnkennard
nnkennard / retrieve_openreview_decisions.py
Last active December 9, 2022 18:20
Retrieving OpenReview decisions
import collections
import glob
import json
import openreview
guest_client = openreview.Client(baseurl='https://api.openreview.net')
review_to_forum_map = {}
@nnkennard
nnkennard / read_disapere.py
Created September 19, 2022 23:56
Read DISAPERE labels into a tsv file
import argparse
import csv
import glob
import json
parser = argparse.ArgumentParser(description="")
parser.add_argument("-d", "--disapere_dir", default="", type=str, help="")
parser.add_argument("-l", "--label", default="", type=str, help="")
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('-o', '--output_dir', default='', type=str, help='')
parser.add_argument('--mode', choices=('train', 'eval'), help='')
parser.add_argument('-d', '--debug', action='store_true', help='')
parser.add_argument('-s', '--year_start', default=2008, type=int, help='')
@nnkennard
nnkennard / preco_converter.py
Last active July 25, 2022 14:57
Code to convert PreCo data to CoNLL format
"""Convert PreCo-formatted jsonl files into CoNLL format.
Example usage:
python preco_converter.py -i PreCo_1.0/train.jsonl -o train.txt # Removes singletons
python preco_converter.py -i PreCo_1.0/train.jsonl -o train.txt -s # Keeps singletons
Input: [input_file_name].jsonl (PreCo format)
From https://preschool-lab.github.io/PreCo/, each line is a valid json object