Skip to content

Commit 880a582

Browse files
authored
Merge pull request #104 from stscoundrel/feature/old-danish-dictionary
Feature/old danish dictionary
2 parents 5020ec5 + 8d4a6fd commit 880a582

File tree

10 files changed

+52
-22
lines changed

10 files changed

+52
-22
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,30 @@ Parses sources from following dictionary projects:
77
- [Old Icelandic Dictionary](https://old-icelandic.vercel.app/)
88
- [Old Norwegian Dictionary](https://old-norwegian-dictionary.vercel.app/)
99
- [Old Swedish Dictionary](https://old-swedish-dictionary.vercel.app/)
10+
- [Old Danish Dictionary](https://old-danish-dictionary.vercel.app/)
1011

1112

1213
The parser finds over 1 000 entries that are present in all four dictionaries. There are also over 20 000 entries that appear in at least two different dictionaries, making them worth a crosslink.
1314

1415
### Install
1516

1617
`yarn add scandinavian-dictionary-crosslinker`
18+
19+
20+
### Download sitemaps.
21+
22+
Run `cargo run` in `downloader` folder. Downloads latest XML sitemaps to `resources` folder.
23+
24+
25+
### Generate crosslinks
26+
27+
Run `go run *.go` in `crosslinks` folder. Generates crosslinks json to `resources` folder.
28+
29+
30+
### Minify outout
31+
32+
Run `nimble build` and `./minifier` in `minifier` folder. Generates minified & gzipped json outputs.
33+
34+
### Update data to NPM module.
35+
36+
Run `go run main.go` in root folder to update json & readme to NPM module.

crosslinker/internal/sitemaps/reader.go

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var sitemapPaths = map[string]string{
77
"old-icelandic": "../resources/old-icelandic.xml",
88
"old-norwegian": "../resources/old-norwegian.xml",
99
"old-swedish": "../resources/old-swedish.xml",
10+
"old-danish": "../resources/old-danish.xml",
1011
}
1112

1213
func readXmlSitemaps() (map[string][]byte, error) {

downloader/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ async fn main() {
1010
urls.insert("old-icelandic", "https://old-icelandic.vercel.app/sitemap.xml");
1111
urls.insert("old-norwegian", "https://old-norwegian-dictionary.vercel.app/sitemap.xml");
1212
urls.insert("old-swedish", "https://old-swedish-dictionary.vercel.app/sitemap.xml");
13+
urls.insert("old-danish", "https://old-danish-dictionary.vercel.app/sitemap.xml");
1314

1415
let client = Client::new();
1516

minifier/src/minifier.nim

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ proc minify_link(link: string): string =
1313
.replace("https://old-norwegian-dictionary.vercel.app/word/", "")
1414
.replace("https://old-swedish-dictionary.vercel.app/word/", "")
1515
.replace("https://cleasby-vigfusson-dictionary.vercel.app/word/", "")
16+
.replace("https://old-danish-dictionary.vercel.app/word/", "")
1617

1718

1819
proc minify_source(link: string): string =
@@ -21,6 +22,7 @@ proc minify_source(link: string): string =
2122
.replace("old-swedish", "os")
2223
.replace("old-norse", "on")
2324
.replace("old-icelandic", "oi")
25+
.replace("old-danish", "od")
2426

2527

2628
for slug, links in jsonContent:

npm-module/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Parses sources from following dictionary projects:
77
- [Old Icelandic Dictionary](https://old-icelandic.vercel.app/)
88
- [Old Norwegian Dictionary](https://old-norwegian-dictionary.vercel.app/)
99
- [Old Swedish Dictionary](https://old-swedish-dictionary.vercel.app/)
10+
- [Old Danish Dictionary](https://old-danish-dictionary.vercel.app/)
1011

1112

1213
The parser finds over 1 000 entries that are present in all four dictionaries. There are also over 20 000 entries that appear in at least two different dictionaries, making them worth a crosslink.
1314

1415
### Install
1516

16-
`yarn add scandinavian-dictionary-crosslinker`
17+
`yarn add scandinavian-dictionary-crosslinker`

npm-module/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scandinavian-dictionary-crosslinker",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "Finds shared entries in dictionary sitemaps, allowing crosslinking",
55
"repository": "https://github.com/stscoundrel/scandinavian-dictionary-crosslinker.git",
66
"author": "stscoundrel <[email protected]>",
106 KB
Binary file not shown.

npm-module/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ export const getOldSwedishCrosslinks = (slug: string): Crosslink[] => filterCros
4646
DictionarySource.OldSwedish,
4747
);
4848

49+
export const getOldDanishCrosslinks = (slug: string): Crosslink[] => filterCrosslinksByLanguage(
50+
slug,
51+
DictionarySource.OldDanish,
52+
);
53+
4954
export { Crosslink, DictionarySource } from './models';

npm-module/src/models.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ export enum DictionarySource {
22
OldNorse = 'old-norse',
33
OldIcelandic = 'old-icelandic',
44
OldNorwegian = 'old-norwegian',
5-
OldSwedish = 'old-swedish'
5+
OldSwedish = 'old-swedish',
6+
OldDanish = 'old-danish'
67
}
78

89
export interface Crosslink{

npm-module/tests/crosslinks.test.ts

+18-19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('Crosslinks tests', () => {
1111
test('Crosslinks contain correct amount of slug entries', () => {
1212
const result = getCrosslinks();
1313

14-
expect(Object.keys(result).length).toBe(44545);
14+
expect(Object.keys(result).length).toBe(48294);
1515
});
1616

1717
test('Crosslinks contain correct amount of summed individual links', () => {
@@ -22,7 +22,7 @@ describe('Crosslinks tests', () => {
2222
sum += result[key].length;
2323
});
2424

25-
expect(sum).toEqual(120313);
25+
expect(sum).toEqual(128440);
2626
});
2727

2828
test('Crosslink entries are returned in correct object format', () => {
@@ -41,23 +41,19 @@ describe('Crosslinks tests', () => {
4141

4242
expect(result.abyrgdarhlutr).toEqual(
4343
[
44-
{
45-
url: 'https://old-norwegian-dictionary.vercel.app/word/abyrgdarhlutr',
46-
source: DictionarySource.OldNorwegian,
47-
},
4844
{
4945
url: 'https://old-icelandic.vercel.app/word/abyrgdarhlutr',
5046
source: DictionarySource.OldIcelandic,
5147
},
48+
{
49+
url: 'https://old-norwegian-dictionary.vercel.app/word/abyrgdarhlutr',
50+
source: DictionarySource.OldNorwegian,
51+
},
5252
],
5353
);
5454

5555
expect(result.hneyking).toEqual(
5656
[
57-
{
58-
url: 'https://old-norwegian-dictionary.vercel.app/word/hneyking',
59-
source: DictionarySource.OldNorwegian,
60-
},
6157
{
6258
url: 'https://cleasby-vigfusson-dictionary.vercel.app/word/hneyking',
6359
source: DictionarySource.OldNorse,
@@ -66,19 +62,23 @@ describe('Crosslinks tests', () => {
6662
url: 'https://old-icelandic.vercel.app/word/hneyking',
6763
source: DictionarySource.OldIcelandic,
6864
},
65+
{
66+
url: 'https://old-norwegian-dictionary.vercel.app/word/hneyking',
67+
source: DictionarySource.OldNorwegian,
68+
},
6969
],
7070
);
7171

7272
expect(result.skurfir).toEqual(
7373
[
74-
{
75-
url: 'https://old-norwegian-dictionary.vercel.app/word/skurfir',
76-
source: DictionarySource.OldNorwegian,
77-
},
7874
{
7975
url: 'https://cleasby-vigfusson-dictionary.vercel.app/word/skurfir',
8076
source: DictionarySource.OldNorse,
8177
},
78+
{
79+
url: 'https://old-norwegian-dictionary.vercel.app/word/skurfir',
80+
source: DictionarySource.OldNorwegian,
81+
},
8282
],
8383
);
8484

@@ -94,10 +94,6 @@ describe('Crosslinks tests', () => {
9494
]);
9595

9696
expect(result['otta-lauss']).toEqual([
97-
{
98-
url: 'https://old-norwegian-dictionary.vercel.app/word/ottalauss',
99-
source: DictionarySource.OldNorwegian,
100-
},
10197
{
10298
source: DictionarySource.OldNorse,
10399
url: 'https://cleasby-vigfusson-dictionary.vercel.app/word/otta-lauss',
@@ -106,7 +102,10 @@ describe('Crosslinks tests', () => {
106102
source: DictionarySource.OldIcelandic,
107103
url: 'https://old-icelandic.vercel.app/word/ottalauss',
108104
},
109-
105+
{
106+
url: 'https://old-norwegian-dictionary.vercel.app/word/ottalauss',
107+
source: DictionarySource.OldNorwegian,
108+
},
110109
]);
111110
});
112111
});

0 commit comments

Comments
 (0)