Skip to content

Instantly share code, notes, and snippets.

View tomericco's full-sized avatar

Tomer Gabbai tomericco

View GitHub Profile
@tomericco
tomericco / cosine_similarity.js
Created January 26, 2019 10:58
Cosine similarity implementation in JS
const str1 = 'This is an example to test cosine similarity between two strings';
const str2 = 'This example is testing cosine similatiry for given two strings';
//
// Preprocess strings and combine words to a unique collection
//
const str1Words = str1.trim().split(' ').map(omitPunctuations).map(toLowercase);
const str2Words = str2.trim().split(' ').map(omitPunctuations).map(toLowercase);
const allWordsUnique = Array.from(new Set(str1Words.concat(str2Words)));
function increaseCounter() {
var account = web3.eth.accounts[0];
var currentNumber = contract_instance.getMyNumber().toNumber();
currentNumber++;
// User dialog goes here
web3.personal.unlockAccount(account, 'secretpasswrod');
contract_instance.setMyNumber(currentNumber, {from: account, gas: 200000}, function(error, result) {
if (error) {