Skip to content

Commit cdbd921

Browse files
authored
Readme: add usage examples
1 parent ff951ec commit cdbd921

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,43 @@ As Maven dependency.
1919

2020
For alternative install methods, see the [Maven Central Repo](https://search.maven.org/artifact/io.github.stscoundrel/old-norse-dictionary)
2121

22+
### Usage
23+
24+
The dictionary comes in two variants:
25+
- Markup dictionary has HTML markup `<i>` and `<b>` to match look of the original book.
26+
- No-markup version has the same content without any additional formatting tags.
27+
28+
Dictionary defaults to "no markup".
29+
30+
```scala
31+
32+
import io.github.stscoundrel.oldnorsedictionary
33+
34+
val dictionary = new Dictionary()
35+
36+
// Both dictionaries return entries that consist of headword and definitions list.
37+
val noMarkupResult = dictionary.getNoMarkupDictionary() // also aliased as getDictionary()
38+
val markupResult = dictionary.getMarkupDictionary()
39+
40+
// Headwords wont differ between dictionaries.
41+
println(noMarkupResult(1989).headword) // át-frekr
42+
println(markupResult(1989).headword) // át-frekr
43+
44+
// But definition markup does differ.
45+
println(noMarkupResult(14).definitions(0)) // adj. <i>greedy, voracious,</i> Hkv. 2. 41.
46+
println(markupResult(14).definitions(0)) // adj. greedy, voracious, Hkv. 2. 41.
47+
48+
```
49+
50+
Individual words are returned in format of:
51+
52+
```scala
53+
{
54+
headword: String
55+
definitions: Array[String]
56+
}
57+
```
58+
2259
### About Cleasby & Vigfusson Dictionary
2360

2461
"Icelandic-English" dictionary was started by Richard Cleasby and finished by Gudbrand Vigfusson. It was published in 1874, which leads to there being many public domain versions of the book available.

0 commit comments

Comments
 (0)