This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = "a9993e364706816aba3e25717850c26c9cd0d89d" | |
b = "cb4cc28df0fdbe0ecf9d9662e294b118092a5735" | |
a = list(a) | |
b = list(b) | |
percent = 0 | |
for counter, value in enumerate(a): | |
if value == b[counter]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prettify(document){ | |
// Turns an array of words into lowercase and removes stopwords | |
const stopwords = ["a", "share", "linkthese", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any","", "are","aren't","as","at","be","because","been","before","being","below","between","both","but","by","can't","cannot","could","couldn't","did","didn't","do","does","doesn't","doing","don't","down","during","each","few","for","from","further","had","hadn't","has","hasn't","have","haven't","having","he","he'd","he'll","he's","her","here","here's","hers","herself","him","himself","his","how","how's","i","i'd","i'll","i'm","i've","if","in","into","is","isn't","it","it's","its","itself","let's","me","more","most","mustn't","my","myself","no","nor","not","of","off","on","once","only","or","other","ought","our","ours","ourselves","out","over","own","same","shan't","she","she'd","she'll","she's","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","them |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prettify(document){ | |
// Turns an array of words into lowercase and removes stopwords | |
const stopwords = stopwords_array | |
// turn document into lowercase words, remove all stopwords | |
var document = document.replace(/[.,]/g, ''); | |
let document_in_lowercase = document.split(" ").map(function(x){ return x.toLowerCase() }); | |
return document_in_lowercase.filter( x => !stopwords.includes(x) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For item in dictionary: | |
if multiSet(WORD) == multiSet(item): | |
print("elvis is an anagram of " + item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dictionary = ["dogs", "lives", "live", "train"] | |
WORD = "elvis" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = pd.read_csv("creditcardcsvpresent.csv | |
data.describe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inverseDocumentFrequency(document){ | |
// calculates the inverse document frequency of every sentence | |
const words_without_stopwords = prettify(document); | |
const unique_words_set = uniqueWords(words_without_stopwords); | |
const sentences = document.split(".").map(item => item.trim()); | |
sentences[0] = sentences[0].substring(146); | |
const lengthOfDocuments = sentences.length; | |
// prettifys each sentence so it doesn't have stopwords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "TL;DR - Summary of BBC news articles", | |
"version": "1.0", | |
"description": "This extension creates a summary of BBC news articles using TF*IDF", | |
"icons": { | |
"48": "icons/border-48.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "TL;DR - Summary of BBC news articles", | |
"version": "1.0", | |
"description": "This extension creates a summary of BBC news articles using TF*IDF", | |
"content_scripts": [ | |
{ | |
"matches": ["*://www.bbc.co.uk/news/*"], | |
"js": ["jquery.js", "tldr.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get all text from .story-body within p tags on a BBC news web article | |
let $article = $('.story-body').find('p').text(); | |
// insert text into body of document | |
let insert = $('.story-body').prepend(TFIDF($article)); |