/* Generated from esperanto.sbl by Snowball 3.1.1 - https://snowballstem.org/ */

#include <xapian/stem.h>

#define SNOWBALL_RUNTIME_THROW_EXCEPTIONS
#include "languages/snowball_runtime.h"

namespace Xapian::Internal::Snowball {

class Esperanto : public Xapian::StemImplementation {
  public:
    struct SN_local {
        struct SN_env z;
    };

  private:
    SN_local zlocal = {};

    void close_env() {
        struct SN_env * z = &(zlocal.z);
        lose_s(z->p);
    }

    static int stem(struct SN_env * z);

  public:
    Esperanto() {
        struct SN_env * z = &(zlocal.z);
        z->p = create_s();
    }

    ~Esperanto() {
        close_env();
    }

    std::string operator()(const std::string& word) override {
        struct SN_env* z = &(zlocal.z);
        const symbol* s = reinterpret_cast<const symbol*>(word.data());
        int s_size = word.size() > INT_MAX ? INT_MAX : word.size();
        replace_s(z, 0, z->l, s_size, s);
        z->c = 0;
        Xapian::Internal::Snowball::Esperanto::stem(z);
        return std::string(reinterpret_cast<const char*>(z->p), SIZE(z->p));
    }

    std::string get_description() const override {
        return "esperanto";
    }
};

}
