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

fixed modeling problems with small models, fixed partial updating database

parent 575d15b3
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,14 @@ This application was created by Eike Cochu for his master's degree thesis in com ...@@ -13,6 +13,14 @@ This application was created by Eike Cochu for his master's degree thesis in com
## Installation ## Installation
1. If MongoDB or ElasticSearch run on different servers that the JavaEE application server, then the configuration files need to be changed. Change `config.properties` file
1. in `vipra.war`: Open `vipra.war` in an archive program, navigate to `/WEB-INF/classes` and edit `config.properties` file appropriately.
2. in `vipra-cmd.jar`: Open `vipra-cmd.jar` and edit `config.properties` file appropriately.
3. Test connection by running `./vipra -t`
2. Copy `vipra.war` to your JavaEE application server
## Development
### Requirements ### Requirements
Run dependencies Run dependencies
...@@ -29,7 +37,7 @@ Additional build dependencies ...@@ -29,7 +37,7 @@ Additional build dependencies
* [Gulp (3.9+)](http://gulpjs.com/) * [Gulp (3.9+)](http://gulpjs.com/)
* [Bower (1.7+](http://bower.io/) * [Bower (1.7+](http://bower.io/)
### Installation ### Build
1. Clone this repository to `./vipra` 1. Clone this repository to `./vipra`
2. Navigate to `./vipra` 2. Navigate to `./vipra`
......
db.host=localhost db.host=localhost
db.port=27017 db.port=27017
db.name=test db.name=test
\ No newline at end of file es.host=localhost
es.port=9300
tm.processor=corenlp
tm.analyzer=jgibb
tm.dtmpath=/home/eike/repos/master/dtm_release/dtm/main
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/vipra-cmd/src/main/java/de/vipra/cmd/Main.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</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="-e"/>
<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="-Dlog4j.configurationFile=log4j2dev.xml"/>
</launchConfiguration>
...@@ -107,21 +107,24 @@ public class JGibbAnalyzer extends Analyzer { ...@@ -107,21 +107,24 @@ public class JGibbAnalyzer extends Analyzer {
List<TopicFull> newTopics = new ArrayList<>(options.K); List<TopicFull> newTopics = new ArrayList<>(options.K);
Map<Integer, Topic> newTopicsMap = new HashMap<>(options.K); Map<Integer, Topic> newTopicsMap = new HashMap<>(options.K);
// for each topic TopicFull newTopic = null;
for (int topicNum = 0; topicNum < options.K; topicNum++) { List<TopicWord> topicWords = null;
TopicFull newTopic = new TopicFull(); int topicNum = 0;
List<TopicWord> topicWords = new ArrayList<>(options.twords);
// for each line
// for each word for (String line : lines) {
for (int wordNum = 0, lineNum = topicNum * options.K + 1; wordNum < options.twords; wordNum++, lineNum++) { if (!line.startsWith("\t")) {
String[] parts = lines.get(lineNum).trim().split("\\s+"); newTopic = new TopicFull();
TopicWord topicWord = new TopicWord(new Word(parts[0]), Double.parseDouble(parts[1])); topicWords = new ArrayList<>();
topicWords.add(topicWord); newTopic.setWords(topicWords);
newTopics.add(newTopic);
newTopicsMap.put(topicNum++, new Topic(newTopic.getId()));
continue;
} }
newTopic.setWords(topicWords); String[] parts = line.trim().split("\\s+");
newTopics.add(newTopic); TopicWord topicWord = new TopicWord(new Word(parts[0]), Double.parseDouble(parts[1]));
newTopicsMap.put(topicNum, new Topic(newTopic.getId())); topicWords.add(topicWord);
} }
dbTopics.drop(); dbTopics.drop();
......
db.host=localhost db.host=localhost
db.port=27017 db.port=27017
db.name=test db.name=test
es.host=localhost
es.port=9300
tm.processor=corenlp tm.processor=corenlp
tm.analyzer=jgibb tm.analyzer=jgibb
tm.dtmpath=/home/eike/repos/master/dtm_release/dtm/main tm.dtmpath=/home/eike/repos/master/dtm_release/dtm/main
\ No newline at end of file
...@@ -51,6 +51,18 @@ public class Config { ...@@ -51,6 +51,18 @@ public class Config {
@ConfigKey("db.name") @ConfigKey("db.name")
public String databaseName = Constants.DATABASE_NAME; public String databaseName = Constants.DATABASE_NAME;
/**
* ElasticSearch host
*/
@ConfigKey("es.host")
public String elasticsearchHost = Constants.ES_HOST;
/**
* ElasticSearch connection port
*/
@ConfigKey("es.port")
public int elasticsearchPort = Constants.ES_PORT;
/** /**
* The text processor to be used. To find a list of available values, * The text processor to be used. To find a list of available values,
* {@link de.vipra.util.Constants.Processor}. * {@link de.vipra.util.Constants.Processor}.
......
...@@ -23,8 +23,8 @@ public abstract class ESClient { ...@@ -23,8 +23,8 @@ public abstract class ESClient {
*/ */
public static TransportClient getClient(Config config) throws UnknownHostException { public static TransportClient getClient(Config config) throws UnknownHostException {
if (client == null) { if (client == null) {
client = TransportClient.builder().build().addTransportAddress( client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(
new InetSocketTransportAddress(InetAddress.getByName(Constants.ES_HOST), Constants.ES_PORT)); InetAddress.getByName(config.elasticsearchHost), config.elasticsearchPort));
} }
return client; return client;
} }
......
...@@ -41,7 +41,8 @@ public class MongoService<Type extends Model<IdType>, IdType> implements Service ...@@ -41,7 +41,8 @@ public class MongoService<Type extends Model<IdType>, IdType> implements Service
field.setAccessible(true); field.setAccessible(true);
UpdateIgnore ui = field.getDeclaredAnnotation(UpdateIgnore.class); UpdateIgnore ui = field.getDeclaredAnnotation(UpdateIgnore.class);
this.updateFields.put(field.getName(), ui == null ? null : field); if (ui == null)
this.updateFields.put(field.getName(), field);
QueryIgnore qi = field.getDeclaredAnnotation(QueryIgnore.class); QueryIgnore qi = field.getDeclaredAnnotation(QueryIgnore.class);
if (qi != null) { if (qi != null) {
...@@ -183,6 +184,7 @@ public class MongoService<Type extends Model<IdType>, IdType> implements Service ...@@ -183,6 +184,7 @@ public class MongoService<Type extends Model<IdType>, IdType> implements Service
} else { } else {
Query<Type> query = datastore.createQuery(clazz).field("_id").equal(t.getId()); Query<Type> query = datastore.createQuery(clazz).field("_id").equal(t.getId());
UpdateOperations<Type> ops = datastore.createUpdateOperations(clazz); UpdateOperations<Type> ops = datastore.createUpdateOperations(clazz);
boolean noChanges = true;
for (String fieldName : fields) { for (String fieldName : fields) {
if (!this.updateFields.containsKey(fieldName)) if (!this.updateFields.containsKey(fieldName))
throw new DatabaseException("field unknown: " + fieldName); throw new DatabaseException("field unknown: " + fieldName);
...@@ -195,11 +197,13 @@ public class MongoService<Type extends Model<IdType>, IdType> implements Service ...@@ -195,11 +197,13 @@ public class MongoService<Type extends Model<IdType>, IdType> implements Service
ops.unset(fieldName); ops.unset(fieldName);
else else
ops.set(fieldName, value); ops.set(fieldName, value);
noChanges = false;
} catch (IllegalArgumentException | IllegalAccessException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
throw new DatabaseException(e); throw new DatabaseException(e);
} }
} }
datastore.update(query, ops); if (!noChanges)
datastore.update(query, ops);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment