Code Monkey home page Code Monkey logo

parsimmon's Introduction

Parsimmon

Build Status

Parsimmon is a wee Objective-C linguistics toolkit for iOS.

Toolkit

Currently available tools:

  • Tokenizer
  • Tagger
  • Lemmatizer
  • Naive Bayes Classifier
  • Decision Tree (alpha)

Installation

The easiest way to get started is to use CocoaPods. Just add the following line to your Podfile:

pod 'Parsimmon', '~> 0.3.0'

Examples

To start using Parsimmon:

#import "Parsimmon.h"

###Tokenizer

ParsimmonTokenizer *tokenizer = [[ParsimmonTokenizer alloc] init];
NSArray *tokens = [tokenizer tokenizeWordsInText:@"The quick brown fox jumps over the lazy dog"];
NSLog(@"%@", tokens);
(
The,
quick,
brown,
fox,
jumps,
over,
the,
lazy,
dog
)

###Tagger

ParsimmonTagger *tagger = [[ParsimmonTagger alloc] init];
NSArray *taggedTokens = [tagger tagWordsInText:@"The quick brown fox jumps over the lazy dog"];
NSLog(@"%@", taggedTokens);
(
"('The', Determiner)",
"('quick', Adjective)",
"('brown', Adjective)",
"('fox', Noun)",
"('jumps', Noun)",
"('over', Preposition)",
"('the', Determiner)",
"('lazy', Adjective)",
"('dog', Noun)"
)

Lemmatizer

ParsimmonLemmatizer *lemmatizer = [[ParsimmonLemmatizer alloc] init];
NSArray *lemmatizedTokens = [lemmatizer lemmatizeWordsInText:@"Diane, I'm holding in my hand a small box of chocolate bunnies."];
NSLog(@"%@", lemmatizedTokens);
diane,
i,
hold,
in,
my,
hand,
a,
small,
box,
of,
chocolate,
bunny
)

Naive Bayes Classifier

ParsimmonNaiveBayesClassifier *classifier = [[ParsimmonNaiveBayesClassifier alloc] init];

// Train the classifier with some ham examples.
[classifier trainWithText:@"nom nom ham" category:@"ham"];
[classifier trainWithText:@"make sure to get the ham" category:@"ham"];
[classifier trainWithText:@"please put the eggs in the fridge" category:@"ham"];

// Train the classifier with some spam examples.
[classifier trainWithText:@"spammy spam spam" category:@"spam"];
[classifier trainWithText:@"what does the fox say?" category:@"spam"];
[classifier trainWithText:@"and fish go blub" category:@"spam"];

// Classify some new text. Is it ham or spam?
// In practice, you'd want to train with more examples first.
NSString *firstExample = @"use the eggs in the fridge.";
NSString *secondExample = @"what does the fish say?";
NSLog(@"'%@' => %@", firstExample, [classifier classify:firstExample]);
NSLog(@"'%@' => %@", secondExample, [classifier classify:secondExample]);
'use the eggs in the fridge.' => ham
'what does the fish say?' => spam

Version

0.3.0

License

MIT

parsimmon's People

Contributors

ayanonagon avatar chocochipset avatar kylef avatar marklarr 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.