Git Product home page Git Product logo

entity.extraction's Introduction

Entity.Extraction

This work is loosely based on SharpNLP.

Here's a quick code example of training and consuming a model that could be used for parsing a recipe:

var tokenizer = new Tokenizer();
var annotator = Annotator.Default();
var context = new Context(4);
var trainer = new Trainer(tokenizer, annotator, context);

// Add some training text. Words that will be labeled are added using _<label name>.
trainer.AddSample("1_amount (8_amount ounce) can_uom Pillsbury® refrigerated crescent dinner_ingredient rolls_ingredient\r\n");
trainer.AddSample("1_amount /_amount 4_amount cup_uom pizza_ingredient sauce_ingredient\r\n");
trainer.AddSample("3_amount /_amount 4_amount cup_uom shredded mozzarella_ingredient cheese_ingredient\r\n");
trainer.AddSample("1_amount /_amount 2_amount cup_uom sliced pepperoni_ingredient\r\n");
trainer.AddSample("2_amount /_amount 3_amount cup_uom sliced pepperoni_ingredient\r\n");
trainer.AddSample("7_amount /_amount 8_amount cup_uom sliced pepperoni_ingredient\r\n");
trainer.AddSample("11_amount teaspoon_uom grated Parmesan_ingredient cheese_ingredient\r\n");
trainer.AddSample("2_amount teaspoons_uom crushed garlic_ingredient\r\n");
trainer.AddSample("1_amount /_amount 4_amount cup_uom olive_ingredient oil_ingredient\r\n");
trainer.AddSample("4_amount skinless_preparation , boneless_preparation chicken_ingredient breast_ingredient halves\r\n");
trainer.AddSample("2_amount eggs_ingredient\r\n");
trainer.AddSample("3_amount eggs_ingredient\r\n");
trainer.AddSample("1_amount /_amount 3_amount cup_uom butter_ingredient , melted\r\n");
trainer.AddSample("1_amount cup_uom fresh orange_ingredient juice_ingredient\r\n");
trainer.AddSample("1_amount /_amount 2_amount cup_uom 2_ingredient %_ingredient milk_ingredient\r\n");
trainer.AddSample("This article has assumed that regular_programming expressions_programming are matched against an entire input string.");
trainer.AddSample("Modern regular expression implementations must deal with large non-ASCII_programming character sets such as Unicode. ");

// train the model
var gisTrainer = new GisTrainer();
gisTrainer.TrainModel(500, new TwoPassDataIndexer(trainer, 0));
var model = new GisModel(gisTrainer);

// initialize the tagger
var tagger = new Tagger(tokenizer, context, annotator, model);

foreach (var file in Directory.GetFiles("examples", "*.txt"))
{
	var text = File.ReadAllText(file);

	var probabilities = new double[0];
	var tokens = tagger.Tag(text, out probabilities);
}

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.