spencermountain / compromise

modest natural-language processing
http://compromise.cool
MIT License
11.31k stars 645 forks source link

syntax tree / dependency parsing #646

Open broskees opened 4 years ago

broskees commented 4 years ago

Hi, saw this in the readme:

dependency parsing: Proper sentence transformation requires understanding the syntax tree of a sentence, which we don't currently do. We should! Help wanted with this.

I looked for about 10 minutes for an issue related to this and didn't find one. So please excuse me if I missed it and there is a better place to be placing this.

I was curious if anything has been done in with this front, and if not, my thoughts were that this topic can be the beginning of a discussion related to this.

spencermountain commented 4 years ago

hey @broskees i'd love some help with this. I'm not sure I understand the problem very well.

in the compromise-sentences plugin, we have very early stabs at this, which need a lot of work.

The process so far:

so in that, we have a basic 'top verb' of the sentence. That's where it's at. I know it's not close to the recursive-tree stuff that is necessary for proper dependency parsing.

Wanna take a stab at it, as a plugin? I can setup some boilerplate code, if you want

cheers

broskees commented 4 years ago

I'd love to; boilerplate code would be extremely helpful.

I understand the issue on some fundamental level. However, I've been doing a great bit of learning more about it for a project I'm currently involved with. So, rather than let that all go to waste, maybe I can get it out in some code and not only achieve the goal I'm going for but make a contribution.

Let me know what you come up with. I'll drop some concepts as I get deeper into it for discussion if I get stuck.

spencermountain commented 4 years ago

ok thanks @broskees i'll create a repo for us to experiment on this with

spencermountain commented 4 years ago

hey @broskees i've created a repo with some rough proof-of-concept here

Feel free to take it for a spin. You'll need to install compromise as a peerDependency, like npm i --no-save compromise

then if you run node ./scratch.js you'll see a basic parsing and response of a sentence.

I built-up a weird Tree and Node class structure, though I have no idea what the best response format would be, for a nested object of phrases.

Up to you! Let me know if I can help. cheers

broskees commented 4 years ago

Hey @spencermountain I'll do my best to give this a whirl this weekend (overall this is probably a bigger tackle than just some time this weekend, but I'll chip away at it). I'll let you know what I come up with.