Skip to content

Instantly share code, notes, and snippets.

View aanastasiou's full-sized avatar

Athanasios Anastasiou aanastasiou

View GitHub Profile
@aanastasiou
aanastasiou / automatic_path_inflation_brief_test.py
Created August 11, 2023 14:18
Minor demo for neomodel's #716
from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,
UniqueIdProperty, RelationshipTo, db)
import os
class Country(StructuredNode):
code = StringProperty(unique_index=True, required=True)
class City(StructuredNode):
name = StringProperty(required=True)
country = RelationshipTo(Country, 'FROM_COUNTRY')
@aanastasiou
aanastasiou / main.py
Created March 9, 2023 11:09
Code to locate the specific "Washington, D.C." entry that causes a constrain validation upon ingesting ROR.
"""
A brief script to indicate the "location" of a possibly misspelled 'Washington'
in the current (v1.20-2023-02-28-ror-data.json) ROR dataset
:author: Athanasios Anastasiou
:date: Mar 2023
"""
import json
@aanastasiou
aanastasiou / stacklang.rsc
Last active March 12, 2023 21:22
A simple stack language expressed in Rascal
module stacklang_list::stacklang_list
// A very simple stack language
//
// The stack is represented as a list with the top of the stack extending the list from the left.
// For example, to add two numbers: eval([add(), push(1), push(1)])
import IO;
// Symbols
@aanastasiou
aanastasiou / main.py
Created November 20, 2022 21:19
Tiny scheme-like language to try out the structural pattern matching features in Python 3.10 onwards
"""
A very small scheme-like language to try out the structural pattern matching
features of python 3.11
Features:
* Mathematical expressions +,-,*,/ involving integers, variables and functions
* Functions are defined via lambda.
* Values (including functions) are assigned to variables via let
For more information regarding the concepts this language depends on, see:
@aanastasiou
aanastasiou / README.md
Last active November 6, 2020 18:45
Simple expression to parsing tree in graphviz

Expression to parse tree visualisation

Call with something like:

    > echo '11*19 + 3 * 9'|python exp2gviz.py -|dot -Earrowsize=0.4 -Nfixedsize=1 -Grankdir=BT -Tpng>gviz_out.png;feh gviz_out.png

To get something like:

image

@aanastasiou
aanastasiou / main.py
Created April 10, 2020 18:26
Graphml to Networkx Conversion
"""
Reads a Graphml file and instantiate the right type Networkx graph.
Notes:
1. This is still work in progress. At its current state, the code will comfortably read "simple" graphml files.
2. The next step is to enable the routine to selectively read in (graph, node, edge) level data based on the
namespace used.
3. This will probably be implemented with named tuples and it should support at least simple reads (if not full
complex writes too).
@aanastasiou
aanastasiou / indicative_output.md
Last active November 1, 2019 21:31
Convex polygon smoothing via DFT

Examples

Square

Smoothed Square

Freeform

Smoothed Freeform

@aanastasiou
aanastasiou / __init__.py
Last active January 9, 2019 10:05
Short term solution to using Neomodel 3.3.0 with Flask.
"""
This is a module that is supposed to be describing the whole datamodel of an application.
NOTE: The directory structure that is implied here is:
src/
app_models/
__init__.py (THIS FILE)
main.py
"""
@aanastasiou
aanastasiou / appmodels.py
Last active October 25, 2023 13:21
Using neomodel with Flask
import neomodel
class Item(neomodel.StructuredNode):
__primarykey__ = "name"
name = neomodel.StringProperty(unique_index=True)
@aanastasiou
aanastasiou / README.md
Created February 13, 2018 11:24
Create a "vectors only" Spacy model
  1. Use GloVe to produce vector data

    • This will produce the vectors.txt and vectors.bin data
  2. Use main.py to produce a new "vectors only" spacy model by using en_core_web_md as the base

  3. Once this finishes, run spacy package inDir outDir with inDir, outDir set to ModelInputDir, WhateverOutputDir respectively.

    • This step will create a package that can be readily used by spacy.
  4. From within WhateverOutputDir, execute pip install -e ./ to install the model as a module.