Skip to content

Instantly share code, notes, and snippets.

View seralf's full-sized avatar
🎯
Focusing

Alfredo Serafini seralf

🎯
Focusing
View GitHub Profile
@afs
afs / rules-spec.md
Last active August 11, 2025 14:47
Sketch of SHACL Rules doc

Warning : this document is out of date and is not being updated

Please direct comments to https://github.com/w3c/data-shapes/issues


SHACL Rules

SHACL rules infer new triples. The input is a data graph and a shape graph with rules, the output is a graph of inferred triples that do not occur in the data graph.

@afs
afs / sql-correlated-example.md
Last active August 6, 2025 19:47
SQL de-correlation example
@afs
afs / notes2.md
Last active August 11, 2025 14:47
Notes on SHACL Rules
@cbuil
cbuil / RDF4JLoad.java
Created January 20, 2023 16:45
loading wikidata on RDF4J
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.rdf4j.common.exception.RDF4JException;
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
@cgivre
cgivre / gist:a5c5c24048fe799278b79f971b39e6e5
Last active August 18, 2021 21:55
Convert ANSI SQL to T-SQL

One of the major challenges you may face is converting "normal" SQL to T-SQL which is Microsoft's dialect of SQL. I couldn't find any easy way to do this, however in doing some other work I found that Apache Calcite can actually perform this function quite simply. So... here's some code that does exactly that!

import org.apache.calcite.config.Lex;
import org.apache.calcite.sql.SqlDialect;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.parser.SqlParseException;

lakeFS with MinIO

lakeFS gives Git-like capabilities over your MinIO storage, allowing you to coordinate with colleagues when working on your data.

In the following example, we will use lakeFS to create a branch on your storage, commit changes to it, and then merge it to the master branch.

Prerequisites

  • Install MinIO Server from here.
  • Install mc from here.
  • Install docker-compose from here.
@pebbie
pebbie / sparqlqueryviz.py
Last active April 11, 2025 09:49
visualize BGP triples in SPARQL query
import sys
import os.path as path
from rdflib import Namespace, XSD, RDF, RDFS, OWL
from rdflib.term import Variable, URIRef, BNode, Literal
from rdflib.plugins.sparql.parser import parseQuery
from rdflib.plugins.sparql.parserutils import prettify_parsetree
from rdflib.plugins.sparql import prepareQuery
from rdflib.paths import Path
import pprint
import pygraphviz as pgv
@huchenxucs
huchenxucs / pos_embed.py
Created July 23, 2020 06:09
T5 relative positional embedding
import math
import torch
import torch.nn as nn
from torch.nn import functional as F
class RelativePositionBias(nn.Module):
def __init__(self, bidirectional=True, num_buckets=32, max_distance=128, n_heads=2):
super(RelativePositionBias, self).__init__()
self.bidirectional = bidirectional
@RobertAKARobin
RobertAKARobin / python.md
Last active August 3, 2025 12:18
Python Is Not A Great Programming Language
@vkocaman
vkocaman / annotators.csv
Created September 27, 2019 21:05
list of annotators offered by Spark NLP
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 5 columns, instead of 3 in line 9.
Annotator,Description,Version,Annotator Approach,Annotator Model
Tokenizer*,Identifies tokens with tokenization open standards,Opensource,-,+
Normalizer*,Removes all dirty characters from text,Opensource,-,+
Stemmer*,Returns hard'-stems out of words with the objective of retrieving the meaningful part of the word,Opensource,+,-
Lemmatizer*,Retrieves lemmas out of words with the objective of returning a base dictionary word,Opensource,-,+
RegexMatcher*,Uses a reference file to match a set of regular expressions and put them inside a provided key.,Opensource,+,+
TextMatcher*,Annotator to match entire phrases (by token) provided in a file against a Document,Opensource,+,+
Chunker*,Matches a pattern of part'-of'-speech tags in order to return meaningful phrases from document,Opensource,+,-
DateMatcher*,Reads from different forms of date and time expressions and converts them to a provided date format,Opensource,+,-
SentenceDetector*,Finds sentence bounds in raw text. Applies rules from Pragmatic Segmenter,Opensou