-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff66f55
Showing
12 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
bower_components | ||
components | ||
.DS_Store | ||
coverage | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Oops, something went wrong.