backoff_tagger未定义错误

时间:2016-12-25 03:54:39

标签: tags nltk

您好,我试图用Brill Tagger来标记一组句子。但是当运行以下内容时,

=======================

培训Brill Tagger

>>> default_tagger = DefaultTagger('NN')
>>> initial_tagger = backoff_tagger(train_sents, [UnigramTagger,     BigramTagger, TrigramTagger], backoff=default_tagger)
>>> initial_tagger.evaluate(test_sents)
0.8806820634578028
>>> from tag_util import train_brill_tagger
>>> brill_tagger = train_brill_tagger(initial_tagger, train_sents)
>>> brill_tagger.evaluate(test_sents)
0.8827541549751781

我收到以下错误消息。

NameError:name' backoff_tagger'未定义

造成这种情况的原因是什么。我需要导入一些东西

1 个答案:

答案 0 :(得分:1)

我认为您需要导入以下内容:

const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const session = require("express-session");
const cookieParser = require("cookie-parser");
const MongoDBStore = require('connect-mongodb-session')(session);

var app = express();

var store = new MongoDBStore({
  uri: "mongodb+srv://<user><password>@cluster0- 
   okw4h.mongodb.net/productosDB",
  collection: "orders"
});

app.use(express.static("public"));
app.set("view engine", "ejs");

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());


app.use(cookieParser());

store.on('error', function(error) {
  console.log(error);
});

app.use(session({
    secret: "Our little secret.",
    cookie: { expires : new Date(Date.now() + 360000) },
    store: store,
    resave: false,
    saveUninitialized: false
}));

mongoose.connect("mongodb+srv://<user><password>@cluster0- 
   okw4h.mongodb.net/productosDB",
   {useNewUrlParser: true});

const orderSchema = {
    amount: Number,
    name: String,
    price: Number,
    total: Number
};

app.post("/cambio", function(req, res) {
   var inputValue = req.body.vote;

    if (inputValue == "add") {
    var cantidad = req.body.option;
    var name = productName.name;
    var price = productName.price;

    totalPrice = cantidad * price;

     const order = new Order ({
       amount: cantidad,
       name: name,
       price: price,
       total: totalPrice
    });

    res.redirect("/cambio");
   }
});