Skip to content

Instantly share code, notes, and snippets.

View sloria's full-sized avatar

Steven Loria sloria

View GitHub Profile
@sloria
sloria / bacon
Last active December 19, 2015 19:09
title: Bacon Ipsum
date: 2013-07-14 12:00:00
Bacon ipsum dolor sit amet ball tip tongue pancetta jowl sirloin rump. Chuck tail pork cow, fatback jerky hamburger pancetta leberkas pig .
[Read more](http://baconipsum.com/)
{% extends "base.html" %}
{% block content %}
<h1>{{ page.meta.title }}</h1>
<p>{{ page.meta.date }}</p>
{{ page }}
{% endblock %}
$ python freeze.py
$ git init
$ git add . --all
$ git commit -am "Initial commit"
$ git checkout -b gh-pages
$ git remote add origin https://github.com/username/flask-ghpages-example.git
$ git push origin --all
#!/usr/bin/env python
from flask import Flask, jsonify, request, render_template, abort
from text.blob import TextBlob
from text.utils import strip_punc
app = Flask(__name__)
##### TextBlob API #####
@app.route("/api/sentiment", methods=['POST'])
def sentiment():
@sloria
sloria / classification.py
Created August 24, 2013 14:14
textblob classification example
from text.classifiers import NaiveBayesClassifier
train = [
('I love this sandwich.', 'pos'),
('This is an amazing place!', 'pos'),
('I feel very good about these beers.', 'pos'),
('This is my best work.', 'pos'),
("What an awesome view", 'pos'),
('I do not like this restaurant', 'neg'),
('I am tired of this stuff.', 'neg'),
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import string
from text.blob import Blobber
from text.taggers import PerceptronTagger, PatternTagger, NLTKTagger
def accuracy(test_set, tagger):
n_correct = 0
total = 0
tb = Blobber(pos_tagger=tagger)
{
// Color
"color_scheme": "Packages/Theme - Nil/Big Duo.tmTheme",
"theme": "Nil.sublime-theme",
// Font
"font_face": "Ubuntu Mono",
"font_options": ["subpixel_antialias"],
"font_size": 15.0,
// Caret
"caret_style": "phase",
{
"auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
"auto_complete_triggers":
[
{
"characters": "$",
"selector": "source.coffee, source.js, source.js.embedded.html"
}
],
"bold_folder_labels": true,
from textblob.classifiers import NaiveBayesClassifier
train = [
('amor', "spanish"),
("perro", "spanish"),
("playa", "spanish"),
("sal", "spanish"),
("oceano", "spanish"),
("love", "english"),
("dog", "english"),
# Even better
def lazy_property(fn):
'''Decorator that makes a property lazy-evaluated.
'''
attr_name = '_lazy_' + fn.__name__
@property
def _lazy_property(self):
if not hasattr(self, attr_name):