Skip to content

NL Query (Langage Naturel)

Principe

Le module NaturalQuery transforme des phrases en francais ou anglais en requetes LINQ executables.

Configuration

csharp
builder.Services.AddRvrNaturalQuery(options =>
{
    options.SupportedLanguages = ["fr", "en"];
    options.DefaultLanguage = "fr";
    options.EnableCaching = true;
});

Utilisation

csharp
// Francais
var results = await _nlQuery.QueryAsync<Product>(
    "produits actifs prix superieur a 100 tries par nom decroissant"
);

// Anglais
var results = await _nlQuery.QueryAsync<Product>(
    "active products with price above 100 sorted by name descending"
);

Operateurs supportes

FrancaisAnglaisLINQ
superieur a, plus deabove, greater than>
inferieur a, moins debelow, less than<
egal aequal to==
contientcontains.Contains()
commence parstarts with.StartsWith()
trie parsorted by, order by.OrderBy()
limite alimit to.Take()

API REST

bash
curl "http://localhost:5220/api/v1/natural-query?entity=Product&q=produits%20actifs%20prix%20%3E%20100" \
  -H "Authorization: Bearer <token>"

Released under the MIT License.