Skip to content

Instantly share code, notes, and snippets.

@edubey
edubey / Text-summarization.py
Created Dec 22, 2018
Text Summarizer in Python
View Text-summarization.py
#!/usr/bin/env python
# coding: utf-8
from nltk.corpus import stopwords
from nltk.cluster.util import cosine_distance
import numpy as np
import networkx as nx
def read_article(file_name):
file = open(file_name, "r")
@edubey
edubey / bag-of-word-vectors.py
Created Dec 2, 2018
Code to generate bag of word vectors in Python
View bag-of-word-vectors.py
# import statments
import numpy
import re
'''
Tokenize each the sentences, example
Input : "John likes to watch movies. Mary likes movies too"
Ouput : "John","likes","to","watch","movies","Mary","likes","movies","too"
'''
def tokenize(sentences):
@edubey
edubey / Multiple-story-medium.js
Created Nov 18, 2018
Scrap Multiple Story from a Publisher Page
View Multiple-story-medium.js
var i = 0,
maxCount = 5;
var storyInterval = setInterval(() => {
document.querySelectorAll(".js-trackedPost>a")[i].click()
setTimeout(() => {
console.log("Title : ", document.getElementsByClassName("graf--title")[i].innerText);
p = document.getElementsByClassName("ui-xs-clamp2")[0]
console.log("Profile Description : ", p ? p.innerText : "");
history.back()
}, 2000);
@edubey
edubey / Single Story.js
Created Nov 17, 2018
Save data from console for medium story
View Single Story.js
var storyPath = window.location.href;
// Console API to clear console before logging new data
console.API;
if (typeof console._commandLineAPI !== 'undefined') {
console.API = console._commandLineAPI; //chrome
} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
console.API = console._inspectorCommandLineAPI; //Safari
} else if (typeof console.clear !== 'undefined') {
@edubey
edubey / console-save.js
Created Nov 17, 2018
Save the data from browser console in a file
View console-save.js
console.save = function (data, filename) {
if (!data) {
console.error('Console.save: No data')
return;
}
if (!filename) filename = 'story.json'
if (typeof data === "object") {
data = JSON.stringify(data, undefined, 4)
@edubey
edubey / story-element.js
Created Nov 17, 2018
Extract Data from a medium story
View story-element.js
// Extracts high level details of current story
function getCurrentStoryDetail() {
console.API.clear();
storyObj = {};
storyObj.title = document.getElementsByClassName("graf--title")[0].innerText;
storyObj.count = document.getElementsByClassName("js-multirecommendCountButton")[0].innerText;
storyObj.name = document.getElementsByClassName("ds-link--styleSubtle")[0].innerText;
storyObj.imageUrl = document.getElementsByClassName("avatar-image")[0].src;
storyObj.profile = document.getElementsByClassName("ui-xs-clamp2")[0].innerText;