Skip to content
Permalink
Browse files

Reorganize project and use all Swift

  • Loading branch information
ayanonagon committed Apr 8, 2015
1 parent aeaf291 commit 1620b88c1959641f6c5f5e402a33b39a84e2e591
Showing with 1,129 additions and 1,018 deletions.
  1. +77 −0 CHANGELOG.md
  2. +1 −1 LICENSE
  3. +5 −5 Parsimmon.podspec
  4. +48 −0 Parsimmon/Analyzer.swift
  5. +1 −1 Parsimmon/{Parsimmon → }/DecisionTree.swift
  6. +0 −15 Parsimmon/Example/AppDelegate.h
  7. +0 −13 Parsimmon/Example/AppDelegate.m
  8. +0 −16 Parsimmon/Example/Example-Prefix.pch
  9. +0 −23 Parsimmon/Example/Images.xcassets/LaunchImage.launchimage/Contents.json
  10. +0 −36 Parsimmon/Example/TaggerViewController.swift
  11. +0 −2 Parsimmon/Example/en.lproj/InfoPlist.strings
  12. +0 −18 Parsimmon/Example/main.m
  13. +30 −0 Parsimmon/Functions.swift
  14. +3 −3 Parsimmon/{Parsimmon → }/Lemmatizer.swift
  15. +17 −3 Parsimmon/{Parsimmon → }/NaiveBayesClassifier.swift
  16. +0 −639 Parsimmon/Parsimmon.xcodeproj/project.pbxproj
  17. +0 −96 Parsimmon/Parsimmon.xcodeproj/xcshareddata/xcschemes/Parsimmon.xcscheme
  18. +0 −34 Parsimmon/Parsimmon/Analyzer.swift
  19. +0 −16 Parsimmon/Parsimmon/Functions.swift
  20. 0 Parsimmon/Parsimmon/Parsimmon-Bridging-Header.h
  21. +0 −21 Parsimmon/Parsimmon/Seed.swift
  22. +0 −24 Parsimmon/Parsimmon/TaggedToken.swift
  23. 0 Parsimmon/ParsimmonTests/ParsimmonTests-Bridging-Header.h
  24. +0 −2 Parsimmon/ParsimmonTests/en.lproj/InfoPlist.strings
  25. +35 −0 Parsimmon/Seed.swift
  26. +43 −0 Parsimmon/TaggedToken.swift
  27. +3 −3 Parsimmon/{Parsimmon → }/Tagger.swift
  28. +2 −2 Parsimmon/{Parsimmon → }/Tokenizer.swift
  29. +582 −0 ParsimmonSample.xcodeproj/project.pbxproj
  30. +1 −1 ...mon/Parsimmon.xcodeproj → ParsimmonSample.xcodeproj}/project.xcworkspace/contents.xcworkspacedata
  31. +10 −0 ParsimmonSample.xcworkspace/contents.xcworkspacedata
  32. +12 −7 Parsimmon/Parsimmon/Parsimmon.h → ParsimmonSample/AppDelegate.swift
  33. +41 −0 ParsimmonSample/Base.lproj/LaunchScreen.xib
  34. +18 −3 {Parsimmon/Example → ParsimmonSample}/ClassifierViewController.swift
  35. +15 −0 {Parsimmon/Example → ParsimmonSample}/Images.xcassets/AppIcon.appiconset/Contents.json
  36. +12 −0 ParsimmonSample/Images.xcassets/first.imageset/Contents.json
  37. BIN ParsimmonSample/Images.xcassets/first.imageset/first.pdf
  38. +12 −0 ParsimmonSample/Images.xcassets/second.imageset/Contents.json
  39. BIN ParsimmonSample/Images.xcassets/second.imageset/second.pdf
  40. +16 −6 Parsimmon/Example/Example-Info.plist → ParsimmonSample/Info.plist
  41. +53 −17 {Parsimmon/Example/Base.lproj → ParsimmonSample}/Main.storyboard
  42. +51 −0 ParsimmonSample/TaggerViewController.swift
  43. 0 {Parsimmon → }/ParsimmonTests/DecisionTreeTests.swift
  44. +4 −2 Parsimmon/ParsimmonTests/ParsimmonTests-Info.plist → ParsimmonTests/Info.plist
  45. 0 {Parsimmon → }/ParsimmonTests/LemmatizerTests.swift
  46. 0 {Parsimmon → }/ParsimmonTests/NaiveBayesClassifierTests.swift
  47. 0 {Parsimmon → }/ParsimmonTests/TaggerTests.swift
  48. 0 {Parsimmon → }/ParsimmonTests/TokenizerTests.swift
  49. +10 −0 Podfile
  50. +14 −0 Podfile.lock
  51. +13 −9 README.md
@@ -0,0 +1,77 @@
# Change Log

## [Unreleased](https://github.com/ayanonagon/Parsimmon/tree/HEAD)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.3.4...HEAD)

**Merged pull requests:**

- Update for Xcode 6.3 beta 2 [\#19](https://github.com/ayanonagon/Parsimmon/pull/19) ([jordanekay](https://github.com/jordanekay))

- Don't have NaiveBayesClassifier inherit from NSObject [\#18](https://github.com/ayanonagon/Parsimmon/pull/18) ([jordanekay](https://github.com/jordanekay))

- Finish up Swift conversion [\#14](https://github.com/ayanonagon/Parsimmon/pull/14) ([jordanekay](https://github.com/jordanekay))

- Introduce more Swift components [\#13](https://github.com/ayanonagon/Parsimmon/pull/13) ([jordanekay](https://github.com/jordanekay))

- Convert naive Bayes classifier to Swift [\#12](https://github.com/ayanonagon/Parsimmon/pull/12) ([jordanekay](https://github.com/jordanekay))

- Update for Swift 1.2 and Xcode 6.3 beta [\#11](https://github.com/ayanonagon/Parsimmon/pull/11) ([jordanekay](https://github.com/jordanekay))

## [0.3.4](https://github.com/ayanonagon/Parsimmon/tree/0.3.4) (2015-02-12)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.3.3...0.3.4)

## [0.3.3](https://github.com/ayanonagon/Parsimmon/tree/0.3.3) (2014-06-30)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.3.2...0.3.3)

## [0.3.2](https://github.com/ayanonagon/Parsimmon/tree/0.3.2) (2014-06-30)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.3.1...0.3.2)

## [0.3.1](https://github.com/ayanonagon/Parsimmon/tree/0.3.1) (2014-06-30)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.3.0...0.3.1)

**Merged pull requests:**

- Update Slather to 0.0.235 [\#9](https://github.com/ayanonagon/Parsimmon/pull/9) ([marklarr](https://github.com/marklarr))

- Slather! [\#8](https://github.com/ayanonagon/Parsimmon/pull/8) ([marklarr](https://github.com/marklarr))

## [0.3.0](https://github.com/ayanonagon/Parsimmon/tree/0.3.0) (2014-01-25)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.2.1...0.3.0)

**Merged pull requests:**

- Remove unnecessary overrides [\#7](https://github.com/ayanonagon/Parsimmon/pull/7) ([jordanekay](https://github.com/jordanekay))

- Fix spelling [\#6](https://github.com/ayanonagon/Parsimmon/pull/6) ([jordanekay](https://github.com/jordanekay))

- Remove unnecessary overrides [\#5](https://github.com/ayanonagon/Parsimmon/pull/5) ([jordanekay](https://github.com/jordanekay))

- Added unit test for lemmatizer class [\#4](https://github.com/ayanonagon/Parsimmon/pull/4) ([iOSCowboy](https://github.com/iOSCowboy))

- More Unit Tests [\#3](https://github.com/ayanonagon/Parsimmon/pull/3) ([iOSCowboy](https://github.com/iOSCowboy))

- Unit Test for Tokenizer [\#2](https://github.com/ayanonagon/Parsimmon/pull/2) ([iOSCowboy](https://github.com/iOSCowboy))

## [0.2.1](https://github.com/ayanonagon/Parsimmon/tree/0.2.1) (2013-10-16)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.2.0...0.2.1)

## [0.2.0](https://github.com/ayanonagon/Parsimmon/tree/0.2.0) (2013-10-14)

[Full Changelog](https://github.com/ayanonagon/Parsimmon/compare/0.1.0...0.2.0)

**Merged pull requests:**

- Fix broken URL in pod spec [\#1](https://github.com/ayanonagon/Parsimmon/pull/1) ([kylef](https://github.com/kylef))

## [0.1.0](https://github.com/ayanonagon/Parsimmon/tree/0.1.0) (2013-10-13)



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -1,4 +1,4 @@
Copyright (c) 2013 Ayaka Nonaka (http://ayaka.me/)
Copyright (c) 2015 Ayaka Nonaka (http://ayaka.me/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -1,9 +1,9 @@
Pod::Spec.new do |s|
# pod customization goes in here
s.name = 'Parsimmon'
s.version = '0.3.0'
s.platform = :ios, '5.0'
s.ios.deployment_target = '5.0'
s.version = '0.3.4'
s.platform = :ios, '8.0'
s.ios.deployment_target = '8.0'
s.license = { :type => 'MIT' }
s.homepage = 'http://www.parsimmon.com'
s.summary = 'Linguistics toolkit for iOS'
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
}
s.source = {
:git => 'https://github.com/ayanonagon/Parsimmon.git',
:tag => '0.3.0'
:tag => s.version
}
s.source_files = 'Parsimmon/Parsimmon/*.{h,m}'
s.source_files = 'Parsimmon/*.swift'
end
@@ -0,0 +1,48 @@
// Enumerator.swift
//
// Copyright (c) 2015 Ayaka Nonaka
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation

typealias Pair = (String, String)

protocol Analyzer {
var seed: Seed { get }
var scheme: String { get }
}

internal func analyze(analyzer: Analyzer, text: String, options: NSLinguisticTaggerOptions?) -> [Pair] {
var pairs: [Pair] = []

let range = NSRange(location: 0, length: count(text))
let options = options ?? analyzer.seed.linguisticTaggerOptions
let tagger = analyzer.seed.linguisticTaggerWithOptions(options)

tagger.string = text
tagger.enumerateTagsInRange(range, scheme: analyzer.scheme, options: options) { (tag: String?, tokenRange, range, stop) in
if let tag = tag {
let token = (text as NSString).substringWithRange(tokenRange)
let pair = (token, tag)
pairs.append(pair)
}
}
return pairs
}
@@ -1,4 +1,4 @@
// DecisionTree.swift
// DecisionTree.swift
//
// Copyright (c) 2015 Ayaka Nonaka
//

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1,30 @@
// Functions.swift
//
// Copyright (c) 2015 Ayaka Nonaka
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation

func argmax<T, U: Comparable>(elements: [(T, U)]) -> T? {
if let start = elements.first {
return elements.reduce(start) { $0.1 > $1.1 ? $0 : $1 }.0
}
return nil
}
@@ -1,4 +1,4 @@
// Tokenizer.swift
// Lemmatizer.swift
//
// Copyright (c) 2015 Ayaka Nonaka
//
@@ -29,11 +29,11 @@ public struct Lemmatizer: Analyzer {
return NSLinguisticTagSchemeLemma
}

init(seed: Seed = Seed()) {
public init(seed: Seed = Seed()) {
self.seed = seed
}

func lemmatizeWordsInText(text: String, options: NSLinguisticTaggerOptions? = nil) -> [String] {
public func lemmatizeWordsInText(text: String, options: NSLinguisticTaggerOptions? = nil) -> [String] {
return analyze(self, text, options).map { (token, lemma) in lemma }
}
}
@@ -1,10 +1,24 @@
// NaiveBayesClassifier.swift
//
// NaiveBayesClassifier.swift
// Parsimmon
// Copyright (c) 2015 Ayaka Nonaka
//
// Created by Jordan Kay on 2/18/15.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
/**
## Sample usage

0 comments on commit 1620b88

Please sign in to comment.
You can’t perform that action at this time.