npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dazzling-fiction

v0.6.0

Published

Fictional facts generator based on a markdown fiction dialect

Downloads

26

Readme

NPM version Build Status Dependency Status

Fictional facts generator based on a markdown fiction dialect

The fiction markdown dialect facilitates the creation of set of fictional (fake) data. The output is a list of statements or facts, in which each fact is represented as subject-predicate-object format. However the object is not limited to one column and could be used in the same way as datalog. The generated data is randomly created but in a predictable and repeatable manner.

The main purpose of this dialect is to experiment with different data samples which conform to a particular structure.

Install

$ npm install --save dazzling-fiction

Usage

$ npm install --global dazzling-fiction
$ fict --help

Examples

Generate CSV

cat LICENSE |  fict run '2 of `Vegetable`' recipe "test/fixtures"

Will output:

"ingredient","child-of-fiction-model","secret-spice"
"olive-oil","child-of-fiction-model","sauce"
"pepper","child-of-fiction-model","sauce"
"diced-onion","child-of-fiction-model","sauce"
"spice:Garlic/wild","child-of-fiction-model","sauce"
"spice:Garlic/black","child-of-fiction-model","sauce"
"chilli","child-of-fiction-model","sauce"
"secret","child-of-fiction-model","sauce"
"spoon-of","child-of-fiction-model","sauce"
"meat-type","child-of-fiction-model","meat"
"sauce","child-of-fiction-model","meat"
"vegetable-mix","child-of-fiction-model","vegetable"
"sauce","child-of-fiction-model","vegetable"
"topping","child-of-fiction-model","dessert"
"starter","child-of-fiction-model","meal"
"main-meat","child-of-fiction-model","meal"
"main-vegetable","child-of-fiction-model","meal"
"dessert","child-of-fiction-model","meal"
"a-vegetable-1-1","vegetable-mix","turnip"
"a-vegetable-1-1","vegetable-mix","potato"
"a-sauce-3-1","pepper","2","teaspoon"
"a-sauce-3-1","diced-onion","2"
"a-sauce-3-1","chilli","false"
"a-sauce-3-1","secret","ref-a-secret"
"a-sauce-3-1","spoon-of","cognac"
"a-sauce-3-1","spoon-of","armagnac"
"a-vegetable-2-2","vegetable-mix","carrot"
"a-vegetable-2-2","sauce","a-sauce-3-1"
"ref-a-secret","ingredient","lemon"
"ref-a-secret","ingredient","orange"

Generate JSON

cat LICENSE |  fict run '2 of `Vegetable`' recipe "test/fixtures" -o json -p beautiful

Concerning the optional parameter -p or --print:

  • machine: Format the output in a compact manner easily readable by a machine.
  • beautiful: Format the output in a beautiful manner.
  • outline: Format the output with the main outlines.

Will output

[
 {"i": "a-ingredient-4",
  "s": "ingredient",
  "p": "child-of-fiction-model",
  "o": [
   "secret-spice"
  ]
 },
 {
  "i": "a-olive-oil-5",
  "s": "olive-oil",
  "p": "child-of-fiction-model",
  "o": [
   "sauce"
  ]
 },
 {
  "i": "a-pepper-6",
  "s": "pepper",
  "p": "child-of-fiction-model",
  "o": [
   "sauce"
  ]
 },
{"i":"a-diced-onion-7","s":"diced-onion","p":"child-of-fiction-model","o":["sauce"]},
{"i":"a-spice:Garlic/wild-8","s":"spice:Garlic/wild","p":"child-of-fiction-model","o":["sauce"]},
{"i":"a-spice:Garlic/black-9","s":"spice:Garlic/black","p":"child-of-fiction-model","o":["sauce"]},
{"i":"a-chilli-10","s":"chilli","p":"child-of-fiction-model","o":["sauce"]},
{"i":"a-secret-11","s":"secret","p":"child-of-fiction-model","o":["sauce"]},
{"i":"a-spoon-of-12","s":"spoon-of","p":"child-of-fiction-model","o":["sauce"]},
{"i":"a-meat-type-13","s":"meat-type","p":"child-of-fiction-model","o":["meat"]},
{"i":"a-sauce-14","s":"sauce","p":"child-of-fiction-model","o":["meat"]},
{"i":"a-vegetable-mix-15","s":"vegetable-mix","p":"child-of-fiction-model","o":["vegetable"]},
{"i":"a-sauce-16","s":"sauce","p":"child-of-fiction-model","o":["vegetable"]},
{"i":"a-topping-17","s":"topping","p":"child-of-fiction-model","o":["dessert"]},
{"i":"a-starter-18","s":"starter","p":"child-of-fiction-model","o":["meal"]},
{"i":"a-main-meat-19","s":"main-meat","p":"child-of-fiction-model","o":["meal"]},
{"i":"a-main-vegetable-20","s":"main-vegetable","p":"child-of-fiction-model","o":["meal"]},
{"i":"a-dessert-21","s":"dessert","p":"child-of-fiction-model","o":["meal"]},
{"s":"a-vegetable-1-1","p":"vegetable-mix","o":["turnip"]},
{"s":"a-vegetable-1-1","p":"vegetable-mix","o":["potato"]},
{"s":"a-sauce-3-1","p":"pepper","o":[2,"teaspoon"]},
{"s":"a-sauce-3-1","p":"diced-onion","o":[2]},
{"s":"a-sauce-3-1","p":"chilli","o":[false]},
{"s":"a-sauce-3-1","p":"secret","o":["ref-a-secret"]},
{"s":"a-sauce-3-1","p":"spoon-of","o":["cognac"]},
{"s":"a-sauce-3-1","p":"spoon-of","o":["armagnac"]},
{"s":"a-vegetable-2-2","p":"vegetable-mix","o":["carrot"]},
{"s":"a-vegetable-2-2","p":"sauce","o":["a-sauce-3-1"]},
{"s":"ref-a-secret","p":"ingredient","o":["lemon"]},
{"s":"ref-a-secret","p":"ingredient","o":["orange"]}
]

Features of the fiction dialect

The fiction dialect supports the following features:

  • Import
  • Weighting
  • Frequency
  • Models and references
  • Lists
  • Mappings

Import

The fiction dialect allow a fiction script to reference another.

Example:

## Import

* another-script
* more-script

Weighting

Weighting allows to introduce a bias to favor some values against others.

Example of declaration:

## Weighting

* ** experimental **  1,2,4,8,16

Frequency

The frequency allows to decide how likely it is that an attribute will exist.

Example of declaration:

## Frequency

* **Never, Rarely, Occasionally, Sometimes, Often, Usually, Always** 0,1,2,3,4,5,6

Example of usage:

* **Diced onion** often ; *1,2,5*

Models and references

You can represent subject-predicate-object relationships in the models section. The subject is declared as a title while the predicate-objects are a list.

Example:

## Models

### Meat

* **meat type** *pork,beef,chicken*
* **sauce** usually; `sauce`

References are models that can be accessed by name.

## References

* **secret** 2 of `Secret spice`

Lists

Fiction scripts rely often on lists to generate fictional data. You can create re-usable lists by declaring them in a list section.

Lists can be loaded from files or from local web services. They can be stored as a JSON array or as a text with each row on a different line. Alternatively, the format mostly used by corpora is also supported (see male-first-name.json). The markdown syntax should be unaware of the exact location of the document.

Example of list declaration:

## Lists

* **male first name** `json-doc:male-first-name`

Example of use:

* **first name** `male first name`

Mappings

Mappings are used to create short aliases. They can be loaded from files or from local web services.

The markdown syntax should be unaware of the exact location of the document.

Example of mapping declaration:

## Mappings

* **title** `json-doc:title`

Example of use:

* **sex** *female*; `title:dr`

For an internal representation of:

{
	"dr": ["Doctor",{"fr": "Docteur"}]
}

License

MIT © Olivier Huin