This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(RCurl) | |
| library(XML) | |
| joinURL <- function(base, u){ | |
| sbase <- parseURI(base) | |
| su <- parseURI(u) | |
| if( su$scheme != "") | |
| return(u) | |
| su$scheme <- sbase$scheme |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A simple script to calculate the number of sentences per markdown | |
| # file in a given directory. | |
| # | |
| # Reference: | |
| # - http://nltk.googlecode.com/svn/trunk/doc/howto/portuguese_en.html | |
| # Author: Alexandre Rademaker | |
| import os | |
| import glob | |
| import re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import os | |
| import glob | |
| import re | |
| import codecs | |
| import nltk | |
| from random import * | |
| from nltk.probability import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun normalize-agents () | |
| (labels ((compare-agents (agent1 agent2) | |
| (let ((u1 (nth 0 agent1)) | |
| (u2 (nth 0 agent2))) | |
| (if (upi= u1 u2) | |
| (list u1 u2 0) | |
| (list u1 u2 | |
| (loop for i in (cdr agent1) | |
| for j in (cdr agent2) | |
| summing (numeric-upi-equal i j) into total |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ql:quickload :drakma) | |
| (ql:quickload :st-json) | |
| (defun show-google-hits (term key ck) | |
| (let* ((query (list (cons "key" key) | |
| (cons "cx" ck) | |
| (cons "q" term))) | |
| (stream (drakma:http-request "https://www.googleapis.com/customsearch/v1" | |
| :parameters query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (let ((data (make-array 20 :initial-element nil))) | |
| (values(read-sequence data (make-string-input-stream "testing things")) data)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Solucao baseada no pseudo-codigo apresentado em: | |
| # http://en.wikipedia.org/wiki/Stable_marriage_problem | |
| stable.match <- function(hprefs, mprefs, debug=FALSE){ | |
| proposed <- matrix(rep(FALSE,25), ncol = 5, dimnames = list(Homens = 1:5, Mulheres = 1:5)) | |
| alloc <- matrix(rep(FALSE,25), ncol = 5, dimnames = list(Homens = 1:5, Mulheres = 1:5)) | |
| # os nomes das linhas e colunas irao ser usados para indicar os | |
| # indices para selecao de elementos das matrizes proposed e alloc, | |
| # por isso precisam ser renomeados. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun fib1 (n) | |
| (cond | |
| ((equal n 0) 0) | |
| ((equal n 1) 1) | |
| (t (+ (fib1 (- n 1)) | |
| (fib1 (- n 2)))))) | |
| (defun fib2 (n) | |
| (labels ((calc-fib (n a b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; first version: procedural | |
| (defun nth-1 (n alist) | |
| (let ((current alist)) | |
| (dotimes (v n current) | |
| (if (equal v n) | |
| (car current) | |
| (setf current (cdr current)))))) | |
| ; second version: functional |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/opt/local/bin/python3.2 | |
| # -*- encoding: utf-8 -*- | |
| import sys | |
| import json | |
| sys.path.append('.../myfreeling/APIs/python') | |
| import freeling | |
| import codecs | |
| import re |