Mallet:Alphabets不匹配,在一个程序中再次制作模型时例外

时间:2018-01-16 07:44:55

标签: java mallet

我已经探索过槌,它运作良好。我想要做的是在程序范围内制作一个模型两次并面临异常。我的程序代码如下:

List<String> commands = new ArrayList<String>();
commands.add("--input input.mallet --output-classifier output_classifier.classifier --trainer MaxEnt --report train:accuracy");

commands.add("--input input.mallet --output-classifier output_classifier.classifier --trainer MaxEnt --report train:accuracy");

for( int index = 0; index < commands.size(); index++ ) {
    try {
        Vectors2Classify.main(commands.get(index).split(" "));
    } catch (EvalError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

第一个命令正在成功运行。在第二个命令我得到以下异常。

Exception in thread "main" java.lang.IllegalArgumentException: Alphabets don't match: Instance: [9327, 3], InstanceList: [9327, 3]

    at cc.mallet.types.InstanceList.add(InstanceList.java:335)
    at cc.mallet.types.InstanceList.shallowClone(InstanceList.java:213)
    at cc.mallet.types.InstanceList.split(InstanceList.java:513)
    at cc.mallet.classify.tui.Vectors2Classify.main(Vectors2Classify.java:397)

我已经搜索过这个问题,但直到现在才找到任何解决方案。看起来直到现在在程序范围内制作模型两次都没有人尝试过 如果有人能帮助我,请感谢你。

1 个答案:

答案 0 :(得分:0)

onDateChangedListener函数旨在在程序执行期间调用一次。可能有一些变量从一次调用转移到另一次调用。这个 TOSalesInvoiceCollection salesinvoiceCollection = new TOSalesInvoiceCollection(); TOSalesInvoiceRowCollection items = new TOSalesInvoiceRowCollection(); TOSalesInvoice salesinvoice = new TOSalesInvoice(); salesinvoice.CustomerID = "4444"; salesinvoice.Date = System.DateTime.Now.ToShortDateString(); salesinvoice.IsQuote = true; salesinvoice.ARAccount = "11010"; salesinvoice.NumberOfDistributions = 1; salesinvoice.Note = "Sales Quote created for Group: " + 1; salesinvoice.InternalNote = "NOTE YUCEL"; TOSalesInvoiceRow line = new TOSalesInvoiceRow(); line.GLAccount = "10090"; line.ItemID = "WLL"; line.Quantity = 1; decimal unitprice = 3433.20m; line.UnitPrice = unitprice; line.Amount = unitprice; line.JobID = "1"; line.Description = "Line ; AE01.22; Architectural and Engineering Drawing*"; line.OrderDistributionNumber = 1; items.Add(line); TOSalesInvoiceRow line2 = new TOSalesInvoiceRow(); line2.GLAccount = "10090"; line2.ItemID = "0002"; line2.Quantity = 1; decimal unitprice2 = 3433.20m; line2.UnitPrice = unitprice2; line2.Amount = unitprice2; line2.JobID = "1"; line2.Description = "1-A FAA & FCC Required Coordinates Form"; line2.OrderDistributionNumber =2; items.Add(line2); salesinvoice.RowCollection = items; salesinvoiceCollection.Add(salesinvoice); TOSalesInvoice.SaveAll(_boSalesInvoiceSettings, null, salesinvoiceCollection); 中有很多逻辑用于从命令行参数中找出用户意图。如果您需要编写Java代码,从main复制代码以完全按照您的要求进行操作可能是更好的选择。