A simple and consistent lib to query the meaning of words in the Cambridge dictionary.
- Meanings
- Similar words sugestion
- Phonetics
As I had implemented all the basics features but I'm going to enhance the results, performance, and documentation in the next few days.
- Release alfa version
- Add method GetMeaningFromHtmlSource the avoid requests (Development utility)
- Enhence Debug Application to create and read [word].txt files with the source of the web pages the avoid requests (Development utility)
- Setup a simple CI/CD mechanism on Github - (It's only building when something is pushed to master branch at the moment)
- Unit Tests
The lib is finally available on Nuget: https://www.nuget.org/packages/MrBroccoli.CambridgeDictionary.Cli.
You can setup the lib in your DI container as follow and then pass the ICambridgeDictionaryCli
interface in the constructor of your services.
using CambridgeDictionary.Cli.Extensions;
...
serviceCollection.AddCambridgeDictionary();
using CambridgeDictionary.Cli;
...
public class Service {
private readonly _cambridgeDictionaryCli;
public YourService(ICambridgeDictionaryCli cambridgeDictionaryCli) {
_cambridgeDictionaryCli = cambridgeDictionaryCli;
}
...
}
It's just needed to import the lib and then create a new instance of the class CambridgeDictionaryCli
.
using CambridgeDictionary.Cli;
...
var cambridgeDictionary = new CambridgeDictionaryCli();
Currently, the lib has the two methods as follow:
/// <summary>
/// Search for entries of the word in dictionary
/// </summary>
/// <param name="word">The word to be searched.</param>
/// <returns>The information about the word on the dictionary</returns>
EntrySet GetEntry(string word);
/// <summary>
/// Fetch the entries of the word in dictionary directly from a html source
/// </summary>
/// <param name="htmlSource">The html source</param>
/// <returns>The information about the word on the dictionary</returns>
EntrySet GetEntryFromHtmlSource(string htmlSource);
A EntrySet looks like this:
EntrySet - Represts a set of entries of the searched word
{
string Headword - Represents the searched word,
string Headline - Small definition fetched from metatag from web page
[
Entry - Represents an entry in dictionary
{
string Type - The word class,
IPA - International Phonetic Alphabet, the phonetic transcription of the word's pronunciation
{
[
string> UK - UK pronounces,
...
],
[
string US - US pronounces,
...
]
},
[
Senses - A possible meaning of the word
{
string GuideWord - It's a word that helps you find the right meaning when a word has more than one meaning,
[
Definitions - A set of definition of the sense of the word
{
string Text - The definition itself,
[
string Examples - Examples of use of the word in the specific definition,
...
]
}
]
},
...
],
}
],
[
string SimilarWords - Similar words sugestion when the searched word wasn't found,
...
],
string Raw - The raw meaning page
}
ServiceUnreachableExacption
- It's thrown when it wasn't possible to reach the Cambridge site
Text's still in development
I'm lurking this other two project:
- DevSnowflake/camb-dict - project implemented with TypeScript
- qas612820704/cambridge-dictionary - project implemented with JavaScript
This link help me to understand the dictionary anatomy:
- Macmillandictionary - Dictionary anatomy