Coder Social home page Coder Social logo

abhidipbhattacharyya / verbnet-parser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jgung/verbnet-parser

0.0 0.0 0.0 3.08 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%

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!

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.