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

Error when loading bin file #24

Closed
Mukarillo opened this issue Feb 27, 2020 · 8 comments
Closed

Error when loading bin file #24

Mukarillo opened this issue Feb 27, 2020 · 8 comments

Comments

@Mukarillo
Copy link

Mukarillo commented Feb 27, 2020

Hello,

I am receiving this error when trying to load a Dawg bin file
unable to read beyond the end of the stream

Here is how I am creating the dawg file:

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/EN_words.txt";
var s = File.ReadAllLines(path);

var dawgBuilder = new DawgSharp.DawgBuilder<bool>();
foreach (var line in s)
{
   dawgBuilder.Insert(line, true);
}

var dawgpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/EN_dawg.bin";
var dawg = dawgBuilder.BuildDawg();
dawg.SaveTo(File.Create(dawgpath));

and here is how i am loading the dawg file

var fpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/EN_dawg.bin";
var file = File.Open(fpath, FileMode.Open);
dawgg = Dawg<bool>.Load(file);

The error occours in YaleDawg.cs at line 66.
Screenshot 2020-02-27 at 19 49 30

Thank you very much for the attention.

@Nogbit
Copy link

Nogbit commented Mar 22, 2020

I'm having the same problems (same line and error).

Though I did remove a bad line from my dictionary file and converted it all to lowercase. Now I get to line 78 in your screenshot with the exact same error.

@Nogbit
Copy link

Nogbit commented Mar 22, 2020

It's not a problem with the word file as I get the same errors with the file in this repos test project at https://github.com/bzaar/DawgSharp/blob/master/DawgSharp.UnitTests/eneko-words.txt.

@Mukarillo
Copy link
Author

Mukarillo commented Mar 22, 2020

@Nogbit If I remember correctly I solved the issue by creating the file, and then saving, like this:

var file = File.Create(dawgpath);
dawg.SaveTo(file);

It has something to do with the position of the stream not being initialized correctly or something, But since the project's is licensed under GPLv3, I couldn't use to what I want... so I just gave up debugging.

Good luck tho :)

@bzaar
Copy link
Owner

bzaar commented Mar 23, 2020

Hi everyone,

Sorry a bit late to the party.

You need to close the file after you're done writing to it:

using (var file = File.Create(dawgpath))
    dawg.SaveTo(file);

I will look into making the API more intuitive.

@Mukarillo, you can do anything you want with the library, once you get a commercial license. :)

@Nogbit
Copy link

Nogbit commented Mar 23, 2020

@bzaar thanks, that worked!

@Nogbit
Copy link

Nogbit commented Mar 24, 2020

@Mukarillo I sent you an email to licensing@morpher.co.uk asking about licensing cost, it may have went to your spam?

@Mukarillo
Copy link
Author

@Nogbit I am not the developer of the tool, @bzaar is. Maybe he can help you with that 👍

@bzaar
Copy link
Owner

bzaar commented Mar 24, 2020

@Nogbit, I replied to your email.

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

3 participants