Skip to content

Instantly share code, notes, and snippets.

@fergusq
fergusq / convert_marian_to_pytorch.py
Last active April 23, 2024 13:05
Convert Marian NMT models to PyTorch models (transformers library format)
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Copyright 2024 Iikka Hauhio (removed OPUS/Tatoeba-specific code to allow converting arbitrary models)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@fergusq
fergusq / finnish_num_infl.py
Last active January 22, 2024 19:02
A small module for replacing cardinal numerals written using number symbols with numerals written using letters in Finnish text. Dependencies: taivutin, stanza
import taivutin
import stanza
import re
nlp = stanza.Pipeline("fi")
tai = taivutin.Taivutin()
case_stanza2taivutin = {
"Nom": "nom",
"Gen": "gen",
@fergusq
fergusq / predict.py
Last active February 23, 2023 14:51
# (c) 2023 Iikka Hauhio
# Use freely but attribute me
import argparse
import readline
import traceback
from pynvml import *
import rich, rich.text, rich.panel, rich.live, rich.console
import torch
@fergusq
fergusq / boqwi.ts
Created March 16, 2021 17:53
This is a script that can analyze Klingon words using the boQwI' dictionary.
/*
* This is a script that can analyze Klingon words using the boQwI' dictionary.
*
* You need to have dictionary.json available somewhere.
*
* Usage:
*
* const analyzeWord = await initializeDictionary();
* console.log(analyzeWord("Heghlu'meH"))
*/
@fergusq
fergusq / Klingon-sampa.txt
Created September 15, 2020 10:17
Virtual Singer Klingon Language Configuration (WIP)
#***************************************************************************************
# Klingon
# Definition des liens entre la notation Sampa et les Fragments
C GLST T2 SH
G RXS RXS
N NG
T GLST T2 GLST LFI
a A
b SQ B
@fergusq
fergusq / tlh.qml
Last active February 28, 2020 15:11
Klingon keyboard layout for the Sailfish keyboard (Jolla maliit plugin)
/*
* Klingon keyboard layout for the Sailfish keyboard (Jolla maliit plugin)
*
* Copyright (C) Iikka Hauhio 2020
* Saa käyttää vapaasti mihin tahansa tarkoitukseen :)
* May be used freely for whatever purpose
*
* How to install:
* 1. Copy file to /usr/share/maliit/plugins/com/jolla/layouts/
* 2. Add this text to the end of /usr/share/maliit/plugins/com/jolla/layouts/layouts_western.conf:
{
conllu := require("conllu")
}
main treebank {
time := currentTime()
conllu.parseSentences treebank | addTree _
time = currentTime()-time
print time/1000, " s"
@fergusq
fergusq / eppa3d.bas
Created November 3, 2018 10:49
A raycasting 3D engine written in EppaBasic
' Pelaajan sijainti
Dim playerAngle As Number = 0
Dim playerX As Number = 1.5
Dim playerY As Number = 1.5
' Näkökentän koko
Dim FOV = ebPi / 2 ' 90°
@fergusq
fergusq / riimit.röd
Created October 21, 2018 20:12
A script for finding Finnish rap rhymes
{
case := require("case").case
vok := "aeiouyäöå"
kon := "bcdfghjklmnpqrstvwx"
}
select l {
return l[abs(randomInteger())%#l]
}
@fergusq
fergusq / aktia-bank-statement-to-report.röd
Last active November 4, 2018 19:01
A script that creates a report with pie charts and transactions from an Aktia bank statement.
/*
* Copyright (c) 2018 Iikka Hauhio
* Do whatever you want with this.
*
* This Röda script will process an Aktia bank statement and
* create a report with nice pie charts. It relies on the
* pgf-pie LaTeX package. After creating pictures using LaTeX
* it creates the report using Troff (Groff) and the ms
* preprocessor.
*