CambridgeDictionary
Porting a crawler to CSharp
Install / Use
/learn @Michael-Santos/CambridgeDictionaryREADME
CambridgeDictionary :book::books:
A simple and consistent lib to query the meaning of words in the Cambridge dictionary.
Dependencies
Features I mind implement
- [x] Meanings
- [x] Similar words sugestion
- [x] 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.
Next Steps
- [x] Release alfa version
- [x] Add method GetMeaningFromHtmlSource the avoid requests (Development utility)
- [x] 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
Nuget
The lib is finally available on Nuget: https://www.nuget.org/packages/MrBroccoli.CambridgeDictionary.Cli.
Setup
DI
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;
}
...
}
Without DI
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();
Usage
Methods
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);
Return
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
}
Exceptions
ServiceUnreachableExacption - It's thrown when it wasn't possible to reach the Cambridge site
Debug Tools (For this project)
Runner
Text's still in development
Links
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
Related Skills
node-connect
341.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
