MrBroccoli.CambridgeDictionary.Cli 1.1.0-alpha

This is a prerelease version of MrBroccoli.CambridgeDictionary.Cli.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MrBroccoli.CambridgeDictionary.Cli --version 1.1.0-alpha                
NuGet\Install-Package MrBroccoli.CambridgeDictionary.Cli -Version 1.1.0-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MrBroccoli.CambridgeDictionary.Cli" Version="1.1.0-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MrBroccoli.CambridgeDictionary.Cli --version 1.1.0-alpha                
#r "nuget: MrBroccoli.CambridgeDictionary.Cli, 1.1.0-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MrBroccoli.CambridgeDictionary.Cli as a Cake Addin
#addin nuget:?package=MrBroccoli.CambridgeDictionary.Cli&version=1.1.0-alpha&prerelease

// Install MrBroccoli.CambridgeDictionary.Cli as a Cake Tool
#tool nuget:?package=MrBroccoli.CambridgeDictionary.Cli&version=1.1.0-alpha&prerelease                

CambridgeDictionary 📖:books:

A simple and consistent lib to query the meaning of words in the Cambridge dictionary.

Dependencies

ScrapySharp

Features I mind implement

  • 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.

Next Steps

  • 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

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

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   
}

Debug Tools

Runner

Text's still in development

I'm lurking this other two project:

This link help me to understand the dictionary anatomy:

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 404 7/4/2021
1.1.0-alpha 354 7/4/2021
1.0.1-alpha 250 7/1/2021

New Features
- It's no longer necessary to instantiate a ServiceCollection to use the lib
- Added GetEntryFromHtmlSource

Bugfixes
- Guide Word no longer presents many spaces at the beginning and the end

Breaking Changes
- Meaning modeling was re-elaborated and changed to EntrySet