GithubHelp home page GithubHelp logo

hase's Introduction

hase

Hase provides Haskell bindings for the Senna NLP toolkit, supporting

  • Part of Speech tagging (POS)
  • Chunking (CHK)
  • Name Entity Recognition (NER)
  • Semantic Role Labeling (SRL)

Getting Started

At first, please download Senna and extract the Senna source files into foreign/senna/. The tar command below does just that.

tar -xzf senna-v3.0.tgz -C foreign/

Then run

cabal configure
cabal build

to build hase. You can run the example program by executing

cabal run example

Finally, if you want to install this package, run

cabal install

Usage

Here's a simple example to tokenize and process a sentence read from stdin.

module Main where
import NLP.Senna

main =
  withContext $ \ctx -> do
    tokenize ctx =<< getLine
    print =<< (process ctx :: IO [Token])
    print =<< (process ctx :: IO [Maybe POS])
    print =<< (process ctx :: IO [(CHK, Phrase)])
    print =<< (process ctx :: IO [(NER, Phrase)])
    print =<< (process ctx :: IO [[(SRL, Phrase)]])

The Context type holds the internal C library state. You can either manage Context manually by calling createContext and freeContext, or you can use withContext, which automatically creates and frees the Context for you.

Once the Context is created, you pass a sentence to the tokenize function. The tokenize function sets up Context to work with your sentence. Then you can call process to perform various NLP tasks on the previously tokenized sentence.

The Context is memory hungry (200 MB) and should only be setup once. Processing multiple sentences works by alternately calling tokenize and process on the same Context.

License

hase is released under MIT license. You can find a copy of the MIT License in the LICENSE file.

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.