本文整理汇总了Java中cc.mallet.util.CommandOption.setSummary方法的典型用法代码示例。如果您正苦于以下问题:Java CommandOption.setSummary方法的具体用法?Java CommandOption.setSummary怎么用?Java CommandOption.setSummary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.util.CommandOption
的用法示例。
在下文中一共展示了CommandOption.setSummary方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws Exception {
// Process the command-line options
CommandOption.setSummary (WordEmbeddings.class,
"Train continuous word embeddings using the skip-gram method with negative sampling.");
CommandOption.process (WordEmbeddings.class, args);
InstanceList instances = InstanceList.load(new File(inputFile.value));
WordEmbeddings matrix = new WordEmbeddings(instances.getDataAlphabet(), numDimensions.value, windowSizeOption.value);
matrix.queryWord = exampleWord.value;
matrix.countWords(instances);
matrix.train(instances, numThreads.value, numSamples.value);
PrintWriter out = new PrintWriter(outputFile.value);
matrix.write(out);
out.close();
}
示例2: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// Process the command-line options
CommandOption.setSummary(WordTopicEmbeddings.class,
"Train continuous word embeddings using the skip-gram method with negative sampling.");
CommandOption.process(WordTopicEmbeddings.class, args);
InstanceList instances = InstanceList.load(new File(inputFile.value));
WordTopicEmbeddings matrix = new WordTopicEmbeddings(instances.getDataAlphabet(), numDimensions.value, windowSizeOption.value, 0);
matrix.queryWord = exampleWord.value;
matrix.countWords(instances);
matrix.train(instances, numThreads.value, numSamples.value);
PrintWriter out = new PrintWriter(outputFile.value);
matrix.write(out);
out.close();
}
示例3: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// Process the command-line options
CommandOption.setSummary(WordEmbeddings.class,
"Train continuous word embeddings using the skip-gram method with negative sampling.");
CommandOption.process(WordEmbeddings.class, args);
InstanceList instances = InstanceList.load(new File(inputFile.value));
WordEmbeddings matrix = new WordEmbeddings(instances.getDataAlphabet(), numDimensions.value, windowSizeOption.value);
matrix.queryWord = exampleWord.value;
matrix.countWords(instances);
matrix.train(instances, numThreads.value, numSamples.value);
PrintWriter out = new PrintWriter(outputFile.value);
matrix.write(out);
out.close();
}
示例4: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws Exception {
// Process the command-line options
CommandOption.setSummary (WordEmbeddings.class,
"Train continuous word embeddings using the skip-gram method with negative sampling.");
CommandOption.process (WordEmbeddings.class, args);
InstanceList instances = InstanceList.load(new File(inputFile.value));
WordEmbeddings matrix = new WordEmbeddings(instances.getDataAlphabet(), numDimensions.value, windowSizeOption.value);
matrix.queryWord = exampleWord.value;
matrix.setNumIterations(numIterationsOption.value);
matrix.countWords(instances, samplingFactorOption.value);
if (orderingOption.value != null) {
if (orderingOption.value.startsWith("s")) { matrix.orderingStrategy = SHUFFLED_ORDERING; }
else if (orderingOption.value.startsWith("l")) { matrix.orderingStrategy = LINEAR_ORDERING; }
else if (orderingOption.value.startsWith("r")) { matrix.orderingStrategy = RANDOM_ORDERING; }
else {
System.err.println("Unrecognized ordering: " + orderingOption.value + ", using linear.");
}
}
matrix.train(instances, numThreads.value, numSamples.value);
PrintWriter out = new PrintWriter(outputFile.value);
matrix.write(out);
out.close();
if (outputContextFile.value != null) {
out = new PrintWriter(outputContextFile.value);
matrix.writeContext(out);
out.close();
}
}
示例5: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws IOException {
CommandOption
.setSummary(Text2Clusterings.class,
"A tool to convert a list of text files to a Clusterings.");
CommandOption.process(Text2Clusterings.class, args);
if (classDirs.value.length == 0) {
logger
.warning("You must include --input DIR1 DIR2 ...' in order to specify a"
+ "list of directories containing the documents for each class.");
System.exit(-1);
}
Clustering[] clusterings = new Clustering[classDirs.value.length];
int fi = 0;
for (int i = 0; i < classDirs.value.length; i++) {
Alphabet fieldAlph = new Alphabet();
Alphabet valueAlph = new Alphabet();
File directory = new File(classDirs.value[i]);
File[] subdirs = getSubDirs(directory);
Alphabet clusterAlph = new Alphabet();
InstanceList instances = new InstanceList(new Noop());
TIntArrayList labels = new TIntArrayList();
for (int j = 0; j < subdirs.length; j++) {
ArrayList<File> records = new FileIterator(subdirs[j]).getFileArray();
int label = clusterAlph.lookupIndex(subdirs[j].toString());
for (int k = 0; k < records.size(); k++) {
if (fi % 100 == 0) System.out.print(fi);
else if (fi % 10 == 0) System.out.print(".");
if (fi % 1000 == 0 && fi > 0) System.out.println();
System.out.flush();
fi++;
File record = records.get(k);
labels.add(label);
instances.add(new Instance(new Record(fieldAlph, valueAlph, parseFile(record)),
new Integer(label), record.toString(),
record.toString()));
}
}
clusterings[i] =
new Clustering(instances, subdirs.length, labels.toNativeArray());
}
logger.info("\nread " + fi + " objects in " + clusterings.length + " clusterings.");
try {
ObjectOutputStream oos =
new ObjectOutputStream(new FileOutputStream(outputFile.value));
oos.writeObject(new Clusterings(clusterings));
oos.close();
} catch (Exception e) {
logger.warning("Exception writing clustering to file " + outputFile.value
+ " " + e);
e.printStackTrace();
}
}
示例6: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws java.io.IOException {
// Process the command-line options
CommandOption.setSummary (HierarchicalLDATUI.class,
"Hierarchical LDA with a fixed tree depth.");
CommandOption.process (HierarchicalLDATUI.class, args);
// Load instance lists
if (inputFile.value() == null) {
System.err.println("Input instance list is required, use --input option");
System.exit(1);
}
InstanceList instances = InstanceList.load(new File(inputFile.value()));
InstanceList testing = null;
if (testingFile.value() != null) {
testing = InstanceList.load(new File(testingFile.value()));
}
HierarchicalLDA hlda = new HierarchicalLDA();
// Set hyperparameters
hlda.setAlpha(alpha.value());
hlda.setGamma(gamma.value());
hlda.setEta(eta.value());
// Display preferences
hlda.setTopicDisplay(showTopicsInterval.value(), topWords.value());
hlda.setProgressDisplay(showProgress.value());
// Initialize random number generator
Randoms random = null;
if (randomSeed.value() == 0) {
random = new Randoms();
}
else {
random = new Randoms(randomSeed.value());
}
// Initialize and start the sampler
hlda.initialize(instances, testing, numLevels.value(), random);
hlda.estimate(numIterations.value());
// Output results
if (stateFile.value() != null) {
hlda.printState(new PrintWriter(stateFile.value()));
}
if (testing != null) {
double empiricalLikelihood = hlda.empiricalLikelihood(1000, testing);
System.out.println("Empirical likelihood: " + empiricalLikelihood);
}
}
示例7: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws IOException {
CommandOption
.setSummary(Text2Clusterings.class,
"A tool to convert a list of text files to a Clusterings.");
CommandOption.process(Text2Clusterings.class, args);
if (classDirs.value.length == 0) {
logger
.warning("You must include --input DIR1 DIR2 ...' in order to specify a"
+ "list of directories containing the documents for each class.");
System.exit(-1);
}
Clustering[] clusterings = new Clustering[classDirs.value.length];
int fi = 0;
for (int i = 0; i < classDirs.value.length; i++) {
Alphabet fieldAlph = new Alphabet();
Alphabet valueAlph = new Alphabet();
File directory = new File(classDirs.value[i]);
File[] subdirs = getSubDirs(directory);
Alphabet clusterAlph = new Alphabet();
InstanceList instances = new InstanceList(new Noop());
TIntArrayList labels = new TIntArrayList();
for (int j = 0; j < subdirs.length; j++) {
ArrayList<File> records = new FileIterator(subdirs[j]).getFileArray();
int label = clusterAlph.lookupIndex(subdirs[j].toString());
for (int k = 0; k < records.size(); k++) {
if (fi % 100 == 0) System.out.print(fi);
else if (fi % 10 == 0) System.out.print(".");
if (fi % 1000 == 0 && fi > 0) System.out.println();
System.out.flush();
fi++;
File record = records.get(k);
labels.add(label);
instances.add(new Instance(new Record(fieldAlph, valueAlph, parseFile(record)),
new Integer(label), record.toString(),
record.toString()));
}
}
clusterings[i] =
new Clustering(instances, subdirs.length, labels.toArray());
}
logger.info("\nread " + fi + " objects in " + clusterings.length + " clusterings.");
try {
ObjectOutputStream oos =
new ObjectOutputStream(new FileOutputStream(outputFile.value));
oos.writeObject(new Clusterings(clusterings));
oos.close();
} catch (Exception e) {
logger.warning("Exception writing clustering to file " + outputFile.value
+ " " + e);
e.printStackTrace();
}
}
示例8: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws IOException {
// Process the command-line options
CommandOption.setSummary (HierarchicalLDATUI.class,
"Hierarchical LDA with a fixed tree depth.");
CommandOption.process (HierarchicalLDATUI.class, args);
// Load instance lists
if (inputFile.value() == null) {
System.err.println("Input instance list is required, use --input option");
System.exit(1);
}
InstanceList instances = InstanceList.load(new File(inputFile.value()));
InstanceList testing = null;
if (testingFile.value() != null) {
testing = InstanceList.load(new File(testingFile.value()));
}
HierarchicalLDA hlda = new HierarchicalLDA();
// Set hyperparameters
hlda.setAlpha(alpha.value());
hlda.setGamma(gamma.value());
hlda.setEta(eta.value());
// Display preferences
hlda.setTopicDisplay(showTopicsInterval.value(), topWords.value());
hlda.setProgressDisplay(showProgress.value());
// Initialize random number generator
Randoms random = null;
if (randomSeed.value() == 0) {
random = new Randoms();
}
else {
random = new Randoms(randomSeed.value());
}
// Initialize and start the sampler
hlda.initialize(instances, testing, numLevels.value(), random);
hlda.estimate(numIterations.value());
// Output results
if (stateFile.value() != null) {
hlda.printState(new PrintWriter(stateFile.value()));
}
if (testing != null) {
double empiricalLikelihood = hlda.empiricalLikelihood(1000, testing);
System.out.println("Empirical likelihood: " + empiricalLikelihood);
}
}
示例9: main
import cc.mallet.util.CommandOption; //导入方法依赖的package包/类
public static void main (String[] args) throws IOException {
CommandOption
.setSummary(Text2Clusterings.class,
"A tool to convert a list of text files to a Clusterings.");
CommandOption.process(Text2Clusterings.class, args);
if (classDirs.value.length == 0) {
logger
.warning("You must include --input DIR1 DIR2 ...' in order to specify a"
+ "list of directories containing the documents for each class.");
System.exit(-1);
}
Clustering[] clusterings = new Clustering[classDirs.value.length];
int fi = 0;
for (int i = 0; i < classDirs.value.length; i++) {
Alphabet fieldAlph = new Alphabet();
Alphabet valueAlph = new Alphabet();
File directory = new File(classDirs.value[i]);
File[] subdirs = getSubDirs(directory);
Alphabet clusterAlph = new Alphabet();
InstanceList instances = new InstanceList(new Noop());
IntArrayList labels = new IntArrayList();
for (int j = 0; j < subdirs.length; j++) {
ArrayList<File> records = new FileIterator(subdirs[j]).getFileArray();
int label = clusterAlph.lookupIndex(subdirs[j].toString());
for (int k = 0; k < records.size(); k++) {
if (fi % 100 == 0) System.out.print(fi);
else if (fi % 10 == 0) System.out.print(".");
if (fi % 1000 == 0 && fi > 0) System.out.println();
System.out.flush();
fi++;
File record = records.get(k);
labels.add(label);
instances.add(new Instance(new Record(fieldAlph, valueAlph, parseFile(record)),
new Integer(label), record.toString(),
record.toString()));
}
}
clusterings[i] =
new Clustering(instances, subdirs.length, labels.toArray());
}
logger.info("\nread " + fi + " objects in " + clusterings.length + " clusterings.");
try {
ObjectOutputStream oos =
new ObjectOutputStream(new FileOutputStream(outputFile.value));
oos.writeObject(new Clusterings(clusterings));
oos.close();
} catch (Exception e) {
logger.warning("Exception writing clustering to file " + outputFile.value
+ " " + e);
e.printStackTrace();
}
}