Extract from Wiktionary dump
Using a really basic extractor
#!/usr/bin/perl
use warnings;
use strict;
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
my $title = '';
my $id = '';
while(<>) {
chomp;
if(m!<title>([^<]+)</title>!) {
$title = $1;
}
if(m!^ <id>([^<]+)</id>!) {
$id = $1;
}
if(/\{\{IPA\|ga/) {
if($title and $title ne '') {
print "\n---\n";
print "$title\n";
print "ID $id\n";
$title = '';
$id = '';
}
print "$_\n";
} elsif(m!Quiggin!) {
print "$_\n";
}
}
INPUT = "/Users/joregan/Playing/irish-gists/wiktionary/2025-extract.txt"
with open(INPUT) as f:
text = f.read()
pieces = text.split("\n---\n")
pieces = [p.strip() for p in pieces if p != ""]
pieces = [p for p in pieces if "|ga|" in p]
quiggin = [p for p in pieces if "Quiggin" in p]
import urllib.parse
def make_link(word, id):
url_word = urllib.parse.quote(word.replace(" ", "_"))
return f"https://en.wiktionary.org/w/index.php?title={url_word}&oldid={id}"
def clean_line(line):
if line.startswith("* "):
line = line[2:]
if "</text>" in line:
line = line.replace("</text>", "")
return line.strip()
def extract_entry(p):
lines = p.split("\n")
title = lines[0].strip()
id = lines[1].strip().replace("ID ", "")
lines = lines[2:]
if len(lines) == 1:
if "Quiggin" in lines[0]:
return {
"title": title,
"url": make_link(title, id),
"raw": clean_line(lines[0])
}
elif len(lines) == 2:
if "* {{R:ga:Quiggin" in lines[1]:
return {
"title": title,
"url": make_link(title, id),
"raw": [clean_line(p) for p in lines],
}
else:
def yes(line):
return "Quiggin" in line or "Ulster" in line
lines = [clean_line(p) for p in lines if yes(p)]
if lines != []:
return {
"title": title,
"url": make_link(title, id),
"raw": lines,
}
return None
extr = [extract_entry(p) for p in quiggin]
extr = [e for e in extr if e is not None]
with open("wiktionary-quiggin.json", "w") as f:
import json
json.dump(extr, f, indent=2)