New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

phraser

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phraser

A small natural language generator. Makes words reads goods.

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

phraser

phraser npm

Early stages of development, please prepare for large amounts of changes until version 1.0.0.

A small natural language generator. Makes words reads goods.

  • API Documentation

Phraser allows you to construct sentences using a syntax similar to sentence syntax trees, and render these to arrays of strings. Right now the development focus is on the lowest layer of language generation, which allows sentences to be defined by their sentence structure. This enforces basic grammar rules about valid word orders, pluralisation, verb tense / aspect / person / number and simple punctuation.

Use Foxtype to help visualise sentences in terms of their structure.

Over time this will be supported by lexicons so irregular verbs and pluralisations don't have to be manually provided. Then all this will form a solid base for a second layer of opinionated sentence constructors that will be able to take data and output sentence structures.

Example usage

import {Constituent} from 'phraser';
const {Sentence, Clause, NP, PP, VP} = Constituent(Lexicon);

const sentence = Sentence(
    Clause(
        NP("dog").quantity(3).determiner("those"),
        VP("ate", NP("food")).adverb("quickly", "middle")
    ).modifier(
        PP("from", NP("trash can").a().adjective("huge"))
    )
);

console.log(sentence.renderString());

// outputs "Those 3 dogs quickly ate food from a huge trash can."

FAQs

Package last updated on 11 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts