Code Monkey home page Code Monkey logo

corenlp's Introduction

CoreNLP

Hex.pm

The CoreNLP package is a thin Elixir client for the Stanford CoreNLP Server.

Since the Stanford offering is written in Java, the recommended integration for non-JVM languages is to stand up a CoreNLP dedicated server and hit it from a client interface. This package provides that interface for the Elixir ecosystem.

Installation

If available in Hex, the package can be installed by adding corenlp to your list of dependencies in mix.exs:

def deps do
  [{:corenlp, "~> 0.1.0"}]
end

The following are configuration settings used by this application to point to your CoreNLP server, with their defaults shown:

config :corenlp,
  host:          "localhost",
  base_path:     "/",
  port:          9000,
  recv_timeout:  30_000

Refer to the Stanford CoreNLP Server page for detailed information regarding standing up a dedicated server (including a local instance for dev/testing).

Usage

For detailed usage information regarding options that can be passed into the various calls, please consult the Stanford CoreNLP Server documentation.

Annotations

iex> CoreNLP.annotate("The cat sat.", annotators: "tokenize,ssplit,pos")
{:ok,
 %{"sentences" => [%{"index" => 0,
      "tokens" => [%{"after" => " ", "before" => "",
         "characterOffsetBegin" => 0, "characterOffsetEnd" => 3, "index" => 1,
         "originalText" => "The", "pos" => "DT", "word" => "The"},
       %{"after" => " ", "before" => " ", "characterOffsetBegin" => 4,
         "characterOffsetEnd" => 7, "index" => 2, "originalText" => "cat",
         "pos" => "NN", "word" => "cat"},
       %{"after" => "", "before" => " ", "characterOffsetBegin" => 8,
         "characterOffsetEnd" => 11, "index" => 3, "originalText" => "sat",
         "pos" => "VBD", "word" => "sat"},
       %{"after" => "", "before" => "", "characterOffsetBegin" => 11,
         "characterOffsetEnd" => 12, "index" => 4, "originalText" => ".",
         "pos" => ".", "word" => "."}]}]}}

TokensRegex

iex> CoreNLP.tokensregex("The quick brown fox jumps over the lazy dog.", ~S/(?$foxtype [{pos:JJ}]+ ) fox/)
{:ok,
 %{"sentences" => [%{"0" => %{"$foxtype" => %{"begin" => 1, "end" => 3,
          "text" => "quick brown"}, "begin" => 1, "end" => 4,
        "text" => "quick brown fox"}, "length" => 1}]}}

Semgrex

iex> CoreNLP.semgrex("The quick brown fox jumped over the lazy dog.", ~S|{pos:/VB.*/} >nsubj {}=subject >/nmod:.*/ {}=prep_phrase|)
{:ok,
 %{"sentences" => [%{"0" => %{"$prep_phrase" => %{"begin" => 8, "end" => 9,
          "text" => "dog"},
        "$subject" => %{"begin" => 3, "end" => 4, "text" => "fox"},
        "begin" => 4, "end" => 5, "text" => "jumped"}, "length" => 1}]}}

Tregex

iex> CoreNLP.tregex("The quick brown fox jumped over the lazy dog.", ~S|NP < NN=animal|)
{:ok,
 %{"sentences" => [%{"0" => %{"match" => "(NP (DT The) (JJ quick) (JJ brown) (NN fox))\n",
        "namedNodes" => [%{"animal" => "(NN fox)\n"}]},
      "1" => %{"match" => "(NP (DT the) (JJ lazy) (NN dog))\n",
        "namedNodes" => [%{"animal" => "(NN dog)\n"}]}}]}}

Contributing

All requests will be entertained, but the purpose of this package is to focus on providing services surrounding the Stanford CoreNLP Server specifically, and not to delve into the broader topic of NLP which will be left to other packages.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/corenlp.

corenlp's People

Contributors

arpieb avatar

Stargazers

 avatar merik avatar amy null avatar Thomas Charbonnel avatar Krzysztof Wende avatar  avatar Zach Parsons avatar Justus Eapen avatar  avatar Joachim Kueter avatar Sam Gaw avatar Chase Gilliam avatar Bruce Yinhe avatar Robb Wright avatar

Watchers

 avatar James Cloos avatar WangJunKai avatar Chase Gilliam avatar

Forkers

omsolem

corenlp's Issues

Deps

Now the deps is

httpoison ~> 0.11
poison ~> 3.1

where httpoison is out of date while poison is too new compared with other mix packages, such as phoenix.

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.