Skip to content

Commit

Permalink
Changed name of method FetchWordsAsync.
Browse files Browse the repository at this point in the history
Update Readme.
Change version to v1.1.1.
  • Loading branch information
josago97 committed Jul 27, 2023
1 parent 7af5320 commit b5b51ce
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 35 deletions.
22 changes: 6 additions & 16 deletions RAE.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using RAE.Models;

namespace RAE.Demo
{
Expand All @@ -12,11 +10,10 @@ class Program

static Func<Task>[] functions =
{
FetchWordsAsync,
FetchWordAsync,
GetKeysAsync,
SearchWordAsync,
WordOfTheDayAsync,
FetchRandomWorldAsync,
GetWordOfTheDayAsync,
GetRandomWorldAsync,
GetWordsStartWithAsync,
GetWordsContainAsync,
Expand All @@ -39,13 +36,13 @@ static async Task Main()
Console.ReadLine();
}

static async Task FetchWordsAsync()
static async Task FetchWordAsync()
{
string[] wordsToFetch = { "y", "tonto", "niño", "en", "manada" };

foreach (string wordToFetch in wordsToFetch)
{
IList<IWord> words = await drae.FetchWordsAsync(wordToFetch);
IList<IWord> words = await drae.FetchWordAsync(wordToFetch);

foreach (IWord word in words)
{
Expand All @@ -58,7 +55,7 @@ static async Task FetchWordsAsync()

static async Task GetKeysAsync()
{
string query = "w";
string query = "hola";
string[] keys = await drae.GetKeysAsync(query);

Console.WriteLine($"GetKeys ({query}): {string.Join(", ", keys)}");
Expand All @@ -72,7 +69,7 @@ static async Task SearchWordAsync()
Console.WriteLine($"SearchWord ({query}): {string.Join<IEntry>(", ", entries)}");
}

static async Task WordOfTheDayAsync()
static async Task GetWordOfTheDayAsync()
{
IEntry word = await drae.GetWordOfTheDayAsync();

Expand All @@ -86,13 +83,6 @@ static async Task GetRandomWorldAsync()
Console.WriteLine($"A random word: {word}");
}

static async Task FetchRandomWorldAsync()
{
IWord word = await drae.GetRandomWordAsync();

Console.WriteLine(word);
}

static async Task GetWordsStartWithAsync()
{
string character = "A";
Expand Down
8 changes: 4 additions & 4 deletions RAE.Tests/DRAE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ public class DRAE
[InlineData("niño")]
[InlineData("tonto")]
[InlineData("y")]
public async Task FetchWordsExist(string word)
public async Task FetchWordExist(string word)
{
IList<IWord> words = await Drae.FetchWordsAsync(word);
IList<IWord> words = await Drae.FetchWordAsync(word);

Assert.NotNull(words);
Assert.NotEmpty(words);
}

[Theory]
[InlineData("asdadasdada")]
public async Task FetchWordsNoExist(string word)
public async Task FetchWordNoExist(string word)
{
IList<IWord> words = await Drae.FetchWordsAsync(word);
IList<IWord> words = await Drae.FetchWordAsync(word);

Assert.NotNull(words);
Assert.Empty(words);
Expand Down
2 changes: 1 addition & 1 deletion RAE/DRAE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public DRAE()
/// <para>The word to search.</para>
/// <para>La palabra a buscar.</para>
/// </param>
public async Task<IWord[]> FetchWordsAsync(string word)
public async Task<IWord[]> FetchWordAsync(string word)
{
IEntry[] entries = await _raeAPI.SearchWordAsync(word, true);
List<IWord> result = new List<IWord>(entries.Length);
Expand Down
2 changes: 1 addition & 1 deletion RAE/RAE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/josago97/RAE.NET</RepositoryUrl>
<PackageTags>RAE, Diccionario, España, Español, Lengua, Dictionary, Spain, Spanish, Language</PackageTags>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
123 changes: 110 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,117 @@

[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/josago97/RAE.NET/blob/master/LICENSE) [![NuGet version (RAE.NET)](https://img.shields.io/nuget/v/RAE.NET.svg)](https://www.nuget.org/packages/RAE.NET/) [![Downloads](https://img.shields.io/nuget/dt/RAE.NET.svg)](https://www.nuget.org/packages/RAE.NET/)

**[Español]** (English below)

Esta es una biblioteca no oficial que te permite:
- Buscar palabras clave.
- Obtener definiciones de palabras.
- Obtener la palabra del día.
- Obtener palabras aleatorias.
<br>
This is an unofficial library that allows you to:

---------------------------------------

**[English]**
- Obtener definiciones de una palabra.
<br>
Get definitions of a word.

This is an unofficial library that allows you to:
- Search for keywords.
- Get definitions of words.
- Get random words.
- Get the word of the day.
```cs
DRAE drae = new DRAE();
IWord[] words = await drae.FetchWordAsync("casa");

foreach (IWord word in words)
{
Console.WriteLine(word);
}
```
<br>

Obtener definiciones de una palabra por identificador.
<br>
Get definitions of a word by id.

```cs
DRAE drae = new DRAE();
IWord word = await drae.FetchWordByIdAsync("7lsKMtR");

Console.WriteLine(word);
```
<br>

Obtener la palabra del día.
<br>
Get the word of the day.

```cs
DRAE drae = new DRAE();
IEntry entry = await drae.GetWordOfTheDayAsync();

Console.WriteLine(entry);
```
<br>

Obtener una palabra aleatoria.
<br>
Get a random word.

```cs
DRAE drae = new DRAE();
IWord word = await drae.GetRandomWordAsync();

Console.WriteLine(word);
```
<br>

Buscar las entradas de una palabra.
<br>
Search the entries of a word.

```cs
DRAE drae = new DRAE();
IEntry[] entries = await drae.SearchWordAsync("y");

Console.WriteLine(string.Join(", ", entries));
```
<br>

Buscar palabras clave.
<br>
Search for keywords.

```cs
DRAE drae = new DRAE();
string[] keys = await drae.GetKeysAsync("hola");

Console.WriteLine(string.Join(", ", keys));
```
<br>

Obtener todas las palabras que comienzan con una cadena.
<br>
Get all words that start with a string.

```cs
DRAE drae = new DRAE();
string[] words = await drae.GetWordsStartWithAsync("sa");

Console.WriteLine(string.Join(", ", words));
```
<br>

Obtener todas las palabras que continenen una cadena.
<br>
Get all words that contain a string.

```cs
DRAE drae = new DRAE();
string[] words = await drae.GetWordsContainAsync("sa");

Console.WriteLine(string.Join(", ", words));
```
<br>

Obtener todas las palabras del diccionario.
<br>
Get all word of the dictionary.

```cs
DRAE drae = new DRAE();
string[] allWords = await drae.GetAllWordsAsync();

Console.WriteLine(string.Join(", ", allWords));
```

0 comments on commit b5b51ce

Please sign in to comment.