Decentralized Node.JS Sentiment Algorithm for Computes

@ChrisMatthieu
computes
Published in
2 min readMay 25, 2018

Computes allows developers to write decentralized apps (DApps), AI algorithms, and high performance computing models in any programming language and run them everywhere as a software-defined supercomputer. Since most of our examples are written in Golang, I wanted to write a new one in Node.JS and it turned out to be easier than I thought! Here’s the results of the “I love skynet” sentiment analysis :)

Computes simply leverages STDIN for input files and uses STDOUT for outputting JSON responses in and out of Lattice. Good news, all programming languages support this model. For fun, I decided to write a simple Node.JS app that performs sentiment analysis based on word scoring. Here’s the example computes-sentiment repo on GitHub.

The magic stdin and stdout handling happens in the first 9 lines of code.

Once your app or algorithm receives the input file or data, it can hand it off to the compute in another function which returns the JSON data back to the STDOUT which returns the results back to the Lattice ledger.

As illustrated in our automated bash script, the Computes task manifest file looks like this:

The Computes results return as follows:

For developers who have not already jumped head-first into Docker, here’s a good walkthrough on “dockerizing” your new Node.JS algorithm to run on Computes. You can test your docker app before running it through Computes as follows:

echo “i love skynet” | docker run -i computes/computes-sentiment:latest

Happy supercomputing!

Learn more about the Computes vision. Learn more about the Computes architecture. Join our beta program and start mesh computing today!

Stay tuned to this blog for more exciting information about our new technology stack and development progress! You can also reach us on Twitter, Facebook, and GitHub.

--

--

@ChrisMatthieu
computes

Builder of companies, robots, supercomputers, & motorcycles. @xrpanet & @twelephone CEO. Formerly @magicleap @computesio @citrix @octoblu @nodester @teleku