Skip to content

Instantly share code, notes, and snippets.

# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@Khalefa
Khalefa / textrank.py
Created November 1, 2015 17:26 — forked from igor-shevchenko/textrank.py
TextRank algorithm for text summarization.
from itertools import combinations
from nltk.tokenize import sent_tokenize, RegexpTokenizer
from nltk.stem.snowball import RussianStemmer
import networkx as nx
def similarity(s1, s2):
if not len(s1) or not len(s2):
return 0.0
return len(s1.intersection(s2))/(1.0 * (len(s1) + len(s2)))
@Khalefa
Khalefa / pagerank
Last active May 5, 2016 21:51 — forked from ekoontz/pagerank
Run Giraph Pagerank
#!/bin/sh
set -x
JAR=`find $HOME/giraph/target -name "giraph*with-dependencies.jar" -maxdepth 1 -mindepth 1`
bin/killmr_apps.sh
sleep 2
HADOOP_RUNTIME=/Users/ekoontz/hadoop-runtime
echo
@Khalefa
Khalefa / psql-srv.py
Last active July 21, 2022 17:28 — forked from matteobertozzi/psql-srv.py
python 3 (should works)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---
@Khalefa
Khalefa / visualization.ipynb
Created May 1, 2018 23:03 — forked from oinume/visualization.ipynb
Visualization MySQL data in Jupyter Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Khalefa
Khalefa / Haversin.py
Created May 28, 2018 05:20 — forked from gopass2002/Haversin.py
Haversine
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371 # km
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1)
a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \
@Khalefa
Khalefa / Haversin.py
Created May 28, 2018 05:20 — forked from gopass2002/Haversin.py
Haversine
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371 # km
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1)
a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \