bchavez / Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Other
8.73k stars 496 forks source link

A random question generator #323

Closed ANF-Studios closed 4 years ago

ANF-Studios commented 4 years ago

Please describe why you are requesting a feature

Bogus has some really cool stuff especially with random, so it'd be cool to have a random topic/question.

Please provide a code example of what you are trying to achieve

var Faker = new Faker(); Console.WriteLine(faker.Random.Question) Or something like that.

Please answer any or all of the questions below

If the feature request is approved, would you be willing to submit a PR?

No

digitalcoyote commented 4 years ago

I'm gonna guess this will get shot down as a feature for bogus, but if you can find a source online for the questions/topics, you could write your own using bogus.

Bogus.Net relies on datasets that generally come from faker.js.

Edit: Possible dataset https://ai.google.com/research/NaturalQuestions

bchavez commented 4 years ago

Hi @ANF-Studios,

Thank you for your feature request. Currently, I don't have any plans to support questions and answers in the main Bogus.dll. Primarily, because, as @digitalcoyote, mentioned,

  1. the main Bogus.dll is usually reserved for faker.js data (with some exceptions) and
  2. the Bogus.dll library is 2MB which is already large.

If this were to get implemented with official support, this type of question/answer data would be included in Bogus.Text as a premium feature. https://github.com/bchavez/Bogus/#bogus-premium-extensions


Alternatively, also as Curtis mentioned, you could extend Bogus with some C# extension methods that generate Q and A with your own data. Below is some sample code that shows how:

void Main()
{
   var f = new Faker();
   var q = f.Random.Question();
   q.Dump();
}

public static class ExtensionsForRandomizer
{
   public static string[] Questions = new string[]{
      "how cold is it today?",
      "are we alone?",
      "what is the meaning of life?"
   };

   public static string Question(this Randomizer r)
   {
      return r.ArrayElement(Questions);
   }
}
what is the meaning of life?