Skip to content

Instantly share code, notes, and snippets.

View arademaker's full-sized avatar
🎯
Focusing

Alexandre Rademaker arademaker

🎯
Focusing
View GitHub Profile
@arademaker
arademaker / commands
Last active August 29, 2015 14:27
playing with stardog and wordnet
stardog-admin server start
stardog-admin db drop wn
stardog-admin db create -n wn wn30.ttl
stardog data add wn test.ttl
stardog-admin icv add -v wn wn30.ttl
stardog icv validate -v -r wn ; the r option is necessary
$ java -jar /usr/local/HermiT/HermiT.jar --classify test-complet.ttl
Exception in thread "main" org.semanticweb.owlapi.reasoner.InconsistentOntologyException: Inconsistent ontology
at org.semanticweb.HermiT.Reasoner.throwInconsistentOntologyExceptionIfNecessary(Unknown Source)
at org.semanticweb.HermiT.Reasoner.checkPreConditions(Unknown Source)
at org.semanticweb.HermiT.Reasoner.precomputeInferences(Unknown Source)
at org.semanticweb.HermiT.cli.CommandLine$ClassifyAction.run(Unknown Source)
at org.semanticweb.HermiT.cli.CommandLine.main(Unknown Source)
wordsensesense
crosswordsense-01913997-v-1wordsense-02023396-v-2
farsightednesswordsense-14555214-n-2wordsense-14554011-n-4
get_upwordsense-00018405-v-1wordsense-01974062-v-4
liftwordsense-01455184-v-2wordsense-01974062-v-2
raisewordsense-01975587-v-1wordsense-01974062-v-1
makewordsense-01646075-v-1wordsense-01645601-v-3
dowordsense-02561995-v-1wordsense-01645601-v-2
@arademaker
arademaker / simple-webserver.js
Created January 27, 2011 23:26
a simple webserver in node.js
var express = require('express'), app = express.createServer();
var fs = require('fs'), sys = require("sys");
var log = fs.createWriteStream('params.json', {'flags': 'a'});
app.use(express.logger());
app.get('/', function(req, res){
console.log(req.query);
log.write(JSON.stringify(req.query));
res.send('It\'s saved!');
@arademaker
arademaker / check-authors.R
Created March 1, 2011 02:19
Verificando autores com ordem de autoria repetida nos Lattes
library(XML)
check <- function(filename, dir = getwd()) {
doc <- xmlInternalTreeParse(paste(dir, filename, sep="/"))
tmp <- xpathSApply(doc,"//AUTORES", function(x)
c(xmlGetAttr(xmlParent(x), "SEQUENCIA-PRODUCAO"),
xmlGetAttr(x, "ORDEM-DE-AUTORIA")))
if(class(tmp) == "list" & length(tmp) == 0)
return(list(file = filename, resp = NA))
tmp <- t(tmp)
@arademaker
arademaker / truth-tables.R
Created March 3, 2011 02:15
constructing truth tables in R
library(gtools)
data <- permutations(2, 3, v = c(T,F), repeats.allowed=TRUE)
tt <- as.data.frame(data)
names(tt) <- letters[1:3]
tt$"! (a | b) | c" <- (!(tt$a | tt$b) | tt$c)
# unusual output!
xtable(tt)
@arademaker
arademaker / lista-2.py
Created April 1, 2011 00:17
Trabalho proposto para turma de LFA. Implementar fecho transitivo-reflexivo de uma relação representada como um grafo. Versão não otimizada, apenas uma possível solução.
import sys
# Leitura do arquivo de entrada no formato especificado. Linhas iniciadas com
# "#" sao comentarios. Nao era necessario os alunos implementarem isso.
grafoin = []
try:
infilename = sys.argv[1]
infile = open(infilename,'r')
for line in infile:
@arademaker
arademaker / fibonacci.py
Created April 6, 2011 01:06
Duas versões de Fibonacci apresentadas em sala (Mestrado EMAP/FGV). Exemplos do Livro Algorithms (http://books.google.com/books?id=3sCxQgAACAAJ).
def fib1(n):
if n == 0:
return 0
if n == 1:
return 1
else:
return fib1(n-1) + fib1(n-2)
def fib2(n):
@arademaker
arademaker / wordcloud-in-r.R
Created August 13, 2011 12:30
Wordcloud em R
library(RColorBrewer)
library(wordcloud)
pal2 <- brewer.pal(8,"Set2")
lines <- readLines("pg32519.txt")
lines <- lines[45:3192]
text <- paste(lines, collapse = " ")
words <- unlist(strsplit(tolower(text), "\\s+|,|\\(|\\)|:|\\.|!|\\?|;"))
@arademaker
arademaker / issn.lisp
Created September 14, 2011 00:07
Verifying ISSN's Check digit using Lisp
(defun check-issn (str)
" Parse a string of 8 digits in the format NNNN-NNNN representing an
ISSN number. The last N can be an X representing 10. "
(let ((digits (remove nil (loop for char across str
collect (cond ((equal char #\X) 10)
((equal char #\-) nil)
(t (parse-integer (string char))))))))
(if (not (equal (length digits) 8))
nil
(equal 0 (mod (loop for i from 8 downto 1