Skip to content

Instantly share code, notes, and snippets.

import argparse
from collections import defaultdict
import json
from pathlib import Path
import re
from typing import Counter
parser = argparse.ArgumentParser(description='Create a JSON file with word pairs using word alignment files')
parser.add_argument('-s', '--source', type=Path, help='Source file', required=True)
parser.add_argument('-t', '--target', type=Path, help='Target file', required=True)
import argparse
from pathlib import Path
import re
from typing import List, Tuple
def main():
parser = argparse.ArgumentParser(description='Create a JSON file with word pairs using word alignment files')
parser.add_argument('-s', '--source', type=Path, help='Source file', required=True)
parser.add_argument('-t', '--target', type=Path, help='Target file', required=True)
parser.add_argument('-a1', '--input1', type=Path, help='Alignment file 1', required=True)
// Default rendering rules for Maperitive resembling that of OSM Mapnik
// http://maperitive.net
// Created by Igor Brejc
// Released under the Creative Commons Attribution-ShareAlike 3.0 License (http://creativecommons.org/licenses/by-sa/3.0/)
// Updates by Michael <quelbs_at_gmail.com>
// Icons used: Map icons CC-0 from SJJB Management (http://www.sjjb.co.uk/mapicons)
// Modified by Iikka Hauhio
@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"