Skip to content
Snippets Groups Projects
Commit 68ba42d7 authored by Eike Cochu's avatar Eike Cochu
Browse files

added topic model groups

parent 3d67b6e2
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="de.vipra.cmd.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-S test -I /home/eike/repos/master/ma-impl/docker/data/test-1.json"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-eC bbc:test"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="vipra-cmd"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
......
......@@ -27,14 +27,16 @@ public class CreateModelCommand implements Command {
this.names = names;
}
private void createModel(final String name, final TopicModelConfig modelConfig, final File modelDir)
private TopicModelFull createModel(final String name, final TopicModelConfig modelConfig, final File modelDir)
throws JsonGenerationException, JsonMappingException, IOException, DatabaseException {
modelConfig.setName(name);
modelConfig.saveToFile(modelDir);
final TopicModelFull topicModel = new TopicModelFull(name, modelConfig);
topicModel.setColorSeed(random.nextLong());
modelConfig.setName(topicModel.getName());
modelConfig.setGroup(topicModel.getGroup());
modelConfig.saveToFile(modelDir);
dbTopicModels.createSingle(topicModel);
config.getTopicModelConfigs().put(name, modelConfig);
config.getTopicModelConfigs().put(topicModel.getName(), modelConfig);
return topicModel;
}
@Override
......@@ -64,8 +66,9 @@ public class CreateModelCommand implements Command {
if (!modelDir.mkdirs())
throw new Exception("could not create model directory: " + modelDir.getAbsolutePath());
createModel(name, modelConfig, modelDir);
ConsoleUtils.info("model created: " + name);
final TopicModelFull topicModel = createModel(name, modelConfig, modelDir);
ConsoleUtils
.info("model created: " + topicModel.getName() + (topicModel.getGroup() == null ? "" : " in group: " + topicModel.getGroup()));
}
}
......
......@@ -33,11 +33,10 @@ public class ProcessedText {
for (final String word : words)
wordCounts.count(word);
final List<ArticleWord> articleWords = new ArrayList<>(wordCounts.size());
articleWords = new ArrayList<>(wordCounts.size());
for (final Entry<String, Integer> entry : wordCounts.entrySet())
articleWords.add(new ArticleWord(entry.getKey(), entry.getValue()));
this.articleWords = articleWords;
Collections.sort(this.articleWords, Comparator.reverseOrder());
Collections.sort(articleWords, Comparator.reverseOrder());
}
public String[] getWords() {
......
......@@ -25,6 +25,7 @@ public class TopicModelConfig implements Serializable {
public static final String FILE_NAME = "config.json";
private String name;
private String group;
private String description;
private int kTopics = Constants.K_TOPICS;
private int kTopWords = Constants.K_TOP_WORDS;
......@@ -86,6 +87,14 @@ public class TopicModelConfig implements Serializable {
this.name = name;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public String getDescription() {
return description;
}
......
......@@ -25,6 +25,8 @@ public class TopicModelFull implements Model<ObjectId>, Comparable<TopicModelFul
private String name;
private String group;
private Long topicCount;
private Long articleCount;
......@@ -62,7 +64,7 @@ public class TopicModelFull implements Model<ObjectId>, Comparable<TopicModelFul
}
public TopicModelFull(final String name, final TopicModelConfig modelConfig) {
this.name = name;
setName(name);
this.modelConfig = modelConfig;
}
......@@ -81,7 +83,20 @@ public class TopicModelFull implements Model<ObjectId>, Comparable<TopicModelFul
}
public void setName(final String name) {
this.name = name;
if (name != null && name.contains(":")) {
final String[] parts = name.split(":");
this.group = parts[0];
this.name = parts[1];
} else
this.name = name;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public Long getTopicCount() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment