<commit_before>Reference Manual
=====
### Table of contents
------
* [Local Setup](reference.md#setup)
* [Cloud Setup](reference.md#setup)
* [Rules](reference.md#rules)
  * [Simple Filter](reference.md#simple-filter)
  * [Correlated Sequence](reference.md#correlated-sequence)
  * [Choice of Sequences](reference.md#choice-of-sequences)
  * [Conflict Resolution](reference.md#conflict-resolution)
  * [Tumbling Window](reference.md#tumbling-window)
* [Data Model](reference.md#data-model)
  * [Events](reference.md#events)
  * [Facts](reference.md#facts)
  * [Context](reference.md#context)
  * [Timers](reference.md#timers) 
* [Flow Structures](reference.md#flow-structures)
  * [Statechart](reference.md#statechart)
  * [Nested States](reference.md#nested-states)
  * [Flowchart](reference.md#flowchart)
  * [Parallel](reference.md#parallel)  

### Local Setup
------
durable_rules has been tested in MacOS X, Ubuntu Linux and Windows.
#### Redis install
durable.js relies on Redis version 2.8  
 
_Mac_  
1. Download [Redis](http://download.redis.io/releases/redis-2.8.4.tar.gz)   
2. Extract code, compile and start Redis

For more information go to: http://redis.io/download  

_Windows_  
1. Download Redis binaries from [MSTechOpen](https://github.com/MSOpenTech/redis/releases)  
2. Extract binaries and start Redis  

For more information go to: https://github.com/MSOpenTech/redis  

Note: To test applications locally you can also use a Redis [cloud service](reference.md#cloud-setup) 

#### First App
Now that your cache and web server are ready, let's write a simple rule:  

1. Start a terminal  
2. Create a directory for your app: `mkdir firstapp` `cd firstapp`  
3. In the new directory `sudo pip install durable_rules` (this will download durable_rules and its dependencies)  
4. In that same directory create a test.py file using your favorite editor  
5. Copy/Paste and save the following code:
  ```python
  from durable.lang import *
  with ruleset('test'):
      @when_all(m.subject == 'World')
      def say_hello(c):
          print ('Hello {0}'.format(c.m.subject))

      @when_start
      def start(host):
          host.post('test', {'id': 1, 'sid': 1, 'subject': 'World'})

  run_all()
  ```
7. In the terminal type `python test.py`  
8. You should see the message: `Hello World`  

Note: If you are using [Redis To Go](https://redistogo.com), replace the last line.
  ```python
  d.runAll([{'host': 'hostName', 'port': port, 'password': 'password'}]);
  ```

[top](reference.md#table-of-contents) 
### Cloud Setup
--------
#### Redis install<commit_msg>Update reference.md<commit_after>Reference Manual
=====
### Table of contents
------
* [Local Setup](reference.md#setup)
* [Cloud Setup](reference.md#setup)
* [Rules](reference.md#rules)
  * [Simple Filter](reference.md#simple-filter)
  * [Correlated Sequence](reference.md#correlated-sequence)
  * [Choice of Sequences](reference.md#choice-of-sequences)
  * [Conflict Resolution](reference.md#conflict-resolution)
  * [Tumbling Window](reference.md#tumbling-window)
* [Data Model](reference.md#data-model)
  * [Events](reference.md#events)
  * [Facts](reference.md#facts)
  * [Context](reference.md#context)
  * [Timers](reference.md#timers) 
* [Flow Structures](reference.md#flow-structures)
  * [Statechart](reference.md#statechart)
  * [Nested States](reference.md#nested-states)
  * [Flowchart](reference.md#flowchart)
  * [Parallel](reference.md#parallel)  

### Local Setup
------
durable_rules has been tested in MacOS X, Ubuntu Linux and Windows.
#### Redis install
durable.js relies on Redis version 2.8  
 
_Mac_  
1. Download [Redis](http://download.redis.io/releases/redis-2.8.4.tar.gz)   
2. Extract code, compile and start Redis

For more information go to: http://redis.io/download  

_Windows_  
1. Download Redis binaries from [MSTechOpen](https://github.com/MSOpenTech/redis/releases)  
2. Extract binaries and start Redis  

For more information go to: https://github.com/MSOpenTech/redis  

Note: To test applications locally you can also use a Redis [cloud service](reference.md#cloud-setup) 

#### First App
Now that your cache ready, let's write a simple rule:  

1. Start a terminal  
2. Create a directory for your app: `mkdir firstapp` `cd firstapp`  
3. In the new directory `sudo pip install durable_rules` (this will download durable_rules and its dependencies)  
4. In that same directory create a test.py file using your favorite editor  
5. Copy/Paste and save the following code:
  ```python
  from durable.lang import *
  with ruleset('test'):
      @when_all(m.subject == 'World')
      def say_hello(c):
          print ('Hello {0}'.format(c.m.subject))

      @when_start
      def start(host):
          host.post('test', {'id': 1, 'sid': 1, 'subject': 'World'})

  run_all()
  ```
7. In the terminal type `python test.py`  
8. You should see the message: `Hello World`  

Note: If you are using [Redis To Go](https://redistogo.com), replace the last line.
  ```python
  d.runAll([{'host': 'hostName', 'port': port, 'password': 'password'}]);
  ```

[top](reference.md#table-of-contents) 
### Cloud Setup
--------
#### Redis install
{'fraction_non_alphanumeric': 0.1472356935014549, 'fraction_numerical': 0.007371483996120271, 'mean_word_length': 4.099901088031652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7420181', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1629, 'n_words': 464}