Skip to content

Instantly share code, notes, and snippets.

View moustaki's full-sized avatar

Yves Raimond moustaki

View GitHub Profile
@moustaki
moustaki / Faster save-load for word2vec
Created February 19, 2014 12:37
Faster save-load for word2vec
import dbm, os
import cPickle as pickle
from gensim.models import Word2Vec
import numpy as np
def save_model(model, directory):
model.init_sims() # making sure syn0norm is initialised
if not os.path.exists(directory):
os.makedirs(directory)
# Saving indexes as DBM'ed dictionary
<http://example.org/bob#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> <http://example.org/bob> .
<http://example.org/bob#me> <http://xmlns.com/foaf/0.1/knows> <http://example.org/alice#me> <http://example.org/bob> .
<http://example.org/bob#me> <http://schema.org/birthDate> "1990-07-04"^^<http://www.w3.org/2001/XMLSchema#date> <http://example.org/bob> .
<http://example.org/bob#me> <http://xmlns.com/foaf/0.1/topic_interest> <http://www.wikidata.org/entity/Q12418> <http://example.org/bob> .
<http://viaf.org/viaf/24604287/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> <https://www.wikidata.org/wiki/Special:EntityData/Q12418> .
<http://viaf.org/viaf/24604287/> <http://xmlns.com/foaf/0.1/name> "Leonardo da Vinci" <https://www.wikidata.org/wiki/Special:EntityData/Q12418> .
<http://viaf.org/viaf/24604287/> <http://xmlns.com/foaf/0.1/made> <http://www.wikidata.org/entity/Q12418> <https://www.wikidata.org/wiki/Special:EntityData/Q12418>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only the root user can own the Upstart name -->
<policy user="root">
<allow own="com.ubuntu.Upstart" />
</policy>
# Monkey-patching sparql-client to add count support
module SPARQL; class Client
class Query < RDF::Query
def self.count(*variables)
options = variables.last.is_a?(Hash) ? variables.pop : {}
unless variables.size == 1 and variables.first.is_a?(Symbol)
raise Exception.new "Only one symbol must be provided for count"
end
diff --git a/src/main.cxx b/src/main.cxx
index 8b2b389..062d0aa 100644
--- a/src/main.cxx
+++ b/src/main.cxx
@@ -230,11 +230,11 @@ int main(int argc, char** argv) {
int start_offset = 0;
int duration = 0;
int already = 0;
- if (argc > 2) start_offset = atoi(argv[2]);
- if (argc > 3) duration = atoi(argv[3]);
require 'helper'
class EasySparqlTest < Test::Unit::TestCase
class Programme
include EasySparql
attr_accessor :title
train(london, sheffield).
train(sheffield, london).
train(sheffield, manchester).
train(manchester, london).
train(manchester, durham).
route(A, B, Route) :-
route(A, B, Route, [A]).
route(A, B, [B], _) :-
@moustaki
moustaki / gist:1078262
Created July 12, 2011 15:54
Weirdness with EasyRdf
<?php
include_once('/usr/share/php/EasyRdf.php');
$graph = new EasyRdf_Graph();
$graph->add('http://example.com/2', 'rdf:p', 'label');
$graph->addResource('http://example.com/1', 'rdf:p', 'http://example.com/2');
$resources = $graph->resourcesMatching('rdf:p', 'label');
@moustaki
moustaki / gist:1012034
Created June 7, 2011 11:00
Handle IRIs with Zend_Uri
/**
* Converts to a Zend_Uri object
* @protected
* @static
* @param string $s
* @return Zend_Uri
*/
protected static function uri($s)
{
if (!empty($s)) {
@moustaki
moustaki / gist:725644
Created December 2, 2010 16:46
ARC2 RDFa bug
<?php
$data = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:mo="http://purl.org/ontology/mo/" xmlns:po="http://purl.org/ontology/po/"><head><title>Component test</title></head><body id="component"><div class="box-component box-component-orphan"><div class="box-content"><ol class="programmes">
<li id="b00s1s1s" about="/programmes/b00s1s1s#programme" typeof="po:Series" class="series">
<div class="head">
<div class="series_summary blq-clearfix">
<h2 class="title" property="dc:title">Series 1</h2>