Kafka is an advanced Natural Language Processing library written in Swift. It's built for speed, simplicity, and easy integration into apps. Kafka currently provides linear neural network models for tagging and parsing, with pretrained models and word vectors. It's commercial open-source software, released under the MIT license.
Documentation
| Documentation | |
|---|---|
| Data | Contains word embeddings, a list of POS tags, and a list of dependency tags |
| DependencyParser | Dependency Parser parses Docs for dependency relations between word tokens |
| Doc | A container for accessing linguistic annotations. |
| Kafka | An interface for the library |
| Math | Math holds helper functions for common mathematical computations |
| PartialParse | A PartialParse is a snapshot of an arc-standard dependency parse |
| Transducer | Holds methods for conversions between data types |
Features
- Non-destructive tokenization
- Named entity recognition
- pretrained statistical models and word vectors
- State-of-the-art speed
- Easy deep learning integration
- Part-of-speech tagging
- Labelled dependency parsing
- Syntax-driven sentence segmentation
- Built in visualizers for syntax and NER
Requirements
iOS 12.0+ | macOS 10.14+ | Mac Catalyst 13.0+ | tvOS 12.0+ | watchOS 5.0+
Integration
CocoaPods
You can use CocoaPods to install Kafka by adding it to your Podfile:
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'Kafka'
endCarthage
You can use Carthage to install Kafka by adding it to your Cartfile:
github "questo-ai/kafka"
If you use Carthage to build your dependencies, make sure you have added Kafka.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.
Usage
Initialization
import Kafka// Initialise a dependency parser
let parser = DependencyParser()Parsing
let doc = Doc(string: "Memories warm you up from the inside. But they also tear you apart.") // From Haruki Murakami, Kafka on the Shore
let result = parser.predict(text: doc)Use dependency data
/// The dependency arcs is stored as a property of Doc, with type [[(Int, Int, String)]]
/// arcs is a list of triples (idx_head, idx_dep, deprel) signifying the
/// dependency relation `idx_head ->_deprel idx_dep`, where idx_head is
/// the index of the head word, idx_dep is the index of the dependant,
/// and deprel is a string representing the dependency relation label.
print(result.arcs)