Skip to content

wooorm/parse-dutch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

parse-dutch

Build Coverage Downloads Size

Natural language parser, for the Dutch language, that produces nlcst.

Contents

What is this?

This package exposes a parser that takes Dutch natural language and produces a syntax tree.

When should I use this?

If you want to handle Dutch natural language as syntax trees manually, use this.

Alternatively, you can use the retext plugin retext-dutch, which wraps this project to also parse natural language at a higher-level (easier) abstraction.

For English or most Latin-script languages, you can instead use parse-english or parse-latin.

Install

This package is ESM only. In Node.js (version 16.0+), install with npm:

npm install parse-dutch

In Deno with esm.sh:

import {ParseDutch} from 'https://esm.sh/parse-dutch@7'

In browsers with esm.sh:

<script type="module">
  import {ParseDutch} from 'https://esm.sh/parse-dutch@7?bundle'
</script>

Use

import {inspect} from 'unist-util-inspect'
import {ParseDutch} from 'parse-dutch'

const tree = new ParseDutch().parse(
  'Kunt U zich ’s morgens melden bij het afd. hoofd dhr. Venema?'
)

console.log(inspect(tree))

Yields:

RootNode[1] (1:1-1:62, 0-61)
└─0 ParagraphNode[1] (1:1-1:62, 0-61)
    └─0 SentenceNode[24] (1:1-1:62, 0-61)
        β”œβ”€0  WordNode[1] (1:1-1:5, 0-4)
        β”‚    └─0 TextNode "Kunt" (1:1-1:5, 0-4)
        β”œβ”€1  WhiteSpaceNode " " (1:5-1:6, 4-5)
        β”œβ”€2  WordNode[1] (1:6-1:7, 5-6)
        β”‚    └─0 TextNode "U" (1:6-1:7, 5-6)
        β”œβ”€3  WhiteSpaceNode " " (1:7-1:8, 6-7)
        β”œβ”€4  WordNode[1] (1:8-1:12, 7-11)
        β”‚    └─0 TextNode "zich" (1:8-1:12, 7-11)
        β”œβ”€5  WhiteSpaceNode " " (1:12-1:13, 11-12)
        β”œβ”€6  WordNode[2] (1:13-1:15, 12-14)
        β”‚    β”œβ”€0 PunctuationNode "’" (1:13-1:14, 12-13)
        β”‚    └─1 TextNode "s" (1:14-1:15, 13-14)
        β”œβ”€7  WhiteSpaceNode " " (1:15-1:16, 14-15)
        β”œβ”€8  WordNode[1] (1:16-1:23, 15-22)
        β”‚    └─0 TextNode "morgens" (1:16-1:23, 15-22)
        β”œβ”€9  WhiteSpaceNode " " (1:23-1:24, 22-23)
        β”œβ”€10 WordNode[1] (1:24-1:30, 23-29)
        β”‚    └─0 TextNode "melden" (1:24-1:30, 23-29)
        β”œβ”€11 WhiteSpaceNode " " (1:30-1:31, 29-30)
        β”œβ”€12 WordNode[1] (1:31-1:34, 30-33)
        β”‚    └─0 TextNode "bij" (1:31-1:34, 30-33)
        β”œβ”€13 WhiteSpaceNode " " (1:34-1:35, 33-34)
        β”œβ”€14 WordNode[1] (1:35-1:38, 34-37)
        β”‚    └─0 TextNode "het" (1:35-1:38, 34-37)
        β”œβ”€15 WhiteSpaceNode " " (1:38-1:39, 37-38)
        β”œβ”€16 WordNode[2] (1:39-1:43, 38-42)
        β”‚    β”œβ”€0 TextNode "afd" (1:39-1:42, 38-41)
        β”‚    └─1 PunctuationNode "." (1:42-1:43, 41-42)
        β”œβ”€17 WhiteSpaceNode " " (1:43-1:44, 42-43)
        β”œβ”€18 WordNode[1] (1:44-1:49, 43-48)
        β”‚    └─0 TextNode "hoofd" (1:44-1:49, 43-48)
        β”œβ”€19 WhiteSpaceNode " " (1:49-1:50, 48-49)
        β”œβ”€20 WordNode[2] (1:50-1:54, 49-53)
        β”‚    β”œβ”€0 TextNode "dhr" (1:50-1:53, 49-52)
        β”‚    └─1 PunctuationNode "." (1:53-1:54, 52-53)
        β”œβ”€21 WhiteSpaceNode " " (1:54-1:55, 53-54)
        β”œβ”€22 WordNode[1] (1:55-1:61, 54-60)
        β”‚    └─0 TextNode "Venema" (1:55-1:61, 54-60)
        └─23 PunctuationNode "?" (1:61-1:62, 60-61)

API

This package exports the identifier ParseDutch. There is no default export.

ParseDutch()

Create a new parser.

ParseDutch extends ParseLatin. See parse-latin for API docs.

Algorithm

All of parse-latin is included, and the following support for the Dutch natural language:

  • unit and time abbreviations (gr., sec., min., ma., vr., vrij., febr., mrt., and more)
  • lots of abbreviations: (Mr., Mv., Sr., Em., bijv., zgn., amb., and more)
  • common elision (omission of letters) (d’, ’n, ’ns, ’t, ’s, ’er, ’em, ’ie, and more)

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

Projects maintained by me are compatible with maintained versions of Node.js.

When I cut a new major release, I drop support for unmaintained versions of Node. This means I try to keep the current release line, parse-dutch@^7, compatible with Node.js 16.

Security

This package is safe.

Related

Contribute

Yes please! See How to Contribute to Open Source.

License

MIT Β© Titus Wormer