Pourquoi l'entrée de myCategorizer.categorize(); doit être une chaîne [] dans Apache opennlp 1.8 au lieu d'une chaîne comme dans la version 1.5 d'apache OpenNLP? parce que je veux vérifier les chaînes séparées au lieu d'un tableau.Catégoriseur de documents openNLP - catégoriser la méthode
public void trainModel()
{
InputStream dataIn = null;
try
{;
dataIn = new FileInputStream("D:/training.txt");
ObjectStream lineStream = new PlainTextByLineStream(dataIn, "UTF-8");
ObjectStream sampleStream = new DocumentSampleStream(lineStream);
// Specifies the minimum number of times a feature must be seen
int cutoff = 2;
int trainingIterations = 30;
model = DocumentCategorizerME.train("NL", sampleStream, cutoff,trainingIterations);
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (dataIn != null)
{
try
{
dataIn.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
public void classifyNewTweet(String tweet)
{
DocumentCategorizerME myCategorizer = new DocumentCategorizerME(model);
double[] outcomes = myCategorizer.categorize(tweet);
String category = myCategorizer.getBestCategory(outcomes);
if (category.equalsIgnoreCase("1"))
{
System.out.println("The tweet is positive :) ");
}
else
{
System.out.println("The tweet is negative :(");
}
}