Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jamesfrost/gnip-rule-parser

Parse Twitter (GNIP) PowerTrack/Search rules into an abstract syntax tree.
https://github.com/jamesfrost/gnip-rule-parser

gnip gnip-powertrack twitter twitter-api twitter-streaming-api

Last synced: about 2 months ago
JSON representation

Parse Twitter (GNIP) PowerTrack/Search rules into an abstract syntax tree.

Awesome Lists containing this project

README

        

# gnip-rule-parser [![Build Status](https://travis-ci.org/JamesFrost/gnip-rule-parser.svg?branch=master)](https://travis-ci.org/JamesFrost/gnip-rule-parser)
Parse [GNIP PowerTrack/Search rules](https://developer.twitter.com/en/docs/tweets/rules-and-filtering/overview) into an abstract syntax tree.

[Try the online demo here](http://jamesfrost.me/gnip-rule-parser/).

*If you want to validate rules, I strongly suggest you use the [validation API endpoint](https://developer.twitter.com/en/docs/tweets/filter-realtime/api-reference/powertrack-stream#get-validation).*

## Getting Started
### Installation
```bash
npm install --save gnip-rule-parser
```
### Running The Tests
```bash
mocha
```
### Usage
```js
var parser = require( 'gnip-rule-parser' );

try
{
var ast = parser.parse( 'happy OR party' );

console.log( ast );
}
catch( err )
{
// Rule isn't valid
}
```
#### Output
```bash
[
{
name: 'boolean',
value: 'OR',
leftBranch:
{
name: 'keyword',
value: 'happy'
},
rightBranch:
{
name: 'keyword',
value: 'party'
}
}
]
```
## License
MIT