#A Collection of NLP notes
##N-grams
###Calculating unigram probabilities:
P( wi ) = count ( wi ) ) / count ( total number of words )
In english..
| /** | |
| * Prepare the App Folder | |
| */ | |
| (function(){ | |
| window.appRootDirName = ".myapp"; | |
| document.addEventListener("deviceready", onDeviceReady, false); | |
| function onDeviceReady() { | |
| console.log("device is ready"); | |
| window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; |
| # Convert any YouTube video into an audio file you can listen to on the go, using: | |
| # http://rg3.github.com/youtube-dl/ | |
| { ~ } > brew install ffmpeg | |
| { ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl | |
| { ~ } > chmod u+x youtube-dl | |
| # Pick which video format you want to download.. (use any YT video link) | |
| { ~ } > ./youtube-dl -s -F http://www.youtube.com/watch?v=vT1KmTQ-1Os |
| # Environment, set GEM_HOME & GEM_PATH. For example, we can launch JRuby like this: | |
| # GEM_HOME=/Users/amurray/tmp/gems/ GEM_PATH=/Users/amurray/tmp/gems java -jar ~/Downloads/jruby-complete-1.7.0.preview1.jar -S irb | |
| # ===================== | |
| # LISTING gems | |
| puts Gem::Specification.find_all.to_s | |
| puts Gem::Specification.find_all.map{|spec| "#{spec.name} (#{spec.version})" } | |
| # ===================== | |
| # USING (a specific version of) gems |
#A Collection of NLP notes
##N-grams
###Calculating unigram probabilities:
P( wi ) = count ( wi ) ) / count ( total number of words )
In english..
| #!/usr/bin/env ruby | |
| # | |
| # Ruby script to download a number of files | |
| # from individual URLs via HTTP/HTTPS/FTP | |
| # specified in an external file. | |
| # | |
| # Author: Tobias Preuss | |
| # Revision: 2013-04-18 16:26 +0100 UTC | |
| # License: Creative Commons Attribution-ShareAlike 3.0 Unported |
| # Basic Code | |
| class Image | |
| has_attached_file :attachment | |
| def attachment_url(url) | |
| require "open-uri" | |
| self.attachment = open(url) | |
| end | |
| end |
| def params | |
| [0,0] | |
| end | |
| def examples | |
| [ | |
| { | |
| :x => 1, | |
| :y => 3 | |
| }, |
| def wget(url,file) | |
| require 'net/http' | |
| require 'uri' | |
| if (!file) | |
| file = File.basename(url) | |
| end | |
| url = URI.parse(url) | |
| Net::HTTP.start(url.host) do |http| |
| // Modernizr style test | |
| if (!(window.webkitMatchMedia || window.mozMatchMedia || window.oMatchMedia || window.msMatchMedia || window.matchMedia)) { | |
| var root = document.getElementsByTagName( 'html' )[0]; | |
| root.className += ' no-matchmedia'; | |
| } | |
| /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */ | |
| window.matchMedia || (window.matchMedia = function() { | |
| "use strict"; |