Skip to content

Instantly share code, notes, and snippets.

@bllchmbrs
bllchmbrs / tfpdf.py
Last active December 29, 2021 14:10
TF IDF Explained in Python Along with Scikit-Learn Implementation
from __future__ import division
import string
import math
tokenize = lambda doc: doc.lower().split(" ")
document_0 = "China has a strong economy that is growing at a rapid pace. However politically it differs greatly from the US Economy."
document_1 = "At last, China seems serious about confronting an endemic problem: domestic violence and corruption."
document_2 = "Japan's prime minister, Shinzo Abe, is working towards healing the economic turmoil in his own country for his view on the future of his people."
document_3 = "Vladimir Putin is working hard to fix the economy in Russia as the Ruble has tumbled."
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@Diftraku
Diftraku / gist:5888214
Created June 28, 2013 21:18
A "simple" PHP function to convert arrays into DataTable JSON export format fit to use with Google Charts
<?php
/**
* arrayToDataTable()
* Converts PHP arrays to nested arrays fit for json_encode()
*
* Format Notice:
* - $cols contains all the columns for the DataTable, each column having a type and a label.
* Columns can be defined as plain arrays (containing only type and label, see below) or as a named array,
* with each of the properties defined as key => value pairs. All columns must have at least a 'type'.
*