Skip to content

Commit

Permalink
NPM module: add Old Danish crosslinks
Browse files Browse the repository at this point in the history
  • Loading branch information
stscoundrel committed Feb 24, 2024
1 parent c4739e8 commit 97fced8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 41 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ Run `cargo run` in `downloader` folder. Downloads latest XML sitemaps to `resour

### Generate crosslinks

Run `go run *.go` in `crosslinks` folder. Generates crosslinks json to `resources` folder.
Run `go run *.go` in `crosslinks` folder. Generates crosslinks json to `resources` folder.


### Minify outout

Run `nimble build` and `./minifier` in `minifier` folder. Generates minified & gzipped json outputs.

### Update data to NPM module.

Run `go run main.go` in root folder to update json & readme to NPM module.
21 changes: 1 addition & 20 deletions npm-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,4 @@ The parser finds over 1 000 entries that are present in all four dictionaries. T

### Install

`yarn add scandinavian-dictionary-crosslinker`


### Download sitemaps.

Run `cargo run` in `downloader` folder. Downloads latest XML sitemaps to `resources` folder.


### Generate crosslinks

Run `go run *.go` in `crosslinks` folder. Generates crosslinks json to `resources` folder.


### Minify outout

Run `nimble build` and `./minifier` in `minifier` folder. Generates minified & gzipped json outputs.

### Update data to NPM module.

Run `go run main.go` in root folder to update json & readme to NPM module.
`yarn add scandinavian-dictionary-crosslinker`
Binary file modified npm-module/resources/crosslinks.json.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions npm-module/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ export const getOldSwedishCrosslinks = (slug: string): Crosslink[] => filterCros
DictionarySource.OldSwedish,
);

export const getOldDanishCrosslinks = (slug: string): Crosslink[] => filterCrosslinksByLanguage(
slug,
DictionarySource.OldDanish,
);

export { Crosslink, DictionarySource } from './models';
3 changes: 2 additions & 1 deletion npm-module/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export enum DictionarySource {
OldNorse = 'old-norse',
OldIcelandic = 'old-icelandic',
OldNorwegian = 'old-norwegian',
OldSwedish = 'old-swedish'
OldSwedish = 'old-swedish',
OldDanish = 'old-danish'
}

export interface Crosslink{
Expand Down
37 changes: 18 additions & 19 deletions npm-module/tests/crosslinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Crosslinks tests', () => {
test('Crosslinks contain correct amount of slug entries', () => {
const result = getCrosslinks();

expect(Object.keys(result).length).toBe(44545);
expect(Object.keys(result).length).toBe(48294);
});

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

expect(sum).toEqual(120313);
expect(sum).toEqual(128440);
});

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

expect(result.abyrgdarhlutr).toEqual(
[
{
url: 'https://old-norwegian-dictionary.vercel.app/word/abyrgdarhlutr',
source: DictionarySource.OldNorwegian,
},
{
url: 'https://old-icelandic.vercel.app/word/abyrgdarhlutr',
source: DictionarySource.OldIcelandic,
},
{
url: 'https://old-norwegian-dictionary.vercel.app/word/abyrgdarhlutr',
source: DictionarySource.OldNorwegian,
},
],
);

expect(result.hneyking).toEqual(
[
{
url: 'https://old-norwegian-dictionary.vercel.app/word/hneyking',
source: DictionarySource.OldNorwegian,
},
{
url: 'https://cleasby-vigfusson-dictionary.vercel.app/word/hneyking',
source: DictionarySource.OldNorse,
Expand All @@ -66,19 +62,23 @@ describe('Crosslinks tests', () => {
url: 'https://old-icelandic.vercel.app/word/hneyking',
source: DictionarySource.OldIcelandic,
},
{
url: 'https://old-norwegian-dictionary.vercel.app/word/hneyking',
source: DictionarySource.OldNorwegian,
},
],
);

expect(result.skurfir).toEqual(
[
{
url: 'https://old-norwegian-dictionary.vercel.app/word/skurfir',
source: DictionarySource.OldNorwegian,
},
{
url: 'https://cleasby-vigfusson-dictionary.vercel.app/word/skurfir',
source: DictionarySource.OldNorse,
},
{
url: 'https://old-norwegian-dictionary.vercel.app/word/skurfir',
source: DictionarySource.OldNorwegian,
},
],
);

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

expect(result['otta-lauss']).toEqual([
{
url: 'https://old-norwegian-dictionary.vercel.app/word/ottalauss',
source: DictionarySource.OldNorwegian,
},
{
source: DictionarySource.OldNorse,
url: 'https://cleasby-vigfusson-dictionary.vercel.app/word/otta-lauss',
Expand All @@ -106,7 +102,10 @@ describe('Crosslinks tests', () => {
source: DictionarySource.OldIcelandic,
url: 'https://old-icelandic.vercel.app/word/ottalauss',
},

{
url: 'https://old-norwegian-dictionary.vercel.app/word/ottalauss',
source: DictionarySource.OldNorwegian,
},
]);
});
});
Expand Down

0 comments on commit 97fced8

Please sign in to comment.