Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View khozzy's full-sized avatar

Norbert khozzy

View GitHub Profile
stopped = [t for t in wordnet_lemmas if t not in stop]
untokenize(stopped)
from nltk.corpus import stopwords
stop = stopwords.words('english')
from nltk.stem.wordnet import WordNetLemmatizer
wordnet = WordNetLemmatizer()
wordnet_lemmas = [wordnet.lemmatize(token) for token in tokens]
untokenize(wordnet_lemmas)
from nltk.stem.lancaster import LancasterStemmer
lancaster = LancasterStemmer()
lancaster_stemmed = [lancaster.stem(token) for token in tokens]
untokenize(lancaster_stemmed)
from nltk.stem.porter import PorterStemmer
porter = PorterStemmer()
porter_stemmed = [porter.stem(token) for token in tokens]
untokenize(porter_stemmed)
from nltk.stem.snowball import SnowballStemmer
snowball = nltk.SnowballStemmer("english")
snowball_stemmed = [snowball.stem(token) for token in tokens]
untokenize(snowball_stemmed)
from nltk.tokenize import RegexpTokenizer
snippet = snippet.lower()
tokens = RegexpTokenizer(r'\w+').tokenize(snippet)
untokenize(tokens)
snippet = """
When the Apple Watch first came out last year, Engadget published not one but two reviews. There was the \"official\" review, which provided an overview of the device's features and, more important, attempted to explain who, if anyone, should buy it. Then there was a piece I wrote, focusing specifically on the watch's capabilities (actually, drawbacks) as a running watch. Although we knew that many readers would be interested in that aspect of the device, we were wary of derailing the review by geeking out about marathoning.
This year, we needn't worry about that. With the new Apple Watch Series 2, the company is explicitly positioning the device as a sports watch. In particular, the second generation brings a built-in GPS radio for more accurate distance tracking on runs, walks, hikes, bike rides and swims. Yes, swims: It's also waterproof this time, safe for submersion in up to 50 meters of water.
Beyond that, the other changes are performance-related, including a faster chip, longer batte
@khozzy
khozzy / nltk1.py
Last active November 2, 2017 14:15
import nltk, string
def untokenize(tokens):
return "".join([" "+i if not i.startswith("'") and i not in string.punctuation else i for i in tokens]).strip()
@khozzy
khozzy / Projects.vue
Created June 14, 2016 12:33
Vue.js auto transitions
<template>
<div class="container tiles" role="main">
<div class="row" v-for="projectGroup in chunkedProjects">
<div class="col-lg-4" v-for="project in projectGroup">
<div class="flip">
<div class="card" :class="{'flipped':project.flipped}">
<div class="face front">Front</div>
<div class="face back">Back</div>