Git Product home page Git Product logo

ritajs's Introduction

Build Status npm version npm version

RiTa.js: a generative language toolkit for JavaScript

RiTa.js is designed to an easy-to-use toolkit for experiments in natural language and generative literature, based on the original RiTa library for Java. RiTa.js works alone or in conjunction with p5.js, processing.js, node.js, bower, or browserify. All RiTa and RiTa.js tools are free/libre/open-source according to the GPL.

About the project


ย 

A simple sketch


Create a new file on your desktop called 'test.html' and download the latest rita.js from here, add the following lines, save and drag it into a browser:

<html>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="./rita.min.js"></script>
  <script>
    window.onload = function() {
      $('#content').text(RiTa.tokenize("The elephant took a bite!"));
    };
  </script>
  <div id="content" width=200 height=200></div>
<html>

With node.js and npm


To install: $ npm install rita

var rita = require('rita');
var rs = rita.RiString("The elephant took a bite!");
console.log(rs.features());

With p5.js


Create a new file on your desktop called 'test.html' and download the latest rita.js from here, add the following lines, save and drag it into a browser:

<html>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.3/p5.min.js"></script>
  <script src="./rita.min.js"></script>
  <script>
  function setup() {

    createCanvas(200,200);
    background(50);
    textSize(20);
    noStroke();

    var words = RiTa.tokenize("The elephant took a bite!")
    for (var i=0, j = words.length; i<j; i++) {
        text(words[i], 50, 50 + i*20);
    }
  }
  </script>
</html>

With browserify and npm


Install browserify (if you haven't already)

$ sudo npm install -g browserify

Create a file called 'main.js' with the following code:

require('rita');

var rs = RiString("The elephant took a bite!");
console.log(rs.features());

Now install RiTa

$ npm install rita

Now use browserify to pack all the required modules into bundle.js

$ browserify main.js -o bundle.js

Create create a file called 'test.html' with a single script tag as below, then open it in a web browser and check the output in the 'Web Console'

<script src="bundle.js"></script>

With bower


Install bower (if you haven't already)

$ sudo npm install -g bower

Choose a directory and do:

$ bower install rita

Now, create a file called 'test.html', add the following lines, save, and open in a browser:

<html>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="./bower_components/rita/dist/rita.min.js"></script>
  <script>
    window.onload = function() {
      $('#content').text(RiTa.tokenize("The elephant took a bite!"));
    };
  </script>
  <div id="content" width=200 height=200></div>
<html>

Create a new file on your desktop called 'test.html' and download the latest rita.js from here, add the following lines, save and drag it into a browser:

<html>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.8/processing.min.js"></script>
  <script src="./rita.min.js"></script>
  <script type="text/processing" data-processing-target="processing-canvas">
    void setup() {

      size(200,200);
      background(50);
      textSize(20);
      noStroke();

      String words = RiTa.tokenize("The elephant took a bite!");
      for (int i=0, j = words.length; i<j; i++) {
          text(words[i], 50, 50 + i*20);
      }
    }
  </script>
  <canvas id="processing-canvas"> </canvas>
</html>

Can I contribute?


Please! We are looking for more coders to help out... Just press Fork at the top of this github page and get started, or follow the instructions below...

Development Setup


  1. Download and install git, npm, and gulp. If you have them already, move on to step #2.

a. You can find a version of git for your OS here
b. The easiest way to install npm is to install node.js
c. You can install gulp via npm as follows:

  $ npm install -g gulp
  ```
2. [Fork and clone](https://help.github.com/articles/fork-a-repo) this library.

a. First, login to github and fork the project  
b. Then, from a terminal/shell:

  ```bash
  $ git clone https://github.com/dhowe/RiTaJS.git
  ```
3. Now navigate into the project folder and install dependencies via npm.

```bash
$  cd RiTaJS && npm install
  1. To create the library from src, use gulp.
$ gulp build
  1. Run all tests (in phantomJS) with gulp.
$ gulp test
  1. Work on an existing issue, then submit a pull request...

ritajs's People

Contributors

cqx931 avatar cyrussuen avatar dhowe avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.