Coder Social home page Coder Social logo

graemenail / ssplit-cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from browsermt/ssplit-cpp

0.0 0.0 0.0 209 KB

Approximate reimplementation of the sentence splitter from the Moses toolkit.

License: Other

Shell 3.25% JavaScript 1.23% Ruby 2.43% C++ 49.38% Perl 1.93% Emacs Lisp 25.10% Smalltalk 2.79% Slash 0.41% SystemVerilog 0.27% NewLisp 2.33% CMake 10.52% Dockerfile 0.37%

ssplit-cpp's Introduction

ssplit-cpp

This is an approximate reimplementation of the sentence splitter from the Moses toolkit.

  • Currently doesn't support CJK character sets.
  • requires the pcre2 libraries On Ubuntu, sudo apt-get install libpcre2 should do the trick
  • The (non-breaking) prefix files included were originally copied from the Moses toolkit but may have been edited there or here since they were copied.

Build instructions

mkdir build
cd build
cmake ..
make -j

This produces an executable ssplit.

Usage

Command line:

run ssplit -h for usage instructions.

In Code (Example)

#include "ssplit.h"

...

std::string prefix_file = "path/to/moses-style/prefix-file";
ug::ssplit::SentenceSplitter ssplit(prefix_file);

...

std::string chunk_of_text = "Sentence one. Sentence two.\nSentence three. Sentence four.";
ug::ssplit::splitmode mode = ug::ssplit::splitmode::one_paragraph_per_line;
ug::sssplit::SentenceStream sentence_stream(chunk_of_text, ssplit, mode);
std::string_view snt;

while(sentence_stream >> snt) { // false means end of chunk
  if (snt.size() == 0) {
    // empty string_view means end of paragraph except in one_sentence_per_line mode,
    // which just returns one line (minus leading and training whitespace) at a time
    // For one_paragraph_per_line each empty paragraph results in snt.size() == 0
    // twice in a row: first the em
    ...
  }
  else { // this is the next non-empty paragraph
    ...
  }
}

ssplit-cpp's People

Contributors

ugermann avatar xapajiamnu avatar kpu avatar jerinphilip avatar kdavis-mozilla avatar abhi-agg 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.