Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use tongram in a class #16

Closed
ducanh841988 opened this issue Feb 25, 2021 · 1 comment
Closed

how to use tongram in a class #16

ducanh841988 opened this issue Feb 25, 2021 · 1 comment

Comments

@ducanh841988
Copy link

Hi @jermp

I want to add n-gram model to a class, but I don't know how to call the class from the main function.

I defined class A which contain n-gram model

template
class A
{
private:
Model* model;

public:
A(string model_path = ""){
model = new Model;
tongrams::util::load(*(model), model_path);
}
void fool(){
auto state = model->state();
}
};

but in main(), I don't know how to call class A, since I need a specific type for the model.
Do you know how to solve this?

Thank you in advance.

@jermp
Copy link
Owner

jermp commented Feb 25, 2021

Hi, this is not an "issue" related to Tongrams, rather to C++ programming.
In fact, I do not understand your code.
I see that you want a class that has a template parameter to specify the n-gram model type.
So it should look like this:

template <typename Model>
struct A {

/* all your public methods */

private:
    Model model;
};

and then, in the main, you should specify the type of the model using one among those in the header file lm_types.hpp.
For example:

 A<ef_trie_IC_ranks_count_lm> my_obj;

@jermp jermp closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants