kotlin-oxford-dictionaries

Kotlin client for the Oxford Dictionaries API.

License

License

MIT
Categories

Categories

Kotlin Languages
GroupId

GroupId

com.github.sparkmuse
ArtifactId

ArtifactId

kotlin-oxford-dictionaries
Last Version

Last Version

1.0.8
Release Date

Release Date

Type

Type

jar
Description

Description

kotlin-oxford-dictionaries
Kotlin client for the Oxford Dictionaries API.
Project URL

Project URL

https://github.com/sparkmuse/kotlin-oxford-dictionaries
Source Code Management

Source Code Management

https://github.com/sparkmuse/kotlin-oxford-dictionaries

Download kotlin-oxford-dictionaries

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sparkmuse/kotlin-oxford-dictionaries/ -->
<dependency>
    <groupId>com.github.sparkmuse</groupId>
    <artifactId>kotlin-oxford-dictionaries</artifactId>
    <version>1.0.8</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sparkmuse/kotlin-oxford-dictionaries/
implementation 'com.github.sparkmuse:kotlin-oxford-dictionaries:1.0.8'
// https://jarcasting.com/artifacts/com.github.sparkmuse/kotlin-oxford-dictionaries/
implementation ("com.github.sparkmuse:kotlin-oxford-dictionaries:1.0.8")
'com.github.sparkmuse:kotlin-oxford-dictionaries:jar:1.0.8'
<dependency org="com.github.sparkmuse" name="kotlin-oxford-dictionaries" rev="1.0.8">
  <artifact name="kotlin-oxford-dictionaries" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sparkmuse', module='kotlin-oxford-dictionaries', version='1.0.8')
)
libraryDependencies += "com.github.sparkmuse" % "kotlin-oxford-dictionaries" % "1.0.8"
[com.github.sparkmuse/kotlin-oxford-dictionaries "1.0.8"]

Dependencies

compile (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.21
org.jetbrains.kotlin : kotlin-reflect jar 1.4.21
com.fasterxml.jackson.module : jackson-module-kotlin jar 2.12.0
com.squareup.okhttp3 : okhttp jar 4.9.0

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.7.0
org.assertj : assertj-core jar 3.18.1
com.github.sparkmuse : wiremock-junit-jupiter jar 1.1.15
com.github.nylle : javafixture jar 2.6.1

Project Modules

There are no modules declared in this project.

Kotlin Oxford Dictionaries

Build Quality Gate Status Coverage Maven Central GitHub

Kotlin client for the Oxford Dictionaries API.

This projects aims to facilitate the interaction with the Oxford Dictionaries API. A complete documentation for the API can be reached at: https://developer.oxforddictionaries.com/documentation.

Contents

Supported endpoints

The API currently supports all endpoints.

endpoints

Api Supported?
/api/v2/entries/{source_lang}/{word_id}:
/api/v2/lemmas/{source_lang}/{word_id}:
/api/v2/translations/{source_lang_translate}/{target_lang_translate}/{word_id}:
/api/v2/thesaurus/{lang}/{word_id}:
/api/v2/sentences/{source_lang}/{word_id}:
/api/v2/words/{source_lang}:
/api/v2/inflections/{source_lang}/{word_id}:
Search
/api/v2/search/translations/{source_lang_search}/{target_lang_search}:
/api/v2/search/{source_lang}:
/api/v2/search/thesaurus/{source_lang}
Utility
/api/v2/domains/{source_lang}:
/api/v2/domains/{source_lang_domains}/{target_lang_domains}:
/api/v2/fields:
/api/v2/fields/{endpoint}:
/api/v2/filters:
/api/v2/filters/{endpoint}:
/api/v2/grammaticalFeatures/{source_lang}:
/api/v2/grammaticalFeatures/{source_lang_grammatical}/{target_lang_grammatical}:
/api/v2/languages:
/api/v2/lexicalCategories/{source_lang}:
/api/v2/lexicalCategories/{source_lang_lexical}/{target_lang_lexical}:
/api/v2/registers/{source_lang}:
/api/v2/registers/{source_lang_registers}/{target_lang_registers}:

Install

All needed to start using the project is to add the dependency

Maven

<dependency>
  <groupId>com.github.sparkmuse</groupId>
  <artifactId>kotlin-oxford-dictionaries</artifactId>
  <version>1.0.8</version>
</dependency>

Gradle Kotlin DSL

implementation("com.github.sparkmuse:kotlin-oxford-dictionaries:1.0.8")

Gradle

implementation 'com.github.sparkmuse:kotlin-oxford-dictionaries:1.0.8'

Authentication App Key and Id

Oxford Dictionaries comes with three price tiers: Prototype, Developer and Research. A key can be obtained by following the link https://developer.oxforddictionaries.com/?tag=#plans.

Use the AppId and AppKey when creating the client.

Usage & Examples

Use the OxfordClient class to interact with the API.

Retrieve entries for the word 'ace'

kotlin

@Test
fun `retrieve entries for the word 'ace'`() {

    val appId = System.getenv("APP_ID")
    val appKey = System.getenv("APP_KEY")
    val baseUrl = "https://od-api.oxforddictionaries.com/api/v2"

    val oxfordClient = OxfordClient(appId, appKey, baseUrl)

    val entries = oxfordClient.entries("ace")

    assertNotNull(entries)
}

java

@Test
@DisplayName("retrieve entries for the word 'ace'")
void entries() {

    String appId = System.getenv("APP_ID");
    String appKey = System.getenv("APP_KEY");
    String baseUrl = "https://od-api.oxforddictionaries.com/api/v2";

    OxfordClient oxfordClient = new OxfordClient(appId, appKey, baseUrl);

    RetrieveEntry entries = oxfordClient.entries("ace");

    assertNotNull(entries);
}

Retrieve entries for the word 'ace' with complex query

kotlin

@Test
fun `gets entries for the word 'ace' with complex query`() {

    val appId = System.getenv("APP_ID")
    val appKey = System.getenv("APP_KEY")
    val baseUrl = "https://od-api.oxforddictionaries.com/api/v2"

    val oxfordClient = OxfordClient(appId, appKey, baseUrl)

    val query = EntryQuery(
        word = "ace",
        sourceLanguage = LanguageMonolingual.English_us,
        fields = listOf(DataField.definitions),
        lexicalCategory = listOf("noun"),
        strictMatch = true
    )

    val entries = oxfordClient.entries(query)
    assertNotNull(entries)
}

java

@Test
@DisplayName("gets entries for the word 'ace' with complex query")
void complexQueryEntries() {

    String appId = System.getenv("APP_ID");
    String appKey = System.getenv("APP_KEY");
    String baseUrl = "https://od-api.oxforddictionaries.com/api/v2";

    OxfordClient oxfordClient = new OxfordClient(appId, appKey, baseUrl);

    EntryQuery query = new EntryQuery(
            "ace",
            LanguageMonolingual.English_us,
            List.of(DataField.definitions),
            List.of(),
            List.of("noun"),
            List.of(),
            List.of(),
            true);
    RetrieveEntry entries = oxfordClient.entries(query);

    assertNotNull(entries);
}

Retrieve grammatical features for 'en-us' language

kotlin

@Test
fun `gets grammatical features for 'en-us' language`() {

    val appId = System.getenv("APP_ID")
    val appKey = System.getenv("APP_KEY")
    val baseUrl = "https://od-api.oxforddictionaries.com/api/v2"

    val oxfordClient = OxfordClient(appId, appKey, baseUrl)

    val query = GrammaticalFeatureMonolingualQuery(
        sourceLanguage = LanguageMonolingual.English_us
    )

    val grammaticalFeature = oxfordClient.grammaticalFeatures(query)
    assertNotNull(grammaticalFeature)
}

java

@Test
@DisplayName("gets grammatical features for 'en-us' language")
void grammaticalFeatures() {

    String appId = System.getenv("APP_ID");
    String appKey = System.getenv("APP_KEY");
    String baseUrl = "https://od-api.oxforddictionaries.com/api/v2";

    OxfordClient oxfordClient = new OxfordClient(appId, appKey, baseUrl);

    GrammaticalFeatureMonolingualQuery query =
            new GrammaticalFeatureMonolingualQuery(LanguageMonolingual.English_us);

    RetrieveGrammaticalFeature grammaticalFeature = oxfordClient.grammaticalFeatures(query);
    assertNotNull(grammaticalFeature);
}

Versions

Version
1.0.8
1.0.7
1.0.6
1.0.4