Skip to content

Commit

Permalink
0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 28, 2014
0 parents commit ff66f55
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
bower_components
components
.DS_Store
coverage
*.log
136 changes: 136 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireMultipleVarDecl": true,
"requireBlocksOnNewline": true,
"disallowPaddingNewlinesInBlocks": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowDanglingUnderscores": true,
"requireSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": [
"?",
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireSpaceBeforeBinaryOperators": [
"=",
",",
"+",
"-",
"/",
"*",
"==",
"===",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": [
"=",
",",
"+",
"-",
"/",
"*",
"==",
"===",
"!=",
"!=="
],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"disallowMultipleLineBreaks": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": 78,
"requireCapitalizedConstructors": true,
"safeContextKeyword": "self",
"requireDotNotation": true,
"disallowYodaConditions": true,
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
}
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
bower_components
components
.DS_Store
coverage
*.log
.travis.yml
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: node_js
script: npm run-script test-travis
node_js:
- '0.10'
- '0.11'
after_script: npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls
deploy:
provider: npm
email: tituswormer@gmail.com
api_key:
secure: gIQo++iWR1Lm9hmlCKETx5aTOwQW5wNJGc+xuJbRSsvUE6DQkxXLKZ0eWRyWWc8IyVArV+Nc/4AdeCtPmu6Mlp465gH9/ZzgouqI+1ygE0oFojpJP95I7/KHA3YILBRhaNZDuY+tkk9UzmaGSby6yOz1MoDZHzPEm2Uet/LtxrA=
on:
repo: wooorm/nlcst-to-string
Empty file added History.md
Empty file.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2014 Titus Wormer <tituswormer@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 changes: 70 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# nlcst-to-string [![Build Status](https://img.shields.io/travis/wooorm/nlcst-to-string.svg)](https://travis-ci.org/wooorm/nlcst-to-string) [![Coverage Status](https://img.shields.io/coveralls/wooorm/nlcst-to-string.svg)](https://coveralls.io/r/wooorm/nlcst-to-string?branch=master)

Transform a Natural Language Syntax Tree (NCLST) node into a string

## Installation

npm:
```sh
$ npm install nlcst-to-string
```

Component.js:
```sh
$ component install wooorm/nlcst-to-string
```

Bower:
```sh
$ bower install nlcst-to-string
```

## Usage

````js
var tokenToString = require('nlcst-to-string');

tokenToString({
"type": "WordNode",
"data": {
"partOfSpeech": [
"NNP",
"NN"
]
},
"children": [
{
"type": "TextNode",
"value": "AT"
},
{
"type": "PunctuationNode",
"children": [
{
"type": "TextNode",
"value": "&"
}
]
},
{
"type": "TextNode",
"value": "T"
}
]
});
/*
* "AT&T"
*/
````

## Related

- [parse-latin](https://github.com/wooorm/parse-latin)
- [parse-dutch](https://github.com/wooorm/parse-dutch)
- [parse-english](https://github.com/wooorm/parse-english)
- [retext](https://github.com/wooorm/retext)
- [textom](https://github.com/wooorm/textom)

## License

MIT © Titus Wormer
29 changes: 29 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "nlcst-to-string",
"main": "index.js",
"description": "Transform a Natural Language Syntax Tree (NCLST) node into a string",
"license": "MIT",
"keywords": [
"nlcst",
"to",
"string"
],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/nlcst-to-string.git"
},
"authors": [
"Titus Wormer <tituswormer@gmail.com>"
],
"ignore": [
".*",
"*.log",
"*.md",
"component.json",
"package.json",
"coverage",
"node_modules",
"benchmark",
"spec"
]
}
15 changes: 15 additions & 0 deletions component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "nlcst-to-string",
"version": "0.0.1",
"description": "Transform a Natural Language Syntax Tree (NCLST) node into a string",
"license": "MIT",
"keywords": [
"nlcst",
"to",
"string"
],
"repository": "wooorm/nlcst-to-string",
"scripts" : [
"index.js"
]
}
39 changes: 39 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

/**
* Stringify an NLCST node.
*
* @param {NLCSTNode} nlcst
* @return {string}
*/

function nlcstToString(nlcst) {
var values,
length,
children;

if (nlcst.value) {
return nlcst.value;
}

children = nlcst.children;
length = children.length;

/**
* Shortcut: This is pretty common, and a small performance win.
*/

if (length === 1 && 'value' in children[0]) {
return children[0].value;
}

values = [];

while (length--) {
values[length] = nlcstToString(children[length]);
}

return values.join('');
}

module.exports = nlcstToString;
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "nlcst-to-string",
"version": "0.0.1",
"description": "Transform a Natural Language Syntax Tree (NCLST) node into a string",
"license": "MIT",
"keywords": [
"nlcst",
"to",
"string"
],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/nlcst-to-string.git"
},
"author": "Titus Wormer <tituswormer@gmail.com>",
"devDependencies": {
"eslint": "^0.8.0",
"istanbul": "^0.3.0",
"jscs": "^1.6.0",
"mocha": "^1.21.0"
},
"scripts": {
"test": "node_modules/.bin/_mocha --reporter spec --check-leaks -u exports spec/nlcst-to-string.spec.js",
"test-travis": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --check-leaks -u exports spec/nlcst-to-string.spec.js",
"lint": "npm run-script lint-api && npm run-script lint-test && npm run-script lint-style",
"lint-api": "node_modules/.bin/eslint index.js --env node --env browser --rule 'quotes: [2, single], consistent-return: false'",
"lint-test": "node_modules/.bin/eslint spec/nlcst-to-string.spec.js --env node --env mocha --rule 'quotes: [2, single], no-loop-func: false'",
"lint-style": "node_modules/.bin/jscs index.js spec/nlcst-to-string.spec.js --reporter=inline",
"coverage": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -- spec/nlcst-to-string.spec.js",
"make": "npm run-script lint && npm run-script coverage"
}
}
Loading

0 comments on commit ff66f55

Please sign in to comment.