Giter Club home page Giter Club logo

js-mdict's Introduction

js-mdict

npm version GitHub issues GitHub forks GitHub stars GitHub license

mdict (*.mdd *.mdx) file reader based on jeka-kiselyov/mdict .

Very thanks to fengdh and jeka-kiselyov.

Usage

NOTE: This version has a lot of changes, please read the example code carefully!

注意: 本版本改动了多个API, 请仔细阅读上方的示例代码。

not support browser

npm install [email protected]
// import Mdict from "../src/mdict";
const Mdict = require("../lib/mdict.js").default;

// Note: *.mdd file only support lookup method.

// loading dictionary
const dict = new Mdict("mdx/testdict/oale8.mdx");

// search a word
console.log(dict.lookup("hello"));
/*

{
  keyText: 'hello',
  definition: `<link rel="stylesheet" type="text/css" href="oalecd8e.css"><script src="jquery.js" charset="utf-8" type="text/javascript" language="javascript"></script><script src="oalecd8e.js" charset="utf-8" type="text/javascript" language="javascript"></script><span name="hello" id="hello_e" idm_id="000016945" class="entry"><span class="h-g"><span class="top-g"><span class="h">hello</span><span class="oalecd8e_show_all"><em></em></span> <span class="z"> <span class="symbols-coresym">★</span> </span><span class="vs-g"><span class="z_br"> (</span><span class="z_vs-g">also </span><span class="vs">hullo</span><span class="label-g"> <span class="g">especially in BrE</span></span><span class="z_br">) </span></span><span class="vs-g"><span class="z_br"> (</span><span class="label-g"><span class="g">BrE also </span></span> <span class="vs">hallo</span><span class="z_br">) </span></span> <span class="ei-g"><span class="z_ei-g">/</span><a class="fayin" href="sound://uk/hello__gb_1.mp3"><span class="phon-gb">həˈləʊ</span><img src="uk_pron.png" class="fayin"/></a><span class="z">; <span class="z_phon-us">NAmE</span></span><a class="fayin" href="sound://us/hello__us_1.mp3"><span class="phon-us">həˈloʊ</span><img src="us_pron.png" class="fayin"/></a><span class="z_ei-g">/</span></span><span class="block-g"><span class="pos-g"> <span class="pos">exclamation</span><span class="z">, </span><span class="pos">noun</span> </span></span><span class="ifs-g"><span class="z_br"> (</span><span class="if-g"><span class="il">pl.</span> <span id="hello_if_1" class="if">hellos</span><span class="z">, </span><span id="hello_if_2" class="if">hullos</span><span class="z">, </span><span id="hello_if_3" class="if">hallos</span></span><span class="z_br">) </span></span></span><span id="hello_ng_1" class="n-g"><span class="z_n">1. </span><span class="symbols-small_coresym">★</span> <span class="def-g"><span class="ud oalecd8e_switch_lang switch_children">used as a <a class="ndv" href="entry://greeting">greeting</a> when you meet sb, when you answer the telephone or when you want to attract sb's attention <span class="oalecd8e_chn">(用于问候、接电话或引起注意)哈罗,喂,你好</span></span></span><span id="hello_xg_1" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">Hello John, how are you? </span><span class="oalecd8e_chn">哈罗,约翰,你好吗?</span></span><span id="hello_xg_2" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">Hello, is there anybody there? </span><span class="oalecd8e_chn">喂,那里有人吗?</span></span><span id="hello_xg_3" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings"><span class="cl">Say hello</span> to Liz for me. </span><span class="oalecd8e_chn">替我向利兹问好。</span></span><span id="hello_xg_4" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">They exchanged hellos<span class="gl"> (= said hello to each other) </span>and forced smiles. </span><span class="oalecd8e_chn">他们相互打个招呼,勉强笑笑。</span></span></span><span id="hello_ng_2" class="n-g"><span class="z_n">2. </span><span class="def-g"><span class="label-g"> (<span class="g">BrE</span>) </span><span class="ud oalecd8e_switch_lang switch_children">used to show that you are surprised by sth <span class="oalecd8e_chn">(表示惊讶)嘿</span></span></span><span id="hello_xg_5" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">Hello, hello, what's going on here? </span><span class="oalecd8e_chn">嘿,嘿,这是在干吗?</span></span></span><span id="hello_ng_3" class="n-g"><span class="z_n">3. </span><span class="def-g"><span class="label-g"> (<span class="r">informal</span>) </span><span class="ud oalecd8e_switch_lang switch_children">used to show that you think sb has said sth stupid or is not paying attention <span class="oalecd8e_chn">(认为别人说了蠢话或分心)喂,嘿</span></span></span><span id="hello_xg_6" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">Hello? You didn't really mean that, did you? </span><span class="oalecd8e_chn">嘿?你不会真是那个意思吧?</span></span><span id="hello_xg_7" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">I'm like, ‘Hello! Did you even listen?’ </span><span class="oalecd8e_chn">我说:“嘿!你到底有没有听我说话?”</span></span></span><span class="xr-g"> <span class="symbols-xrsym">➔</span> see also <span id="hello_xr_1" href="goldenhello_e" class="xr"><span class="Ref"> <span class="xh"> <a href="entry://golden hello">golden hello</a></span> </span></span></span><span class="table"><span class="tr"><span class="th"><a href="#O8T">MORE ABOUT 补充说明</a></span></span><span class="tr"><span class="td"><span name="greetings" id="hello_un_1" class="unbox"><span class="title">greetings <span class="oalecd8e_chn">打招呼</span></span><span class="para"><span class="symbols-para_square">■ </span><span class="und oalecd8e_switch_lang switch_children"> <span class="unfm">Hello</span> is the most usual word and is used in all situations, including answering the telephone. <span class="oalecd8e_chn"><span class="ast">*</span> Hello 最为常用,用于所有场合,包括接电话。</span></span></span><span class="para"><span class="symbols-para_square">■ </span><span class="und oalecd8e_switch_lang switch_children"> <span class="unfm">Hi</span> is more informal and is now very common. <span class="oalecd8e_chn"><span class="ast">*</span> Hi 较非正式,现在使用很普遍。</span></span></span><span class="para"><span class="symbols-para_square">■ </span><span class="und oalecd8e_switch_lang switch_children"> <span class="unfm">How are you?</span> or <span class="unfm">How are you doing?</span> (<span class="r">very informal</span>) often follow <span class="unfm">Hello</span> and <span class="unfm">Hi.</span> <span class="oalecd8e_chn"><span class="ast">*</span> How are you? 或 How are you doing?(非常口语化)常用于 Hello 和 Hi 之后:</span></span><span id="hello_xg_8" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">‘Hello, Mark.’ ‘Oh, hi, Kathy! How are you?’ </span><span class="oalecd8e_chn">“马克,你好。” “噢,凯西,你好!最近好吗?”</span></span></span><span class="para"><span class="symbols-para_square">■ </span><span class="und oalecd8e_switch_lang switch_children"> <span class="unfm">Good morning</span> is often used by members of a family or people who work together when they see each other for the first time in the day. It can also be used in formal situations and on the telephone. In informal speech, people may just say <span class="unfm">Morning.</span> <span class="oalecd8e_chn"><span class="ast">*</span> Good morning 常在家庭成员或同事之间一天中第一次见面时说,亦可用于正式场合和电话中。在非正式谈话中,可只说 Morning。</span></span></span><span class="para"><span class="symbols-para_square">■ </span><span class="und oalecd8e_switch_lang switch_children"> <span class="unfm">Good afternoon</span> and <span class="unfm">Good evening</span> are much less common. <span class="unfm">Good night</span> is not used to greet somebody, but only to say goodbye late in the evening or when you are going to bed. <span class="oalecd8e_chn"><span class="ast">*</span> Good afternoon 和 Good evening 少用得多。Good night 只在晚上说再见或上床睡觉前说,不用以打招呼。</span></span></span><span class="para"><span class="symbols-para_square">■ </span><span class="und oalecd8e_switch_lang switch_children">If you are meeting someone for the first time, you can say <span class="unfm">Pleased to meet you</span> or <span class="unfm">Nice to meet you</span> (<span class="r">less formal</span>). Some people use <span class="unfm">How do you do?</span> in formal situations. The correct reply to this is <span class="unfm">How do you do?</span> . <span class="oalecd8e_chn">第一次与人见面时可说 Pleased to meet you 或 Nice to meet you(较非正式)。在正式场合有些人用 How do you do? ,正确的回答是 How do you do?。</span></span></span></span></span></span></span><span class="infl"><span class="inflection">hello</span> <span class="inflection">hellos</span> </span></span><span class="pracpron"><span class="pron-g"><span class="wd">hello</span> <span class="ei-g"><span class="z_ei-g">/</span><a class="fayin" href="sound://uk/hello__gb_1.mp3"><span class="phon-gb">həˈləʊ</span><img src="uk_pron.png" class="fayin"/></a><span class="z">; <span class="z_phon-us">NAmE</span></span><a class="fayin" href="sound://us/hello__us_1.mp3"><span class="phon-us">həˈloʊ</span><img src="us_pron.png" class="fayin"/></a><span class="z_ei-g">/</span></span></span></span></span>\r\n` +
    '\x00'
}
  */

console.log(dict.prefix("hell"));

/*
[
  {
    recordStartOffset: 65513175,
    keyText: 'hell',
    keyBlockIdx: 26,
    original_idx: 44204,
    nextRecordStartOffset: 65533900,
    key: 'hell',
    rofset: 65513175
  },
  {
    recordStartOffset: 65533900,
    keyText: 'hell-bent',
    keyBlockIdx: 26,
    original_idx: 44205,
    nextRecordStartOffset: 65535903,
    key: 'hell-bent',
    rofset: 65533900
  },
  {
    recordStartOffset: 65535903,
    keyText: 'hellebore',
    keyBlockIdx: 26,
    original_idx: 44206,
    nextRecordStartOffset: 65537736,
    key: 'hellebore',
    rofset: 65535903
  },
  ...
]
  */

// NOTE: the `suggest` method has been depreciated

word = "hitch";
const fws = dict.fuzzy_search(word, 3, 1);
console.log(fws);
/*
[
[
  {
    recordStartOffset: 3100575,
    keyText: 'aitch',
    keyBlockIdx: 1,
    original_idx: 1930,
    nextRecordStartOffset: 3102663,
    key: 'aitch',
    idx: 3100575,
    ed: 1
  },
  {
    recordStartOffset: 10538065,
    keyText: 'batch',
    keyBlockIdx: 4,
    original_idx: 7046,
    nextRecordStartOffset: 10542859,
    key: 'batch',
    idx: 10538065,
    ed: 2
  },
  {
    recordStartOffset: 13472522,
    keyText: 'birch',
    keyBlockIdx: 5,
    original_idx: 9488,
    nextRecordStartOffset: 13476855,
    key: 'birch',
    idx: 13472522,
    ed: 2
  }
]
]

  */
console.log(dict.fetch_defination(fws[0]));
/*

{
  keyText: 'aitch',
  definition: '<link rel="stylesheet" type="text/css" href="oalecd8e.css"><script src="jquery.js" charset="utf-8" type="text/javascript" language="javascript"></script><script src="oalecd8e.js" charset="utf-8" type="text/javascript" language="javascript"></script><span id="aitch_e" name="aitch" idm_id="000000810" class="entry"><span class="h-g"><span class="top-g"><span class="h">aitch</span><span class="oalecd8e_show_all"><em></em></span> <span class="ei-g"><span class="z_ei-g">/</span><a class="fayin" href="sound://uk/aitch__gb_1.mp3"><span class="phon-gb">eɪtʃ</span><img src="uk_pron.png" class="fayin"/></a><span class="z">; <span class="z_phon-us">NAmE</span></span><a class="fayin" href="sound://us/aitch__us_1.mp3"><span class="phon-usgb">eɪtʃ</span><img src="us_pron.png" class="fayin"/></a><span class="z_ei-g">/</span></span><span class="block-g"><span class="pos-g"> <span class="pos">noun</span> </span></span></span> <span class="def-g"><span class="d oalecd8e_switch_lang switch_children">the letter H written as a word <span class="oalecd8e_chn">字母 H</span></span></span><span id="aitch_xg_1" class="x-g"><span class="symbols-xsym"></span><span class="x oalecd8e_switch_lang switch_siblings">He spoke with a cockney accent and <span class="cl">dropped his aitches</span> <span class="gl"> (= did not pronounce the letter H at the start of words).</span> </span><span class="oalecd8e_chn">他带伦敦东区的口音,总是漏发词首的 h 音。</span></span><span class="infl"><span class="inflection">aitch</span> <span class="inflection">aitches</span> </span></span><span class="pracpron"><span class="pron-g"><span class="wd">aitch</span> <span class="ei-g"><span class="z_ei-g">/</span><a class="fayin" href="sound://uk/aitch__gb_1.mp3"><span class="phon-gb">eɪtʃ</span><img src="uk_pron.png" class="fayin"/></a><span class="z">; <span class="z_phon-us">NAmE</span></span><a class="fayin" href="sound://us/aitch__us_1.mp3"><span class="phon-usgb">eɪtʃ</span><img src="us_pron.png" class="fayin"/></a><span class="z_ei-g">/</span></span></span></span></span>\r\n' +
    '\x00'
}


  */

depreciate if you use js-mdict @2.0.3, you can use api shown below:

Note: 2.0.3 not supports mdd file, and record info encrypted file

import path from 'path';
import Mdict from 'js-mdict';

const dictPath = path.join(__dirname, '../resource/Collins.mdx');
const mdict = new Mdict(dictPath);
mdict
  .build()
  .then((_mdict) => {
    console.log('hello', _mdict.lookup('hello'));
    console.log('world', _mdict.lookup('world'));
    console.log(_mdict.attr());
  })
  .catch((err) => {
    console.error(err);
  });

Release

v5.0.0

NOTE: This version has a lot of changes, please read the example code example carefully!

注意: 本版本改动了多个API, 请仔细阅读上方的示例代码。

BREAKING CHANGES:

  1. Refactor the key search algorithm: build the keyList first, and resort internally, then search the word
  2. The suggest method has been deprecated.
  3. The parse_definition method has been deprecated, use fetch_definition instead
  4. Delete nspell and en-dictionary-us dependencies
  5. Cleanup unstable compare method and key record compare, won't use keyInfoBlock.firstKey/lastKey to locate recordBlock
  6. Use built-in TextDecoder and zlib, instead of third party TextDecoder and pako.
  7. use pnpm instead of yarn to manage the dependencies.
  8. Have fun!

v4.0.20

  1. upgrade xmldom to v0.7.5

v4.0.19

  1. support rangeKey API

v4.0.18

  1. add rangeKeyBlock interface
  2. enhance performance of readKeyBlock

v4.0.17

  1. fix associate can't find special character bug

v4.0.16

  1. fix accurate record start offset parse_definition bug

v4.0.15

  1. fix findList return undefined will crash the associate and prefix method bug

v4.0.14

  1. fix babel-runtime dependencies issue

v4.0.13

  1. fix UpperCase key sensitive options logic, details #41
  2. fix 1.2 mdx keyblock read bug
  3. correct some Header properties (StripKey..)

very thanks to @songxiaocheng

v4.0.12

  1. fix typings declaring and reformat codebase

v4.0.11

  1. fix some .mdd file reading issues, and if you search mdd file, use lookup method, and it will return base64 data

v4.0.10

  1. rewrite typings/mdict.d.ts

v4.0.9

  1. rename typings/Mdict.d.ts to typings/mdict.d.ts

v4.0.8

  1. fix uppercase words comparing missed bug
  2. fix out of index error when cannot locate word offset
  3. if cannot find the word key block, return undefined

v4.0.7

  1. rename Mdict.js to mdict.js , rename MdictBase.js to mdict-base.js, fix import error on ubuntu.

v4.0.6

  1. support search words by prefix associate (the phrase as the words' prefix, not the phrase's prefix as search token just like prefix function)
  2. some security updates

very thanks to @Danjame

v4.0.x

  1. ES6 implemention
  2. rewrite the decode code, more readable decode api
  3. NOT SUPPORT BROWSER CURRENTLY

v3.1.0 (2018-08-22)

  1. add fuzzy_search method, which supports fuzzy word search

MDX/MDD Layout

layout

this picture is from @ikey4u/wikit

code by terasum with ❤️

js-mdict's People

Contributors

danjame avatar dependabot[bot] avatar songxiaocheng avatar terasum avatar yangcurve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

js-mdict's Issues

部分单词查询 不准确

比如《新牛津英汉双解大词典》查询 word 的结果是 -word.
可能是词典的原因,也可能是程序的原因,这我无法确定。作者有空看下。

补充:
新牛津英汉双解大词典.zip

比如单词 be
《新牛津英汉双解大词典里》be/Be/BE 都是有的。但 be 查不到。
《欧路词典》则一次将三个都查了出来。

再补充一些不准确的单词:and、in、for、on、by、who、up

lookup 方法 nextStart 计算疑问

    const i = record.idx;
    const list = record.list;
    const rid = this._reduceRecordBlock(list[i].recordStartOffset);
    const nextStart =
      i + 1 >= list.length
        ? this._recordBlockStartOffset +
          this.recordBlockInfoList[this.recordBlockInfoList.length - 1]
            .decompAccumulator +
          this.recordBlockInfoList[this.recordBlockInfoList.length - 1]
            .decompSize
        : list[i + 1].recordStartOffset;

list 是当前块的单词列表,但当最后一个单词的时候,偏移值却是根据最后一个 block 计算的。虽然最后查询结果没问题——_decodeRecordBlockByRBID 是截取的当前块的数据,就算 nextStart 超出也没关系。
不确定 nextStart 的计算是否是有意这么写的。

关于 `keyCaseSensitive` 和 `stripKey` 的预期行为

keyCaseSensitive 为例,当同时存在仅大小写不同的单词时,期望的行为是如何?

比如测试词典中的"dict-01-袖珍葡汉汉葡词典(简体版).mdx"设置的是 KeyCaseSensitive: 'No', 词典中同时存在 holanda 和 Holanda,当查询其中一个词条时,有以下几种方式:

  1. 强行大小写敏感,这是 #37 之前事实上的效果
  2. 对大小写不敏感的词典,先搜到哪个是就用哪个,这是 #37 之后的效果,造成 test 中上述测试失败
  3. 两个均都同时返回(考虑以数组或拼合的方式)
  4. 若存在大小写相同的精确匹配,则返回该条目,否则返回大小写不敏感的匹配

其实我认为该测试词典的制作是有不妥的,因为既然设置了大小写不敏感,就不应同时提供两个仅大小写不同的词条,应该将二者放在同一个词条里,或者设置大小写敏感。

第1种方式我认为应当首先排除,因为其无视了词典的设置。该库调用者若有需要可以强行覆盖设置的。

不过,若需要兼容部分词典已经发生这种现象(大小写不敏感但是大小写分不同词条)的既定事实,则需考虑其它方式。

第2种方式我认为也应当排除,因为造成使用上的不便(我们不希望搜索“Holanda”时,词典中明明存在“Holanda”,却只返回“holanda”,造成词典中的“Holanda”无法被查询到)。

方式3的问题是,若以拼合字符串返回,则相当于事实上调整了词条内容,作为 mdict reader 这样似乎也不妥;若以数组返回,则需要改动接口。

方式4的话感觉最佳?

方式3和方式4实现起来很可能都需要二次查询。

`fuzzy_search` 函数签名与实现不一致

虽然发现以前解决过这个问题(#4),不过现在我用了五个词典测试,都返回为空,用了 README 里面示例的单词”hitch“,也试了其它单词,全部返回为空数组。

raise error when import v4.0.13

Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
    at webpackMissingModule (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:118902:99)
    at Object../node_modules/js-mdict/lib/mdict.js (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:118902:218)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/service/mainsvc/main.service.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137345:34)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/service/service.manifest.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137503:22)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/service/service.main.register.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137452:26)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/main/init.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137134:1)

TypeError: Mdict is not a constructor

作者您好,JavaScript我不是太熟悉。按照documentation 运行的时候terminal报告了这个错误,请问应该怎么解决,谢谢

Type Definition file?

Hi, i need to use some .mdx dictionary files in a typescript project. Do you plan to provide a type definition file for your library?

npm 包在Ubuntu服务器上无法被加载

在远程服务器上测试后发现目前的构建出来的模块无法被加载。
经过排查发现:

  1. package.json 中定义了"main": "lib/Mdict.js",但是构建出来的是 lib/mdict.js,由于首字母大小写的差异会导致在远程服务器Ubuntu上会出现 cannot find module ,手动把首字母改回大写后正常加载。
  2. 上一个版本构建出来的是 Mdict.js,加载没有问题。

该问题在本地测试不会出现。

fuzzy_search return empty array with some keywords

Thanks a lot for your project.
I found that the method fuzzy_search many times doesnt return a correct result as other mdict apps or webs do. For some words it works well but fot others It doesnt.

For example, in the dictionary mdx there are many key text starts with 'on', but the fuzzy_search method returns a empty array and I did pass fuzzy_size, ed_gap params.

I was trying to figure out the problem but the MdictBase file is too heard for me.

Mdict is not a constructor?

Hi, I am trying out this module but got a TypeError: Mdict is not a constructor.

I tested it this way: create a main.js file, npm install js-mdict, add the following lines to the script file and run it in the console by node main.js. I tried with node v17.3 and v18.15 but neither worked out for me.

import Mdict from 'js-mdict';
const dict = new Mdict('./testDict/data.mdx');  // <= error
console.log('lookup red', dict.lookup('red'));

Am I using the module correctly?

Thank you for your help!

mdict.js _findList 返回值可能是 undefined,后续取值会报错

  _findList(word) {
    const findListInternal = (compareFn) => {
      const sfunc = this._stripKey();
      const kbid = this._reduceWordKeyBlock(word, sfunc, compareFn);
      // not found
      if (kbid < 0) {
        return undefined;
      }
      return { sfunc, kbid, list: this._decodeKeyBlockByKBID(kbid) };
    };

    let list;
    if (this._isKeyCaseSensitive()) {
      list = findListInternal(common.normalUpperCaseWordCompare);
    } else {
      list = findListInternal(common.normalUpperCaseWordCompare);
      if (list === undefined) {
        list = findListInternal(common.wordCompare);
      }
    }
    return list;
  }

findListInternal 会返回 undefined,后续操作报错,比如:this._findList(phrase).list

类型声明与实现不一致

  1. mdict.d.ts 中,class Mdict 的方法全都返回的值,然而实现中 suggest 方法返回的却是 Promise
  2. mdict.d.ts 中,prefixfuzzy_searchassociate 方法均返回 Array<WordIndex>WordIndex声明如下:
    declare interface WordIndex {
    keyText: string
    roffset: number
    ed?: number
    }

    然而,prefixfuzzy_search 实际返回的元素属性为 keyrofsetassociate 实际返回的为 keyTextrecordStartOffset,均与类型声明不一致。

多文件词典读取错误

assert.js:339
    throw err;
    ^

AssertionError [ERR_ASSERTION]: key_block_info length should equal
    at Mdict._decodeKeyBlockInfo (/Users/x/Projs/youdao_wordbook_tool/node_modules/js-mdict/lib/MdictBase.js:391:28)
    at Mdict._readKeyBlockInfo (/Users/x/Projs/youdao_wordbook_tool/node_modules/js-mdict/lib/MdictBase.js:354:35)
    at Mdict.MDictBase (/Users/x/Projs/youdao_wordbook_tool/node_modules/js-mdict/lib/MdictBase.js:114:10)
    at new Mdict (/Users/x/Projs/youdao_wordbook_tool/node_modules/js-mdict/lib/Mdict.js:54:95)

用的是这本词典https://www.pdawiki.com/forum/thread-35803-1-1.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.