Giter Site home page Giter Site logo

philipphager / docker-ingredient-phrase-tagger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from archsirius/docker-ingredient-phrase-tagger

0.0 3.0 0.0 777 KB

Extract structured data from ingredient phrases using conditional random fields http://open.blogs.nytimes.com/2016/04/27/structured-ingredients-data-tagging/

License: Apache License 2.0

Dockerfile 74.87% Shell 25.13%

docker-ingredient-phrase-tagger's Introduction

CRF Ingredient Phrase Tagger

This is a Docker-contained version of NYTimes' ingredient-phrase-tagger, for the parsing function. It acts as a pre-packaged wrapper to use the tool more easily. For more details on the tool itself, please refer to the original documentation (link above).

Given the following input:

1 pound carrots, young ones if possible
Kosher salt, to taste
2 tablespoons sherry vinegar
2 tablespoons honey
2 tablespoons extra-virgin olive oil
1 medium-size shallot, peeled and finely diced
1/2 teaspoon fresh thyme leaves, finely chopped
Black pepper, to taste

It produces something like:

[
    {
        "qty":     "1",
        "unit":    "pound"
        "name":    "carrots",
        "other":   ",",
        "comment": "young ones if possible",
        "input":   "1 pound carrots, young ones if possible",
        "display": "<span class='qty'>1</span><span class='unit'>pound</span><span class='name'>carrots</span><span class='other'>,</span><span class='comment'>young ones if possible< /span>",
    },
    ...
]

Usage

To start, use, then remove the container once done, simply execute the following command, assuming input.txt contains a list of ingredients, one per line.

$ docker run -i --rm archsirius/ingredient-phrase-tagger < input.txt

You can also pipe output directly.

$ cat input.txt | docker run -i --rm archsirius/ingredient-phrase-tagger
$ echo "1 cup milk" | docker run -i --rm archsirius/ingredient-phrase-tagger

Results will be sent to STDOUT, so it can easily be written to any file, or piped to another program.

$ docker run -i --rm archsirius/ingredient-phrase-tagger < input.txt > output.json

The -i option is required to read from STDIN. The --rm option is optional but useful to remove the container once the job is completed, since it is not daemonized.

It may take a few moments for results to appear with large input, as the original tool uses intermediate files and waits to tag all the input data before writing to the output CRF++ file, then converting it to JSON.

License

Apache 2.0.

docker-ingredient-phrase-tagger's People

Contributors

archsirius avatar

Watchers

 avatar  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.