Giter Site home page Giter Site logo

tatoeba / nihongoparserd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from allan-simon/nihongoparserd

23.0 12.0 5.0 43 KB

Web services to provide Japanese parsing, conversion in kana, romaji

License: MIT License

CMake 1.45% Shell 5.17% C++ 92.74% C 0.65%

nihongoparserd's Introduction

nihongoparserd

A service to convert japanese languages into romaji, kana etc.

for the moment it's based on libmecab but it may be replaced by homebrew parser in the future

Building and running

With Docker

Since getting this code to compile under macOS (the use of strdupa from the GNU C++ extensions may be hard or impossible under clang++), this repo contains a Dockerfile:

$ docker build -t nihongoparserd .
$ docker run -t -i -p 8842:8842 nihongoparserd

You can then hit the service at localhost:8842 like so.

To kill the service, you can:

$ docker ps #<-- to find the container ID
$ docker kill <that_container_id>

Building manually (without Docker)

Requirements

  • libexpat
  • libevent
  • libmecab2
  • cmake
  • a C++11 compatible compiler with GNU's stdlib
  • a dictionary (e.g. mecab-ipadic-utf8)

Building

To build the project:

$ cmake .
$ make

To run the server:

    ./nihonggoparserd -p PORT [-h HOSTNAME]

That will launch an HTTP server listening on port PORT, bound to HOSTNAME.

Usage

It provides the following API calls, that will return an XML answer. Note that contents are wrapped into <![CDATA[...]]>, which is removed from the following examples for readability.

Parse

URL: /parse?str=*

Example of response for /parse?str=学校は家から遠いの?

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <parse>
        <token>学校</token>
        <token>は</token>
        <token>家</token>
        <token>から</token>
        <token>遠い</token>
        <token>の</token>
        <token>?</token>
    </parse>
</root>

Furigana

URL: /furigana?str=*

Example of response for /furigana?str=学校は家から遠いの?

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <parse>
       <token>
           <reading furigana="がっこう">学校</reading>
       </token>
       <token>は</token>
       <token>
           <reading furigana="いえ">家</reading>
       </token>
       <token>から</token>
       <token>
           <reading furigana="とお">遠></reading>
           い
       </token>
       <token>の</token>
       <token>?</token>
    </parse>
</root>

Kana

URL: /kana?str=*

Example of rensponse for /kana?str=学校は家から遠いの?

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <kana>がっこうはいえからとおいの?</kana>
</root>

nihongoparserd's People

Contributors

jiru avatar allan-simon avatar searls avatar linkmauve avatar

Stargazers

Klaudia Bronowicka avatar James Moran avatar  avatar Sacha Arbonel avatar Valdi Asgeirs avatar Ben-Hur avatar Misael Eduardo Rojas Lopez avatar Isara Naranirattisai avatar Alejandro Exojo avatar Minh Tran avatar  avatar machiko avatar Claudio Dekker avatar soo avatar Michael Goulet avatar Hoang Tung avatar Max avatar Divam avatar  avatar Gabriel Tibúrcio avatar Loreto Parisi avatar Blue avatar zhiyue avatar

Watchers

pep avatar  avatar Trang avatar  avatar Tomasz Melcer avatar James Cloos avatar  avatar  avatar  avatar Gabriel Tibúrcio avatar Harsh Nisar avatar  avatar

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.