GithubHelp home page GithubHelp logo

speakeasy's Introduction

SpeakEasy

Simple Natural Language Processing

Circle CI


npm install speakeasy-nlp


Current commands:

  1. *.classify : Roughly determines the action, subject, and owner (posessive object) of a sentence. As of 0.2.2 it also includes verbs, nouns, and adjectives
  2. *.sentiment: A collection of methods to approximate the positive/negative affect of a statement (relative to the whole statement)
  3. *.closest : Uses levenshtein distance to find the best match for a word given an array

var speak = require("./speakeasy-nlp");

// Analyze sentences at a basic level
// ------------------------------------- //
speak.classify("What is your name?")             //=> { action: "what", owner: "listener", subject: "name" }
speak.classify("Do you know what time it is?")   //=> { action: "what", owner: "it", subject: "time" }

// Sentiment analysis
// ------------------------------------- //
speak.sentiment.negativity("I hate your guts")   //=> { score: 1, words: [hate] }
speak.sentiment.positivity("I love you")         //=> { score: 1, words: [love] }

speak.sentiment.analyze("I love you, but you smell something aweful")  
// (Negative scores dictate a stronger influence of negative words)
//=> { score: -1, positive: { ... }, negative: { ... } }

// Closest word
// ------------------------------------- //
speak.closest("node", ["foo", "nodejs", "baz"])     //=> "nodejs"

Philosophy

The goal of this project is not to be the next final solution for natural language processing. There are plenty of other projects that do a significantly better job of this. SpeakEasy spawned out of another of my projects, Nodebot, as a method of processing user input to simulate the illusion of intelligence.

SpeakEasy's goal is to provide a library for NodeJS to perform simple language processing actions that perform well for 70%-80% of all cases.

License

speakeasy is released under the MIT License.

speakeasy's People

Contributors

nhunzaker avatar rockitbaby avatar thinkroth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

speakeasy's Issues

README EXAMPLE

The example

speak.classify("Do you know what time it is?") //=> { action: "what", owner: "it", subject: "time" }

is not correct.

.classify() never recognizes 'you' especially if leading the sentence

I'd expect it to return 'listener' and you see this behavior often when text contains "your", but curiously not pronouns like "you", which never is identified as the subject if the first word in a sentence:

const speak = require("speakeasy-nlp");
// below using speak.classify(String)

'What is your name?' 
// owner: 'listener', subject: 'name'   <--- Correct

'What name do you have?'
// owner: undefined, subject: 'you'

'You have a name?'
// owner: undefined, subject: 'name'

'You look lovely'
// owner: 'lovely', subject: 'look lovely' 

'I look lovely'
// owner: 'speaker', subject: 'look lovely' <--- Correct

code breaks when I extend Array.prototype

code breaks when I use these kind of code.
Array.prototype.somefuntion=function(){
//do something
}

error:
TypeError: words[i].toLowerCase is not a function
at POSTagger.tag (\node_modules\speakeasy-nlp\lib\classify\pos\POSTagger.js:52:40)

TypeError: string.match is not a function

Just running the module on a string i am getting this error , any ideas?

TypeError: string.match is not a function
at new LexerNode (web/node_modules/speakeasy-nlp/lib/classify/pos/lexer.js:32:31)
at module.exports.Lexer.lex (web/node_modules/speakeasy-nlp/lib/classify/pos/lexer.js:89:14)
at Object.classify (web/node_modules/speakeasy-nlp/lib/classify/index.js:86:21)
at Object.processMessage (web/src/server/Logics/ProcessMessage.js:12:20)
at web/src/server/Logics/SendMessage.js:69:28
at web/src/server/Models/UserModel.js:38:13
at model.Query. (web/node_modules/mongoose/lib/model.js:3731:16)
at web/node_modules/kareem/index.js:277:21
at web/node_modules/kareem/index.js:131:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

array.slice arguments error

I have found a issues with your code that I am unsure how to fix. You are supplying too many argument to the slice function in lib/classify/index.js on line 203. According to MDN, the slice function should only have 2 arguments, not 3.

 owner = words.slice(prepIndex + 1, -1, detIndex).join(" ");

Thanks!

Subject is wrong?

If I write "I am a dog" it says "dog" is the subject even though "I" am the subject.

Perhaps stop processing words/numbers in quotes?

I really like your project, i'm working on some kind of ifttt-clone for my personal usage, which should be configured as simple as possible, therfor i really like the idea of natural language configs, like

watch my server reinemuth.rocks with username [email protected] and password "password123password" for new mail

or

watch folder "/test123/test3" for new files

but words with number etc. in it are simply split into pieces, numbers are thrown away... Perhaps there could be some "stop-parsing" chars, maybe simple quotes?

Thanks,

Jens

Client-side?

Is there a way to make this client-side and run in the browser?

License?

Hey there!

Very cool plugin -- noticed that there's not a license associated with this project. Is it MIT? GPL? Etc?

Hope this helps

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.