#A Collection of NLP notes
##N-grams
###Calculating unigram probabilities:
P( wi ) = count ( wi ) ) / count ( total number of words )
In english..
| ''' | |
| Created on 2012. 2. 19. | |
| This module is for playing mp3 (limited) and wav formatted audio file | |
| @author: John | |
| ''' | |
| import pygame | |
| def playsound(soundfile): | |
| """Play sound through default mixer channel in blocking manner. | |
| This will load the whole sound into memory before playback |
#A Collection of NLP notes
##N-grams
###Calculating unigram probabilities:
P( wi ) = count ( wi ) ) / count ( total number of words )
In english..
| # (C) Kyle Kastner, June 2014 | |
| # License: BSD 3 clause | |
| import scipy.stats as st | |
| import numpy as np | |
| class gmmhmm: | |
| #This class converted with modifications from https://code.google.com/p/hmm-speech-recognition/source/browse/Word.m | |
| def __init__(self, n_states): | |
| self.n_states = n_states |
| import pandas as pd | |
| import numpy as np | |
| import logging | |
| import time | |
| import datetime | |
| from sklearn.ensemble import RandomForestClassifier | |
| from sklearn import cross_validation | |
| from sklearn.svm import SVC | |
| from sklearn.metrics import accuracy_score | |
| from sklearn.feature_selection import VarianceThreshold |
| from keras import applications | |
| from keras.preprocessing.image import ImageDataGenerator | |
| from keras import optimizers | |
| from keras.models import Sequential, Model | |
| from keras.layers import Dropout, Flatten, Dense, GlobalAveragePooling2D | |
| from keras import backend as k | |
| from keras.callbacks import ModelCheckpoint, LearningRateScheduler, TensorBoard, EarlyStopping | |
| img_width, img_height = 256, 256 |
| from keras.layers.core import Layer | |
| import keras.backend as K | |
| if K.backend() == 'tensorflow': | |
| import tensorflow as tf | |
| def K_arange(start, stop=None, step=1, dtype='int32'): | |
| result = tf.range(start, limit=stop, delta=step, name='arange') | |
| if dtype != 'int32': | |
| result = K.cast(result, dtype) | |
| return result |
| import hashlib as hasher | |
| import datetime as date | |
| # Define what a Snakecoin block is | |
| class Block: | |
| def __init__(self, index, timestamp, data, previous_hash): | |
| self.index = index | |
| self.timestamp = timestamp | |
| self.data = data | |
| self.previous_hash = previous_hash |
| from flask import Flask | |
| from flask import request | |
| import json | |
| import requests | |
| import hashlib as hasher | |
| import datetime as date | |
| node = Flask(__name__) | |
| # Define what a Snakecoin block is | |
| class Block: |