GithubHelp home page GithubHelp logo

drdub / language Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nathanathan/language

0.0 3.0 0.0 240 KB

A crowdsourcing approach natural language programming

Home Page: https://language-nathanathan.rhcloud.com

License: Other

JavaScript 100.00%

language's Introduction

Language

Use Case:

  1. The user types a command that makes sense to them into a search box. For example:

generate an html form with name age and gender fields draw a teapot sum(1,2,3)

  1. The command is parsed using an ambiguous grammar, generating many possible interpretations. An interpretation is a parse tree with a widget attached to its root (other nodes may also have widgets). A widget is a small webpage that performs a particular function relevant to the interpretation it is attached to.

  2. The user sees a list of widgets corresponding to various interpretations of their command. For example, if the user's command was "draw a teapot" they might see widgets containing various teapot drawings and perhaps widgets with instructions how to draw a teapot. The user can up-vote good interpretations and down-vote irrelevant interpretations to improve future rankings. In addition to votes, probability of occurance also affects an interpration's ranking.

  3. If none of the resulting interpretations are to the user's liking, they can add new language nodes to the grammar that do what they want. This is easily done using a query like "add language node."

Live Examples:

You can see the languageNodes used in all these examples by clicking more->view source.

Language Terminology for computer scientists:

LangNode => Production rule + meta data

Category => Non-termial (LHS of production rule)

Components => RHS of production rule

Interpretation ~> Parse tree

Planned* formats (as json schemas):

*note that the current formats differ in a few ways.

langNode:

    {
        type: "object",
        properties: {
            category: { type: "string" },
            components: {
                type: "array",
                items: [
                    {
                        description: "terminal",
                        type: "string"
                    },
                    {
                        description: "non-terminal",
                        type: "object",
                        properties: {
                            category: {
                                type: ["string", "array"]
                                description: "This can be a category name (which corresponds to an array of language nodes in the database) or an array of language nodes defined inline.",
                            }
                        }
                    },
                    {
                        description: "regular expression",
                        type: "object",
                        properties: {
                            regex: { type: "string" }
                        }
                    },
                ]
            },
            repository: {
                type: "object",
                properties: {
                    type: "gist",
                    gistId: "3925079",
                    lastSync: { type: "string"}
                }
            },
            content: {
                description: "The complete content of the json object used to construct this langNode. You can put any metadata you want here.",
                type: "object"
            }
        }
    }

Interpretation: (Add "&json=true" to your url search strings to see what things actually look like)

    {
        type: "object",
        properties: {
            query: {
                description: "The command/query the user searched for.",
                type: "string"
            },
            category: {
                description: "The category that the search was done under. (e.g. main/science/code)",
                type: "string"
            },
            interpretations: {
                description: "The interpretations of the query",
                type: "array",
                items: {
                    type: "object",
                    description: "A langNode extended with an interpretations array like this one."
                }
            }
        }
    }

Server API:

Upsert language node

TODO

Get parse tree:

//This example uses jQuery and jQuery-URL-Parser
var interpId = $.url().param('interpId'); 
$.getJSON($.url().param('serverUrl') + '/interpretations/' + interpId, function(data) {
	var multiParseTree = data.root;
});

Roadmap:

There is a need for some kind of API to make it easier to deal with multi-parse trees in widgets. One idea I like for this is having callback functions that get called multiple times for each interpretation.

Voting/ranking is not implemented. This will also require github or some other authentication service to prevent ballot box stuffing. First there needs to be enough widgets that there is a need to rank them though.

In the distant future:

Create interface for widgets to request access to resources from the parent site. For example, if the user links their github account to the main site, widgets could request the ability to modify one of the user's repositories from it.

Opt-in personalized rankings.

Parsing of non-textual input (e.g. voice, video)

language's People

Contributors

nathanathan avatar drdub avatar

Watchers

 avatar James Cloos avatar  avatar

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.