Skip to content

Instantly share code, notes, and snippets.

Avatar
🐓

Julian Bruyat BruJu

🐓
View GitHub Profile
@BruJu
BruJu / state.ts
Created Jan 18, 2022
Incremental state
View state.ts
// Incremental state for lang-turtle in my repository prec-demo
// It gives me serious headaches so I'm gisting it
import { Language, syntaxTree } from "@codemirror/language";
import { EditorState, StateField, Transaction } from "@codemirror/state";
import { SyntaxNode } from "@lezer/common";
import * as RDF from "@rdfjs/types";
import { DataFactory, Store } from 'n3';
function buildForest() {
@BruJu
BruJu / findAllOccurrencesOfTerms.ts
Created Nov 23, 2021
findAllOccurrencesOfTerms
View findAllOccurrencesOfTerms.ts
/**
* Return all occurences of the given terms in a DStar Dataset
* @see https://github.com/BruJu/PREC
*/
function findAllOccurrencesOfTerms(graph: DStar, terms: RDF.Term[]): RDF.Quad[] {
return terms.flatMap(term => [
...graph.getQuads(term, null, null, $defaultGraph),
...graph.getQuads(null, term, null, $defaultGraph),
...graph.getQuads(null, null, term, $defaultGraph),
...graph.getRDFStarQuads().filter(q => QuadStar.containsTerm(q, term))
View two_legs.rs
// The feature that Rust needs
trait Animal { const LEGS: u32; }
fn walk_on_your_two_legs<A>(_animal: &A)
where A: Animal
// , A::LEGS == 2 :(
{
println!("I'm walking on my two legs")
}
View quad-star-multinested-store.js
'use strict';
/*
* This script enables to store multi nested quads in an N3.Store
* Usage:
* Add quads with addQuadsWithoutMultiNesting(store, quads)
* The store will contain the quads, but 2sd level nested quads will be replaced with a blank node
* When you have a quad for which you want the true version, use remakeMultiNesting(store, quads)
*
@BruJu
BruJu / pgoContext.ttl
Last active Jun 30, 2021
Property Graph Ontology Context
View pgoContext.ttl
PREFIX prec: <http://bruy.at/prec#>
PREFIX pvar: <http://bruy.at/prec-trans#>
PREFIX pgo: <http://ii.uwb.edu.pl/pgo#>
PREFIX ex: <http://example.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# A PREC Context to produce RDF graphs similar to the one produced by graphConv
# PREC: https://github.com/BruJu/PREC
# graphConv: https://github.com/domel/graphConv
@BruJu
BruJu / notes_latex.md
Last active Jun 30, 2021
Notes latex / papiers
View notes_latex.md
  • Most of the time, \tt / \texttt instead of verb!!
  • Create macro for common tools \Javascript
  • Section, Table and Figure with a majuscule, (stop forgetting about this)
  • an rdf because "an airdieff"
  • "semantic" → adjectif, "semantics" → nom (même au singulier)
@BruJu
BruJu / graph-reducer.js
Created May 14, 2021
Leftovers code from PREC
View graph-reducer.js
// === transformProperties
// TODO:
// if (asSet) {
// for (const bind of newB) {
// noList(store, bind.x);
// }
// }
View StoreAlterer.js
"use strict";
//! I was too lazy to learn how to use another Triple Pattern Matching and
//! Replacement library, let alone find one that is not async await heavy,
//! so I built one...
const DataFactory = require('n3').DataFactory;
const variable = DataFactory.variable;
/**
@BruJu
BruJu / printPropertyMapper.js
Created Apr 19, 2021
PropertyMapper::printPropertyMapper
View printPropertyMapper.js
// https://github.com/BruJu/PREC/blob/master/prec3/vocabulary-reader.js
// Developed for debug purpose
function PropertyMapper::printPropertyMapper() {
console.error("PropertyMapper {");
console.error(` iri:`);
console.error(this.iri);
console.error(" description node:");
console.error(this.descriptionNode);
console.error(" src:");
View Unblanknode.js
const N3 = require('n3');
/**
* Return the description of the `term`.
*
* The description is:
* - the term itself if it is not a blank node
* - if it is a blank node, a list of every [predicate, object] for which
* there exists a (term, predicate, object) quad in the default graph of the
* store