Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 14, 2021
1 parent af47a96 commit 5ae9a9f
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 64 deletions.
4 changes: 4 additions & 0 deletions packages/franc-all/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ usage information.

## Install

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be
`import`ed instead of `require`d.

npm:

```sh
Expand Down
3 changes: 3 additions & 0 deletions packages/franc-cli/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and usage information.

## Install

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it.

npm:

```sh
Expand Down
4 changes: 4 additions & 0 deletions packages/franc-min/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ usage information.

## Install

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be
`import`ed instead of `require`d.

npm:

```sh
Expand Down
4 changes: 4 additions & 0 deletions packages/franc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ usage information.

## Install

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be
`import`ed instead of `require`d.

npm:

```sh
Expand Down
47 changes: 31 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Make sure to pass it big documents to get reliable results.

## Install

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.

[npm][]:

```sh
Expand All @@ -40,8 +43,11 @@ available on [GitHub Releases][releases].

## Use

This package exports the following identifiers: `franc`, `francAll`.
There is no default export.

```js
var franc = require('franc')
import {franc, francAll} from 'franc'

franc('Alle menslike wesens word vry') // => 'afr'
franc('এটি একটি ভাষা একক IBM স্ক্রিপ্ট') // => 'ben'
Expand All @@ -57,47 +63,56 @@ franc('the', {minLength: 3}) // => 'sco'
###### `.all`

```js
console.log(franc.all('O Brasil caiu 26 posições'))
console.log(francAll('Considerando ser essencial que os direitos humanos'))
```

Yields:

```js
[ [ 'por', 1 ],
[ 'src', 0.8797557538750587 ],
[ 'glg', 0.8708313762329732 ],
[ 'snn', 0.8633161108501644 ],
[ 'bos', 0.8172851103804604 ],
... 116 more items ]
[
[ 'por', 1 ],
[ 'glg', 0.771284519307895 ],
[ 'spa', 0.6034146900423971 ],
[ 'cat', 0.5367251059928957 ],
[ 'src', 0.47461899851037015 ],
... 122 more items ]
```

###### `only`

```js
console.log(franc.all('O Brasil caiu 26 posições', {only: ['por', 'spa']}))
console.log(
francAll('Considerando ser essencial que os direitos humanos', {
only: ['por', 'spa']
})
)
```

Yields:

```js
[ [ 'por', 1 ], [ 'spa', 0.799906059182715 ] ]
[ [ 'por', 1 ], [ 'spa', 0.6034146900423971 ] ]
```

###### `ignore`

```js
console.log(franc.all('O Brasil caiu 26 posições', {ignore: ['src', 'glg']}))
console.log(
francAll('Considerando ser essencial que os direitos humanos', {
ignore: ['src', 'glg']
})
)
```

Yields:

```js
[ [ 'por', 1 ],
[ 'snn', 0.8633161108501644 ],
[ 'bos', 0.8172851103804604 ],
[ 'hrv', 0.8107092531705026 ],
[ 'lav', 0.810239549084077 ],
... 114 more items ]
[ 'spa', 0.6034146900423971 ],
[ 'cat', 0.5367251059928957 ],
[ 'ita', 0.4740460639394981 ],
[ 'fra', 0.44757648676521145 ],
... 120 more items ]
```

## CLI
Expand Down
113 changes: 65 additions & 48 deletions script/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,25 @@ async function main() {
depth: 2,
children: [{type: 'text', value: 'Install'}]
},
{
type: 'paragraph',
children: [
{type: 'text', value: 'This package is '},
{
type: 'link',
url: 'https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c',
children: [{type: 'text', value: 'ESM only'}]
},
{
type: 'text',
value: ':\nNode 12+ is needed to use it and it must be\n'
},
{type: 'inlineCode', value: 'import'},
{type: 'text', value: 'ed instead of '},
{type: 'inlineCode', value: 'require'},
{type: 'text', value: 'd.'}
]
},
{type: 'paragraph', children: [{type: 'text', value: 'npm:'}]},
{type: 'code', lang: 'sh', value: 'npm install ' + pack.name},
{
Expand Down Expand Up @@ -409,7 +428,52 @@ async function main() {
}
]
},
...list.map((d) => row(d))
...list.map((info) => ({
type: 'tableRow',
children: [
{
type: 'tableCell',
children: [
{
type: 'link',
url:
'http://www-01.sil.org/iso639-3/documentation.asp?id=' +
info.code,
title: null,
children: [{type: 'inlineCode', value: info.code}]
}
]
},
{
type: 'tableCell',
children: [
{
type: 'text',
value:
info.name +
(counts[info.code] === 1
? ''
: ' (' + info.script + ')')
}
]
},
{
type: 'tableCell',
children: [
{
type: 'text',
value:
typeof info.speakers === 'number'
? info.speakers.toLocaleString('en', {
notation: 'compact',
maximumFractionDigits: 0
})
: 'unknown'
}
]
}
]
}))
]
},
{
Expand Down Expand Up @@ -437,53 +501,6 @@ async function main() {
}

return unified().use(stringify).use(gfm).stringify(tree)

function row(info) {
return {
type: 'tableRow',
children: [
{
type: 'tableCell',
children: [
{
type: 'link',
url:
'http://www-01.sil.org/iso639-3/documentation.asp?id=' +
info.code,
title: null,
children: [{type: 'inlineCode', value: info.code}]
}
]
},
{
type: 'tableCell',
children: [
{
type: 'text',
value:
info.name +
(counts[info.code] === 1 ? '' : ' (' + info.script + ')')
}
]
},
{
type: 'tableCell',
children: [
{
type: 'text',
value:
typeof info.speakers === 'number'
? info.speakers.toLocaleString('en', {
notation: 'compact',
maximumFractionDigits: 0
})
: 'unknown'
}
]
}
]
}
}
}

function count(list) {
Expand Down

0 comments on commit 5ae9a9f

Please sign in to comment.