Инструменты моделирования тем в Стэнфорде: исключение

1

Я пытаюсь работать со Стэнфордской моделью моделирования тем. Я загрузил "tmt-0.4.0.jar" -File отсюда: http://nlp.stanford.edu/software/tmt/tmt-0.4/, и я попытался привести примеры. Пример 0 и 1 работал нормально, но пример 2 (без изменений кода), я получаю следующее исключение:

[cell] loading pubmed-oa-subset.csv.term-counts.cache.70108071.gz [Concurrent] 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) at scala.collection.Iterator $$ anon $ 22.hasNext(Iterator.scala: 390) в scala.collection.Iterator $$ anon $ 22.hasNext(Iterator.scala: 388) в scala.collection.Iterator $ class. foreach (Iterator.scala: 660) в scala.collection.Iterator $$ anon $ 22.foreach(Iterator.scala: 382) в scala.collection.IterableViewLike $ Преобразован $ class.foreach(IterableViewLike.scala: 41) в scala.collection.IterableViewLike $$ Анон $ 5.foreach(IterableViewLike.sca la: 82) at 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 $ применяет $ 1.apply(Filter.scala: 38) в scalanlp. stage.generic.Filter $$ anonfun $ применить $ 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) at edu.stanford.nlp.tmt.data.concurrent.Concurrent $$ anonfun $ map $ 2.apply(Concurrent.scala: 88) в edu. stanford.nlp.tmt.data.concurrent.Concurrent $$ Анон $ 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);
  • 0
    Без кода, с которым его можно сравнить, мы не знаем, как его раскосить.
  • 0
    Я добавил код :) Спасибо за любую помощь :)
Теги:
stanford-nlp

1 ответ

1

Ответ был опубликован автором инструмента. Пожалуйста, смотрите здесь.

Обычно это происходит, когда у вас есть устаревший файл.cache - к сожалению, сообщение об ошибке не особенно полезно. Попробуйте удалить кеш в папке запуска и снова запустите.

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

Ещё вопросы

Сообщество Overcoder
Наверх
Меню