Coder Social home page Coder Social logo

jgung / verbnet-parser Goto Github PK

View Code? Open in Web Editor NEW
36.0 7.0 10.0 3.09 MB

VerbNet semantic parser and related utilities

License: Apache License 2.0

Java 19.16% HTML 0.07% JavaScript 45.14% CSS 35.61% Dockerfile 0.03%
semantic-role-labeling verbnet

verbnet-parser's Introduction

SemParse

License

SemParse provides common utilities for interfacing with lexical resources in the SemLink project, as well as tools for parsing and extraction. This includes a VerbNet semantic parser, which produces VerbNet thematic roles and semantic predicates.

See a demo of the VerbNet parser in action here!

Quickstart with Docker

A Docker image for running the VerbNet parser demo and API is available here: https://hub.docker.com/r/jgung/verbnet-parser.

docker pull jgung/verbnet-parser:0.1-SNAPSHOT
docker run -p 8080:8080 jgung/verbnet-parser:0.1-SNAPSHOT

Then just open localhost:8080 in your browser, or call the API directly:

curl -s localhost:8080/predict/semantics?utterance=John%20gave%20Mary%20the%20book | python -m json.tool

NOTE: this API has no stability guarantees and will likely change in later versions.

Requirements for Development

semparse-core

Provides a VerbNet parser that uses VerbNet class predictions and PropBank semantic roles to align to a VerbNet frame and produce VerbNet semantic representations.

To use the parser, you will need to download and unzip the pre-trained models and mapping files.

The API is a work in progress (as the project itself is not stable), but an overview of current usage is shown here:

import io.github.clearwsd.parser.*;
import io.github.semlink.verbnet.*;
import io.github.semlink.parser.*;
import io.github.semlink.propbank.type.PropBankArg;
import io.github.semlink.semlink.VerbNetAligner;

import static io.github.semlink.parser.VerbNetParser.pbRoleLabeler;

public class VerbNetParserTest {

    public static void main(String[] args) {
        // VerbNet index over VerbNet classes/frames
        VnIndex verbNet = new DefaultVnIndex();

        // Dependency parser used for WSD model and alignment logic
        NlpParser dependencyParser = new Nlp4jDependencyParser();
        // WSD model for predicting VerbNet classes (uses ClearWSD and the NLP4J parser)
        VerbNetSenseClassifier classifier = VerbNetSenseClassifier.fromModelPath("semparse/nlp4j-verbnet-3.3.bin",
                verbNet, dependencyParser);
        // PropBank semantic role labeler from a TF NLP saved model
        SemanticRoleLabeler<PropBankArg> roleLabeler = pbRoleLabeler("semparse/propbank-srl");
        // maps nominal predicates with light verbs to VerbNet classes (e.g. take a bath -> dress-41.1.1)
        LightVerbMapper verbMapper = LightVerbMapper.fromMappingsPath("semparse/lvm.tsv", verbNet);
        // aligner that uses PropBank VerbNet mappings and heuristics to align PropBank roles with VerbNet thematic roles
        VerbNetAligner aligner = VerbNetAligner.of("semparse/pbvn-mappings.json", "semparse/unified-frames.bin");
        VnPredicateDetector predicateDetector = new DefaultVnPredicateDetector(classifier, verbMapper);

        // simplifying facade over the above components
        VerbNetParser parser = new VerbNetParser(predicateDetector, classifier, roleLabeler, aligner);

        VerbNetParse parse = parser.parse("John ate an apple");
        System.out.println(parse); // Take In[EVENT(E1 = VnClassXml(verbNetId=eat-39.1)), Agent(A0[John]), Patient(A1[an apple])]
    }

}

semparse-tf4j

Wrapper for Tensorflow Java API to load and make predictions with TF-based NLP sequence models exported as saved models from TF-NLP.

semparse-web

A Spring Boot web app with a React frontend to demonstrate VerbNet parsing models.

To build and run the demo yourself, you'll need to copy the pre-trained models and mapping files into the resources folder:

# (download and unzip models as described above into semparse/ directory)
cd verbnet-parser
cp -R semparse/* semparse-web/src/main/resources/
mvn clean install -DskipTests
cd semparse-web
mvn spring-boot:run

Then just open localhost:8080 in your browser.

Try the demo here!

verbnet-parser's People

Contributors

jgung 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

verbnet-parser's Issues

How does the parser decide on a specific VN class when pb-predicate is ambiguous?

Thank you very much for sharing the parser. I wonder how the parse treats pb2vn mapping where pb predicate does not specific enough to identify the VN class?

I noticed that VN is more fine-grained for many cases and there seems to be critical differences in the results depending on. For instance "take.10" in prop bank can be mapped onto three VN classes "54.2", "103", or "54.3". Did you train the model with a VN specific annotated dataset to disambiguate this? OR did you manually chose one out of these three as default cases (not considering the other two?)?

If you took a statistical approach (the former), could you let me know where you got the VN annotated treebank?
If the latter is the approach, I wonder if you could share the overall strategy that you took.

I appreciate the way you handled this disambiguation task.
Thank you in advance!

Missing dependency in semparse-core

semparse-core should also depend on clearwsd-api. VerbNetSenseClassifier.java refers to io.github.clearwsd.ParsingSensePredictor. This bug is in the master branch as of today, 4/2/20.

Sentence length

Hello again,

Another quick question: if I understood correctly the models were trained with the maximum length of 256 characters, so VerbNet Parser can't handle sequences with more than 256 characters. Could you please confirm my understanding?

Thank you very much for your help!

Problems with some char sequences

Hello,

Thank you for the great repo!

I failed to process the following sentence using the docker image locally (and also on the website demo):
He was only a minute or so inside , and then I heard the key turn once more and he passed me and re - entered the house . Apparently something is wrong with the sequence re -: when deleting spaces or removing re, it works.

The error log: verbnet-parser-log-error.txt

Thank you for looking into that!

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.