A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| { | |
| // 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", |
| #!/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) |
| import math | |
| from text.blob import TextBlob as tb | |
| def tf(word, blob): | |
| return blob.words.count(word) / len(blob.words) | |
| def n_containing(word, bloblist): | |
| return sum(1 for blob in bloblist if word in blob) | |
| def idf(word, bloblist): |
| from textblob.classifiers import NaiveBayesClassifier | |
| train = [ | |
| ('amor', "spanish"), | |
| ("perro", "spanish"), | |
| ("playa", "spanish"), | |
| ("sal", "spanish"), | |
| ("oceano", "spanish"), | |
| ("love", "english"), | |
| ("dog", "english"), |
| import random | |
| from nltk.corpus import movie_reviews | |
| from textblob.classifiers import NaiveBayesClassifier | |
| random.seed(1) | |
| 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'), |
| from textblob.classifiers import NaiveBayesClassifier | |
| from textblob import TextBlob | |
| 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'), |
| 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'), |
Works well with sloria's cookiecutter-pypackage template.
my_project/__init__.pygit checkout dev
python setup.py test
tox