Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import elasticsearch | |
from math import log | |
def tfidf_matrix(es, index, doc_type, fields, size=10, bulk=500, query=dict(match_all=[])): | |
"""Generate tfidf for `size` documents of `index`/`doc_type`. | |
All `fields` need to have the mapping "term_vector": "yes". | |
This is the consuming version (i.e. get everything at once). | |
:param es: elasticsearch client |
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
require 'tire' | |
# Tire.configure { logger STDERR, level: 'debug' } | |
Tire.index('movie-titles') do | |
delete | |
create \ | |
settings: { | |
index: { | |
analysis: { |
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
{ | |
"text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...", | |
"truncated": true, | |
"in_reply_to_user_id": null, | |
"in_reply_to_status_id": null, | |
"favorited": false, | |
"source": "<a href=\"http://twitter.com/\" rel=\"nofollow\">Twitter for iPhone</a>", | |
"in_reply_to_screen_name": null, | |
"in_reply_to_status_id_str": null, | |
"id_str": "54691802283900928", |