open-language / en-dictionary

En-Dictonary is a node.js module which makes works and their relations available as a package.
MIT License
10 stars 3 forks source link

Dictionary contain only verb #13

Closed terrierscript closed 3 years ago

terrierscript commented 3 years ago

Dictionaly only return verb.

I think this problem occured because overwrited on this addIndex https://github.com/open-language/en-dictionary/blob/b8ebef75f9e3d1d8b3e0ddadcac4827f28c2f3c9/src/reader/index.ts#L33

terrierscript commented 3 years ago

sorry, I read version 1.x source code.

terrierscript commented 3 years ago

I found overwrite on offset data. indexLemmaIndex is set separate with pos https://github.com/open-language/en-dictionary/blob/b8ebef75f9e3d1d8b3e0ddadcac4827f28c2f3c9/src/database/index.ts#L43-L51

but dataOffsetIndex and dataLemmaIndex is not separated https://github.com/open-language/en-dictionary/blob/b8ebef75f9e3d1d8b3e0ddadcac4827f28c2f3c9/src/database/index.ts#L96

winterdl commented 1 year ago

same issue:

const wordnet = require("en-wordnet").default;
const Dictionary = require("en-dictionary").default;

const start = async () => {
  const dictionary = new Dictionary(wordnet.get("3.1"));
  await dictionary.init();

  const result = dictionary.searchFor(["good"]);

  console.log(result.get('good'));
};
start();

only return noun data:

Map(1) {
  'good' => {
    lemma: 'good',
    pos: 'noun',
    offsetCount: 4,
    pointerCount: 4,
    pointers: [ [Object], [Object], [Object], [Object] ],
    senseCount: 4,
    tagSenseCount: 3,
    offsets: [ 5167108, 4856472, 5149427, 3080712 ],
    isComment: false,
    offsetData: [ [Object], [Object], [Object], [Object] ]
  }
}

All data must be:

Noun

S: (n) good (benefit) "for your own good"; "what's the good of worrying?"
S: (n) good, goodness (moral excellence or admirableness) "there is much good to be found in people"
S: (n) good, goodness (that which is pleasing or valuable or useful) "weigh the good against the bad"; "among the highest goods of all are happiness and self-realization"
S: (n) commodity, trade good, good (articles of commerce)

Adjective

S: (adj) good (having desirable or positive qualities especially those suitable for a thing specified) "good news from the hospital"; "a good report card"; "when she was good she was very very good"; "a good knife is one good for cutting"; "this stump will make a good picnic table"; "a good check"; "a good joke"; "a good exterior paint"; "a good secretary"; "a good dress for the office"
S: (adj) full, good (having the normally expected amount) "gives full measure"; "gives good measure"; "a good mile from here"
S: (adj) good (morally admirable)
S: (adj) estimable, good, honorable, respectable (deserving of esteem and respect) "all respectable companies give guarantees"; "ruined the family's good name"
S: (adj) beneficial, good (promoting or enhancing well-being) "an arms limitation agreement beneficial to all countries"; "the beneficial effects of a temperate climate"; "the experience was good for her"
S: (adj) good (agreeable or pleasing) "we all had a good time"; "good manners"
S: (adj) good, just, upright (of moral excellence) "a genuinely good person"; "a just cause"; "an upright and respectable man"
S: (adj) adept, expert, good, practiced, proficient, skillful, skilful (having or showing knowledge and skill and aptitude) "adept in handicrafts"; "an adept juggler"; "an expert job"; "a good mechanic"; "a practiced marksman"; "a proficient engineer"; "a lesser-known but no less skillful composer"; "the effect was achieved by skillful retouching"
S: (adj) good (thorough) "had a good workout"; "gave the house a good cleaning"
S: (adj) dear, good, near (with or in a close or intimate relationship) "a good friend"; "my sisters and brothers are near and dear"
S: (adj) dependable, good, safe, secure (financially safe) "a good investment"; "a secure investment"
S: (adj) good, right, ripe (most suitable or right for a particular purpose) "a good time to plant tomatoes"; "the right time to act"; "the time is ripe for great sociological changes"
S: (adj) good, well (resulting favorably) "it's a good thing that I wasn't there"; "it is good that you stayed"; "it is well that no one saw you"; "all's well that ends well"
S: (adj) effective, good, in effect, in force (exerting force or influence) "the law is effective immediately"; "a warranty good for two years"; "the law is already in effect (or in force)"
S: (adj) good (capable of pleasing) "good looks"
S: (adj) good, serious (appealing to the mind) "good music"; "a serious book"
S: (adj) good, sound (in excellent physical condition) "good teeth"; "I still have one good leg"; "a sound mind in a sound body"
S: (adj) good, salutary (tending to promote physical well-being; beneficial to health) "beneficial effects of a balanced diet"; "a good night's sleep"; "the salutary influence of pure air"
S: (adj) good, honest (not forged) "a good dollar bill"
S: (adj) good, unspoiled, unspoilt (not left to spoil) "the meat is still good"
S: (adj) good (generally admired) "good taste"

Adverb

S: (adv) well, good ((often used as a combining form) in a good or proper or satisfactory manner or to a high standard (`good' is a nonstandard dialectal variant for `well')) "the children behaved well"; "a task well done"; "the party went well"; "he slept well"; "a well-argued thesis"; "a well-seasoned dish"; "a well-planned party"; "the baby can walk pretty good"
S: (adv) thoroughly, soundly, good (completely and absolutely (`good' is sometimes used informally for `thoroughly')) "he was soundly defeated"; "we beat him good"

update: I used 1.2.4 version from npm, the code was outdate with the repo.

current github version return full data:

Map(1) {
  'good' => Map(3) {
    'adverb' => {
      lemma: 'good',
      pos: 'adverb',
      offsetCount: 2,
      offsets: [Array],
      offsetData: [Array],
      pointerCount: 1,
      pointers: [],
      senseCount: 2,
      tagSenseCount: 2,
      isComment: false
    },
    'adjective' => {
      lemma: 'good',
      pos: 'adjective',
      offsetCount: 21,
      offsets: [Array],
      offsetData: [Array],
      pointerCount: 5,
      pointers: [Array],
      senseCount: 21,
      tagSenseCount: 14,
      isComment: false
    },
    'noun' => {
      lemma: 'good',
      pos: 'noun',
      offsetCount: 4,
      offsets: [Array],
      offsetData: [Array],
      pointerCount: 4,
      pointers: [Array],
      senseCount: 4,
      tagSenseCount: 3,
      isComment: false
    }
  }
}