Parsimmon

Parsimmon is a wee linguistics toolkit for iOS written in Swift.

  • 所有者: ayanonagon/Parsimmon
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Parsimmon

Build Status

Parsimmon is a wee linguistics toolkit for iOS written in Swift.

We currently support Swift 2.0. If you are looking for Objective-C, please use version 0.3.4 or earlier.

Toolkit

Currently available tools:

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

Installation

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

pod 'Parsimmon', '~> 0.5.0'

Examples

To start using Parsimmon:

import Parsimmon

Tokenizer

let tokenizer = Tokenizer()
let tokens = tokenizer.tokenize("The quick brown fox jumps over the lazy dog")
print(tokens)
(
The,
quick,
brown,
fox,
jumps,
over,
the,
lazy,
dog
)

Tagger

let tagger = Tagger()
let taggedTokens = tagger.tagWordsInText("The quick brown fox jumps over the lazy dog")
print(taggedTokens)
(
"('The', Determiner)",
"('quick', Adjective)",
"('brown', Adjective)",
"('fox', Noun)",
"('jumps', Noun)",
"('over', Preposition)",
"('the', Determiner)",
"('lazy', Adjective)",
"('dog', Noun)"
)

Lemmatizer

let lemmatizer = Lemmatizer()
let lemmatizedTokens = lemmatizer.lemmatizeWordsInText("Diane, I'm holding in my hand a small box of chocolate bunnies.")
print(lemmatizedTokens)
(
diane,
i,
hold,
in,
my,
hand,
a,
small,
box,
of,
chocolate,
bunny
)

Naive Bayes Classifier

let classifier = NaiveBayesClassifier()

// 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.
let firstExample = "use the eggs in the fridge."
let secondExample = "what does the fish say?"

print("\(firstExample) => \(classifier.classify(firstExample))")
print("\(secondExample) => \(classifier.classify(secondExample))")
'use the eggs in the fridge.' => ham
'what does the fish say?' => spam

License

MIT

Contributing

We’d love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We’ll do our best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. :octocat:

Please make sure to follow our general coding style and add test coverage for new features!

主要指标

概览
名称与所有者ayanonagon/Parsimmon
主编程语言Swift
编程语言Ruby (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2013-10-11 05:14:40
推送于2017-03-09 13:08:46
最后一次提交2016-06-17 14:49:10
发布数10
最新版本名称0.5.0 (发布于 )
第一版名称0.1.0 (发布于 2013-10-12 18:12:35)
用户参与
星数706
关注者数22
派生数46
提交数118
已启用问题?
问题数10
打开的问题数7
拉请求数21
打开的拉请求数1
关闭的拉请求数4
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?