Skip to content

Instantly share code, notes, and snippets.

View DJSagarAhire's full-sized avatar

Sagar Ahire DJSagarAhire

  • Google
  • Bangalore, India
View GitHub Profile
@DJSagarAhire
DJSagarAhire / SWNReader.py
Last active February 5, 2017 12:44
A short utility to read SentiWordNet made in Python.
import sys
def split_line(line):
cols = line.split("\t")
return cols
def get_words(cols):
words_ids = cols[4].split(" ")
words = [w.split("#")[0] for w in words_ids]
return words
@DJSagarAhire
DJSagarAhire / Test.ipynb
Created February 6, 2014 09:56
IPython notebook test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DJSagarAhire
DJSagarAhire / SubstringSum
Created August 1, 2014 07:25
Solution to the 'substring sum' problem (see file for a description).
/**
Solution to the 'Substring Sum' problem:
Accept a string consisting of digits and return the number of possible groupings of digits such that
sum of digits of each grouping at the left is less than or equal to sum of digits of every grouping on the right (i.e. they are in ascending order).
For example:
String = "1337"
Groupings: "1,337"; "1,3,37"; "1,3,3,7"; "1,33,7"; "13,37"; "13,3,7"; "133,7"
@author Sagar Ahire
*/
public class SubstringSum
@DJSagarAhire
DJSagarAhire / dir_creator.py
Last active October 25, 2016 14:33
Quick script to create a list of directories named after dates
def create_directories(basepath, start_date, end_date, date_format='%Y%m%d'):
""" Creates all subdirectories under the specified path named after the specified dates, one for each date.
start_date and end_date are both datetime.date objects.
date_format is a format string for the date which will be used to name the directories.
Example:
create_directories('/home/myhome', date(2016, 01, 01), date(2016, 01, 03)) will create directories named 20160101, 20160102 and 20160103 within /home/myhome.
Directory structure is created recursively if it doesn't exist.
"""