Skip to content

Instantly share code, notes, and snippets.

View tatiana's full-sized avatar

Tatiana Al-Chueyr tatiana

View GitHub Profile
@tatiana
tatiana / factorial.feature
Created March 14, 2011 03:46
lettuce usage - feature file for the factorial example (using table)
Feature: Compute factorial
In order to play with Lettuce
As beginners
We'll implement factorial
Scenario: Factorials [0-4]
Given I have the number <number>
When I compute its factorial
Then I see the number <result>
@tatiana
tatiana / factorial_step.py
Created March 15, 2011 12:37
lettuce usage - step file for the factorial example
from lettuce import *
@step('I have the number (\d+)')
def have_the_number(step, number):
world.number = int(number)
@step('I compute its factorial')
def compute_its_fatorial(step):
world.number = factorial(world.number)
@tatiana
tatiana / rdfalchemy_test_dbpedia.py
Created June 21, 2012 19:02
First steps with RDFAlchemy and SPARQL to access DBPedia
from rdfalchemy.sparql import SPARQLGraph
from rdflib import Namespace
query = """
PREFIX db: <http://dbpedia.org/resource/>
PREFIX dbonto: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?who
FROM <http://dbpedia.org>
WHERE {
@tatiana
tatiana / rdfalchemy_test_dbpedia2.py
Created June 22, 2012 19:14
Trying to replace SPARQL query using RDFAlchemy's rdfSubject
from rdfalchemy import rdfSingle, rdfSubject
from rdfalchemy.sparql import SPARQLGraph
from rdflib import Namespace
query = """
PREFIX db: <http://dbpedia.org/resource/>
PREFIX dbprop: <http://dbpedia.org/property/>
PREFIX dbonto: <http://dbpedia.org/ontology/>
SELECT distinct ?name ?label {
@tatiana
tatiana / sparql_list_predicates_band.py
Created June 28, 2012 22:19
SPARQLWrapper example: List all predicates of DBPedia Band class
from SPARQLWrapper import SPARQLWrapper, JSON
query = """
SELECT distinct ?subject
FROM <http://dbpedia.org>
{
?subject rdfs:domain ?object .
<http://dbpedia.org/ontology/Band> rdfs:subClassOf ?object
OPTION (TRANSITIVE, t_distinct, t_step('step_no') as ?n, t_min (0) ).
}"""
@tatiana
tatiana / sparql_metal_musicians.py
Created June 29, 2012 04:29
SPARQLWrapper example: List who (musicians) have genre Metal
from SPARQLWrapper import SPARQLWrapper, JSON
# List all instances (eg. bands) with genre Metal
query = """
PREFIX db: <http://dbpedia.org/resource/>
PREFIX dbonto: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?who
FROM <http://dbpedia.org>
WHERE {
@tatiana
tatiana / sparql_query_inference
Last active December 15, 2015 00:08
Why adding transitivity breaks language filter in SPARQL Query?
@prefix tpedia: <http://tatipedia.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
tpedia:new_york a tpedia:Place ;
rdfs:label "Nova Iorque"@pt ;
rdfs:label "New York"@en .
tpedia:london a tpedia:Place ;
rdfs:label "Londres"@pt ;
@tatiana
tatiana / sparql_query_count
Created March 19, 2013 14:10
Can I build a single SPARQL query for listing items and counting them?
DEFINE input:inference <http://tatipedia.org/property_ruleset>
SELECT DISTINCT ?subject ?label count(distinct ?subject) as ?total
WHERE {
?subject a <http://tatipedia.org/Place>;
rdfs:label ?label .
FILTER (langMatches(lang(?label), "pt"))
}
LIMIT 2
@tatiana
tatiana / server1.py
Last active July 30, 2022 14:29
Example of usage of BaseHTTPServer, available at Python 2.x
import urlparse
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
# http://pymotw.com/2/BaseHTTPServer/
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
message_parts = [
'CLIENT VALUES:',
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hi from Flask!"
if __name__ == "__main__":