Jaccard Similarity Coefficient Index Stream Transform
var JaccardStream = ;var logs ="item1" "user1""item1" "user2""item2" "user2""item2" "user3""item2" "user4""item3" "user1""item3" "user2""item3" "user5";var jaccard = ;jaccard;jaccard;logs;jaccard; // end of input
Stream Model: Log CSV to Links CSV
var JaccardStream = ;var fs = ;var csv = ;var read = fs;var parse = csv;var jaccard = ;var stringify = csv;var write = fs;read;
Stream Model: Log JSON to Links JSON
var JaccardStream = ;var fs = ;var ndjson = ;var read = fs;var parse = ndjson;var jaccard = ;var stringify = ndjson;var write = fs;read;
$ npm install jaccard-stream csv ndjson $ PATH=./node_modules/.bin:$PATH $ jaccard-stream -h Usage: jaccard-stream [-CTJctjNnh] [input] [output] C: input is CSV file (comma separated values) T: input is TSV file (tab separated values) J: input is newline-delimited JSON stream (ndjson) c: output is CSV file t: output is TSV file j: output is newline-delimited JSON stream (ndjson) N: detect column names from the first line of input CSV n: output with named columns h: show this message
Try it with sample files:
$ jaccard-stream -CNcn sample/with-header.csv$ jaccard-stream -Cc sample/without-header.csv$ jaccard-stream -Jj sample/array-stream.json$ jaccard-stream -Jjn sample/object-stream.json
Copyright (c) 2016 Yusuke Kawasaki
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.