私はJavaが初めてです。私はテキストのアスペクト・センチメント分析を実装するコードを使って作業しています。私はコードが動作するはずですが、どういうわけか私は次のエラーが発生し続けることを知っています。ここでJavaがForステートメントをスキップするのはなぜですか?
----jGRASP exec: java -Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,suspend=y,server=y sto2.STO2Core
----jGRASP: connected to debugger.
Exception in thread "main" java.lang.Exception: Alpha should be specified as a positive real number.
----jGRASP debugger: run in canvas ended
at sto2.STO2Core.main(STO2Core.java:114)
はラインを実行するように見える場合、私は場合や、他のプログラムのどれを実行しない場合、私はエラーに
public static void main(String [] args) throws Exception {
int numTopics = 10;
int numIterations = 100;
int numSenti = 2;
int numThreads = 1;
String inputDir = null;
String outputDir = null;
String dicDir = null;
double alpha = -1;
double [] betas = null;
double [] gammas = null;
String [] betasStr = null;
String [] gammasStr = null;
boolean randomInit = false;
String sentiFilePrefix = "SentiWords-";
String wordListFileName = "WordList.txt";
String docListFileName = "DocumentList.txt";
String wordDocFileName = "BagOfSentences.txt";
for (int i = 0; i < args.length/2; i++) {
String option = args[2*i];
String value = args[2*i+1];
if (option.equals("-t")) numTopics = Integer.valueOf(30);
else if (option.equals("-s")) numSenti = Integer.valueOf(2);
else if (option.equals("-i")) numIterations = Integer.valueOf(1000);
else if (option.equals("-th")) numThreads = Integer.valueOf(3);
else if (option.equals("-d")) inputDir = value.replaceAll("T:/Summer 2017/ASUM/ASUM/Test data", "/").replaceAll("/$", "");
else if (option.equals("-o")) outputDir = value.replaceAll("T:/Summer 2017/ASUM/ASUM/Output", "/").replaceAll("/$", "");
else if (option.equals("-dic")) dicDir = value.replaceAll("T:/Summer 2017/ASUM/ASUM/Test data", "/").replaceAll("/$", "");
else if (option.equals("-a")) alpha = Double.valueOf(0.1);
else if (option.equals("-b")) betasStr = value.split("0.001/0.1/0");
else if (option.equals("-g")) gammasStr = value.split("1/1");
else if (option.equals("-r")) randomInit = value.toLowerCase().equals("true")?true:false;
}
if (inputDir == null) inputDir = ".";
if (outputDir == null) outputDir = new String(inputDir);
if (dicDir == null) dicDir = new String(inputDir);
// Exceptions
if (!new File(inputDir).exists()) throw new Exception("There's no such an input directory as " + inputDir);
if (!new File(outputDir).exists()) throw new Exception("There's no such an output directory as " + outputDir);
if (!new File(dicDir).exists()) throw new Exception("Tehre's no such a dictionary directory as " + dicDir);
if (alpha <= 0) throw new Exception("Alpha should be specified as a positive real number.");
を得るラインゴマアップ私の主な機能のコードです。問題の原因は何か? ありがとうございました!
プログラムにコマンドライン引数を渡していますか? – Eran
はい、opは次のようなことをしています:*** args [2 * i]; *** argsが与えられていないとクラッシュします –
@ΦXocę笑Пepeúpaツいいえ、argsが与えられていなければループは入力されません。 – Eran