【问题标题】:Stanford Topic Modeling Toolbox: Exception斯坦福主题建模工具箱:例外
【发布时间】:2014-05-10 20:06:48
【问题描述】:

我正在尝试使用斯坦福主题建模工具箱。我从这里下载了“tmt-0.4.0.jar”文件:http://nlp.stanford.edu/software/tmt/tmt-0.4/ 并尝试了示例。 示例 0 和 1 运行良好,但尝试示例 2(无代码更改),我收到以下异常:

[cell] 加载 pubmed-oa-subset.csv.term-counts.cache.70108071.gz [并发] 32 允许线程“Thread-3”中的异常 java.lang.ArrayIndexOutOfBoundsException:-1 在 scalanlp.stage.text.TermCounts$class.getDF(TermFilters.scala:64) 在 scalanlp.stage.text.TermCounts$$anon$2.getDF(TermFilters.scala:84) 在 scalanlp.stage.text.TermMinimumDocumentCountFilter$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(TermFilters.scala:172) 在 scalanlp.stage.text.TermMinimumDocumentCountFilter$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(TermFilters.scala:172) 在 scala.collection.Iterator$$anon$22.hasNext(Iterator.scala:390) 在 scala.collection.Iterator$$anon$22.hasNext(Iterator.scala:388) 在 scala.collection.Iterator$class.foreach(Ite​​rator.scala:660) 在 scala.collection.Iterator$$anon$22.foreach(Ite​​rator.scala:382) 在 scala.collection.IterableViewLike$Transformed$class.foreach(Ite​​rableViewLike.scala:41) 在 scala.collection.IterableViewLike$$anon$5.foreach(Ite​​rableViewLike.scala:82) 在 scala.collection.TraversableOnce$class.size(TraversableOnce.scala:104) 在 scala.collection.IterableViewLike$$anon$5.size(IterableViewLike.scala:82) 在 scalanlp.stage.text.DocumentMinimumLengthFilter.filter(DocumentFilters.scala:31) 在 scalanlp.stage.text.DocumentMinimumLengthFilter.filter(DocumentFilters.scala:28) 在 scalanlp.stage.generic.Filter$$anonfun$apply$1.apply(Filter.scala:38) 在 scalanlp.stage.generic.Filter$$anonfun$apply$1.apply(Filter.scala:38) 在 scala.collection.Iterator$$anon$22.hasNext(Iterator.scala:390) 在 edu.stanford.nlp.tmt.data.concurrent.Concurrent$$anonfun$map$2.apply(Concurrent.scala:100) 在 edu.stanford.nlp.tmt.data.concurrent.Concurrent$$anonfun$map$2.apply(Concurrent.scala:88) 在 edu.stanford.nlp.tmt.data.concurrent.Concurrent$$anon$4.run(Concurrent.scala:45)

为什么我会收到此异常,如何解决? 非常感谢你的帮助!

PS:代码与网站示例2相同:

// Stanford TMT Example 2 - Learning an LDA model
// http://nlp.stanford.edu/software/tmt/0.4/

// tells Scala where to find the TMT classes
import scalanlp.io._;
import scalanlp.stage._;
import scalanlp.stage.text._;
import scalanlp.text.tokenize._;
import scalanlp.pipes.Pipes.global._;

import edu.stanford.nlp.tmt.stage._;
import edu.stanford.nlp.tmt.model.lda._;
import edu.stanford.nlp.tmt.model.llda._;

val source = CSVFile("pubmed-oa-subset.csv") ~> IDColumn(1);

val tokenizer = {
  SimpleEnglishTokenizer() ~>            // tokenize on space and punctuation
  CaseFolder() ~>                        // lowercase everything
  WordsAndNumbersOnlyFilter() ~>         // ignore non-words and non-numbers
  MinimumLengthFilter(3)                 // take terms with >=3 characters
}

val text = {
  source ~>                              // read from the source file
  Column(4) ~>                           // select column containing text
  TokenizeWith(tokenizer) ~>             // tokenize with tokenizer above
  TermCounter() ~>                       // collect counts (needed below)
  TermMinimumDocumentCountFilter(4) ~>   // filter terms in <4 docs
  TermDynamicStopListFilter(30) ~>       // filter out 30 most common terms
  DocumentMinimumLengthFilter(5)         // take only docs with >=5 terms
}

// turn the text into a dataset ready to be used with LDA
val dataset = LDADataset(text);

// define the model parameters
val params = LDAModelParams(numTopics = 30, dataset = dataset,
  topicSmoothing = 0.01, termSmoothing = 0.01);

// Name of the output model folder to generate
val modelPath = file("lda-"+dataset.signature+"-"+params.signature);

// Trains the model: the model (and intermediate models) are written to the
// output folder.  If a partially trained model with the same dataset and
// parameters exists in that folder, training will be resumed.
TrainCVB0LDA(params, dataset, output=modelPath, maxIterations=1000);

// To use the Gibbs sampler for inference, instead use
// TrainGibbsLDA(params, dataset, output=modelPath, maxIterations=1500);

【问题讨论】:

  • 没有代码来比较它,我们不知道如何诊断它。
  • 我添加了代码 :) 感谢您的帮助 :)

标签: java scala stanford-nlp


【解决方案1】:

答案已由该工具的作者发布。请看这里。

这通常发生在您有一个陈旧的 .cache 文件时 - 不幸的是 错误消息不是特别有用。尝试在运行中删除 cache 文件夹并再次运行。

https://lists.cs.princeton.edu/pipermail/topic-models/2012-July/001979.html

【讨论】:

    猜你喜欢
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 2012-04-30
    • 2012-12-07
    • 1970-01-01
    • 2012-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多