This file contains 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
/* | |
code to get all var names hanging from a rasqal_expression | |
author: Manuel Salvadores ([email protected]) | |
*/ | |
static void get_var_names(rasqal_expression *e,GList **list_vars) { | |
GList *l = *list_vars; | |
if (!e) return; | |
if (e->literal != NULL) { | |
rasqal_literal *lit = e->literal; |
This file contains 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
""" | |
Sample code to traverse RDF list with RDFLIB. | |
author: Manuel Salvadores ([email protected]) | |
rdf containers are a pain in general, quite annoying to handle them. | |
To get all the authors for a given article like in your case you could do | |
something like the code I am posting below. |
This file contains 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
""" | |
author: Manuel Salvadores ([email protected]) | |
Code sample in answer from Stack Overflow: | |
http://stackoverflow.com/questions/5289189/how-to-change-tag-name-with-beautifulsoup/5289523#5289523 | |
""" | |
import BeautifulSoup | |
if __name__ == "__main__": | |
data = """ |
This file contains 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
" author: Manuel Salvadores http://msalvadores.me " | |
" My notes on using git/github " | |
#---- workflow on remote public forked repositories ---- | |
#checkouts master branch from a forked github repo | |
git clone <git path to my forked repo> | |
#adds origin for futures merges/pulls | |
git remote add <name_origin> <git path to original repo> |
This file contains 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
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
@prefix def: <http://foo.com/def/> . | |
@prefix id: <http://foo.com/id/> . | |
############################################################ | |
##### RDFS SCHEMA | |
############################################################ | |
######## rdfs:subClassOf hierarchy |
This file contains 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
#stackoverflow answer http://stackoverflow.com/questions/6225590/python-find-occurrences-of-strings-from-a-reference-file-within-an-input-file | |
def count_line_occurrences(ref_list,input_list): | |
line_counter = {} | |
# Initialization | |
for ref_line in ref_list: | |
ref_line = ref_line.rstrip() | |
line_counter[ref_line] = 0 | |
for input_line in input_list: | |
input_line = input_line.rstrip() |
This file contains 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
package ncbo.proto; | |
import java.io.FileInputStream; | |
import java.net.URI; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Properties; | |
import edu.stanford.smi.protegex.owl.database.creator.OwlDatabaseCreator; | |
import edu.stanford.smi.protegex.owl.model.OWLModel; |
This file contains 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
#Ontology here http://protege.stanford.edu/ontologies/mappings/mappings.rdfs | |
<http://purl.bioontology.org/mapping/21d7a8e0-004d-012e-74a1-005056bd0010> | |
<http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#created_in_source_ontology_version> 40400 ; | |
<http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#created_in_target_ontology_version> 42693 ; | |
<http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#date> "2010-05-17T23:24:34Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ; | |
<http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#mapping_source> "Application" ; | |
<http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#mapping_source_algorithm> "Mappings were generated by the LOOM algorithm automatically based on close lexical match between preferred names of terms or a preferred name and a synonym." ; | |
<http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#mapping_source_contact_info> "[email protected]" ; | |
<http://protege.stanford. |
This file contains 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
import json | |
import urllib2 | |
import urllib | |
import traceback | |
import sys | |
def query(q,apikey,epr,f='application/json'): | |
"""Function that uses urllib/urllib2 to issue a SPARQL query. | |
By default it requests json as data format for the SPARQL resultset""" |
This file contains 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
package test; | |
import java.io.PrintStream; | |
public class TestOutput { | |
public static void outputFiltered(String label, PrintStream out) { | |
for (byte b : label.getBytes()) { | |
if (Character.isLetterOrDigit((char)b)) { | |
out.print((char)b); |
OlderNewer