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

removed articles from topic show

parent dbc61a66
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.vipra.cmd.ex.AnalyzerException;
import de.vipra.cmd.file.DTMVocabulary;
import de.vipra.util.Config;
import de.vipra.util.Constants;
import de.vipra.util.ConvertStream;
......@@ -108,13 +109,23 @@ public class DTMAnalyzer extends Analyzer {
@Override
public ConvertStream<TopicFull> getTopicDefinitions() throws AnalyzerException {
// TODO Auto-generated method stub
DTMVocabulary vocab;
try {
vocab = new DTMVocabulary(modelDir, false);
} catch (IOException e) {
throw new AnalyzerException(e);
}
return null;
}
@Override
public ConvertStream<List<TopicRef>> getTopics() throws AnalyzerException {
// TODO Auto-generated method stub
DTMVocabulary vocab;
try {
vocab = new DTMVocabulary(modelDir, false);
} catch (IOException e) {
throw new AnalyzerException(e);
}
return null;
}
......
......@@ -98,10 +98,14 @@ public class JGibbAnalyzer extends Analyzer {
}
// get all lines that follow until the next topic is
// discovered (line does not start with a tab)
// discovered (line does not start with a tab). Cut off
// after k words are gathered.
String nextLine;
int words = 0;
while ((nextLine = nextLine()) != null) {
if (nextLine.startsWith("\t")) {
if (words > Constants.K_TOPIC_WORDS)
continue;
String[] parts = nextLine.trim().split("\\s+");
try {
Word word = wordMap.get(parts[0]);
......@@ -109,6 +113,7 @@ public class JGibbAnalyzer extends Analyzer {
Constants.LIKELINESS_PRECISION);
TopicWord topicWord = new TopicWord(word, likeliness);
topicWords.add(topicWord);
words++;
} catch (NumberFormatException e) {
log.error("could not parse number in line: " + nextLine);
} catch (ArrayIndexOutOfBoundsException e) {
......
......@@ -2,6 +2,6 @@ db.host=localhost
db.port=27017
db.name=test
tm.processor=corenlp
tm.analyzer=dtm
tm.analyzer=jgibb
tm.saveallwords=false
tm.dtmpath=/home/eike/Downloads/dtm_release/dtm/main
\ No newline at end of file
......@@ -32,6 +32,7 @@ import de.vipra.util.StringUtils;
import de.vipra.util.ex.ConfigException;
import de.vipra.util.ex.DatabaseException;
import de.vipra.util.model.ArticleFull;
import de.vipra.util.model.Topic;
import de.vipra.util.model.TopicFull;
import de.vipra.util.service.MongoService;
import de.vipra.util.service.Service.QueryBuilder;
......@@ -109,9 +110,6 @@ public class TopicResource {
}
if (topic != null) {
List<ArticleFull> articles = dbArticles.getMultiple(QueryBuilder.builder().criteria("topics.topic", topic));
topic.setArticles(articles);
return res.ok(topic);
} else {
res.addError(new APIError(Response.Status.NOT_FOUND, "Resource not found",
......@@ -120,6 +118,24 @@ public class TopicResource {
}
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("{id}/articles")
public Response getArticles(@PathParam("id") String id, @QueryParam("fields") String fields) {
Wrapper<List<ArticleFull>> res = new Wrapper<>();
try {
Topic topic = new Topic(MongoUtils.objectId(id));
List<ArticleFull> articles = dbArticles.getMultiple(
QueryBuilder.builder().criteria("topics.topic", topic).fields(true, StringUtils.getFields(fields)));
return res.ok(articles);
} catch (Exception e) {
e.printStackTrace();
res.addError(new APIError(Response.Status.BAD_REQUEST, "Error", e.getMessage()));
return res.badRequest();
}
}
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
......
......@@ -27,14 +27,6 @@
</tbody>
</table>
<h3>Articles <hide-link target="#articles"/></h3>
<ul class="dashed">
<li ng-repeat="article in ::topic.articles">
<article-link article="article"/>
</li>
</ul>
<h3>Words <hide-link target="#words"/></h3>
<table class="table table-bordered table-condensed" id="words">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment