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

RangeError: Invalid typed array length #1

Open
trong opened this issue Jan 13, 2017 · 0 comments
Open

RangeError: Invalid typed array length #1

trong opened this issue Jan 13, 2017 · 0 comments

Comments

@trong
Copy link

trong commented Jan 13, 2017

Построение словаря:

from pprint import pprint
import dawg

words = [ u'ABC', u'ABCD', u'ABCS', u'АБВ', u'АБВГ', u'АБВЦ' ]
d = dawg.CompletionDAWG(words)
d.save('../data/words.dawg')

print(d.keys("ABC"))
print(d.keys("АБ"))

# Output: 
#   ['ABC', 'ABCD', 'ABCS']
#   ['АБВ', 'АБВГ', 'АБВЦ']

Готовый словарь: words.dawg.zip

Инициализация словая в JS:

import {readStringMapDawgSync} from "dawgjs";

let dawg = readStringMapDawgSync('../../data/words.dawg', bytes => {
    let view = new DataView(bytes.buffer);
    return {
        paradigmId: view.getUint16(0, true),
        indexInParadigm: view.getUint8(2)
    };
});
console.log(dawg.get("АБВ"));

Ошибка загрузки словаря:

./dawg/dawgjs-sample/node_modules/dawgjs/factories.js:13
    let dictData = new Uint32Array(buffer, 4, dictSize);
                   ^

RangeError: Invalid typed array length
    at new Uint32Array (native)
    at readByteCompletionDawg (./dawg/dawgjs-sample/node_modules/dawgjs/factories.js:13:20)
    at Object.readStringMapDawg (./dawg/dawgjs-sample/node_modules/dawgjs/factories.js:27:55)
    at Object.readStringMapDawgSync (./dawg/dawgjs-sample/node_modules/dawgjs/factories.node.js:6:24)
    at Object.<anonymous> (./dawg/dawgjs-sample/index.js:3:21)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Окружение:

$ node --version
   v6.9.1

$ sw_vers
   ProductName:    Mac OS X
   ProductVersion: 10.12.2

$ python3 --version
   Python 3.6.0

$ pip3 list
   DAWG (0.7.8)
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