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

Unable to convert data/glove/glove.840B.300d.txt to Torch serialized format #13

Open
sravyapolisetty opened this issue Jul 11, 2017 · 0 comments

Comments

@sravyapolisetty
Copy link

sravyapolisetty commented Jul 11, 2017

Error occurs in convert-wordvecs.lua at

vecs[{i, j}] = tonumber(tokens[j + 1])

screen shot 2017-07-11 at 2 53 40 pm

The conversion fails as the data/glove/glove.840B.300d.txt file has non-UTF8 and Non-ASCII characters. Did anyone face this issue with data/glove/glove.840B.300d.txt file?

Changed the for loop to add the condition to avoid conversion to number and writing to vocab, if the second token in each count is not a number.(the problem is because if there is no number, then tonumber returns nil)

for i = 1, count do
 repeat
  xlua.progress(i, count)
  local tokens = stringx.split(file:read())
  if tonumber(tokens[2]) == nil then break end
  local word = tokens[1]
  vocab:write(word .. '\n')
  for j = 1, dim do
   vecs[{i, j}] = tonumber(tokens[j + 1])
  end
 until true
end

The above fix solves the issue, but I would like to know if this is the correct solution for the problem.

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

1 participant