GithubHelp home page GithubHelp logo

yhirose / cpp-fstlib Goto Github PK

View Code? Open in Web Editor NEW
51.0 4.0 9.0 7.48 MB

A single file C++17 header-only Minimal Acyclic Subsequential Transducers, or Finite State Transducers

License: MIT License

C++ 59.11% CMake 0.11% Makefile 15.66% SWIG 0.04% Perl 0.52% Python 0.66% Ruby 0.10% Shell 22.96% M4 0.33% CSS 0.23% C 0.27%
cpp header-only fst cpp17 finite-state-transducers

cpp-fstlib's People

Contributors

yhirose avatar zpalmtree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cpp-fstlib's Issues

conditional logical bug when calculating output

if (OutputTraits<output_t>::empty(state_output)) {

In current condition, state_output will not add up to final output in current frame
I try to fix like this:

        if (ope.data.final && atm.is_match()) {
            if (prefix.empty() || (prefix.size() == 1 && prefix.front() == arc)) {
                if (OutputTraits<output_t>::type() == OutputType::none_t ||
                        OutputTraits<output_t>::empty(state_output)) {
                    accept(word, output);
                } else {
                    accept(word, output + state_output);
                }
            }
        }

how to support prefix search in cpp-fstlib?

I use API named common_prefix_search but the result is not what i want.
I use the example in tutorials.
for example:

// input
const std::vector<std::pair<std::string, std::string>> items = {
  {"hello", "こんにちは!"},
  {"hello world", "こんにちは世界!"}, // incorrect sort order entry...
  {"world", "世界!"},
};
//Omit the initialization process for fstmap; 
//....

//search result with prefix 'h' but no result returned.
auto prefixes = matcher.common_prefix_search("h");

//output=0;
cout << prefixes.size() << endl;  

I expect the result to be “こんにちは!” and “こんにちは世界!”.
Which interface can get the expected result? And what does 'common_prefix_search' mean?

Problem to make this lib support uint64

Hello, I am diving into let the fstlib support uint64_t type. When I simply change the classes instantiated for std::string and uint32_t types to uint64_t, some error are produced in test file. Can you give some hint that where should I make changes if I want to support uint64_t type?

how to dynamically add new items after fst::compile called ?

const std::vector<std::pair<std::string, std::string>> items =
{
{"hello", "a"},
{"hello world", "b"},
{"world", "c"}
};

std::stringstream out;
auto sorted = false; // ask fst::compile to sort entries
auto [result, error_line] = fst::compilestd::string(items, out, sorted);

const auto &byte_code = out.str();
fst::mapstd::string matcher(byte_code.data(), byte_code.size());

//do something
****** here, I have more items to add, how to do that ? ******

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.