From 13148ea6b9299762fde8841bf41c61319f572ad1 Mon Sep 17 00:00:00 2001 From: Philip Leifeld Date: Wed, 11 Sep 2019 23:04:46 +0100 Subject: [PATCH] Final changes before release beta 25 --- DNA/src/dna/export/ExporterR.java | 113 +++++++++++++++++++++++++++++- rDNA/DESCRIPTION | 2 +- 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/DNA/src/dna/export/ExporterR.java b/DNA/src/dna/export/ExporterR.java index ae16239d..58fe032d 100644 --- a/DNA/src/dna/export/ExporterR.java +++ b/DNA/src/dna/export/ExporterR.java @@ -6,7 +6,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.Date; @@ -14,7 +13,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.Random; import org.rosuda.JRI.RConsoleOutputStream; import org.rosuda.JRI.Rengine; @@ -199,6 +197,117 @@ public String rShow() { * ================================================================================================================= */ + /* + public void filterStatements( + String statementType, + String duplicates, + String startDate, + String stopDate, + String startTime, + String stopTime, + String[] excludeVariables, + String[] excludeValues, + String[] excludeAuthors, + String[] excludeSources, + String[] excludeSections, + String[] excludeTypes, + boolean invertValues, + boolean invertAuthors, + boolean invertSources, + boolean invertSections, + boolean invertTypes) throws Exception { + + // format duplicates argument + // valid R input: 'include', 'document', 'week', 'month', 'year', or 'acrossrange' + // valid Java output: 'include all duplicates', 'ignore per document', 'ignore per calendar week', 'ignore per calendar month', 'ignore per calendar year', or 'ignore across date range' + if (!duplicates.equals("include") && !duplicates.equals("document") && !duplicates.equals("week") && !duplicates.equals("month") + && !duplicates.equals("year") && !duplicates.equals("acrossrange")) { + throw new Exception("'duplicates' must be 'include', 'document', 'week', 'month', 'year', or 'acrossrange'."); + } + if (duplicates.equals("include")) { + duplicates = "include all duplicates"; + } else if (duplicates.equals("document")) { + duplicates = "ignore per document"; + } else if (duplicates.equals("week")) { + duplicates = "ignore per calendar week"; + } else if (duplicates.equals("month")) { + duplicates = "ignore per calendar month"; + } else if (duplicates.equals("year")) { + duplicates = "ignore per calendar year"; + } else if (duplicates.equals("acrossrange")) { + duplicates = "ignore across date range"; + } + + // format dates and times with input formats "dd.MM.yyyy" and "HH:mm:ss" + DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + String startString = startDate + " " + startTime; + Date start = null; + try { + start = df.parse(startString); + } catch (ParseException e) { + System.err.println("\nStart date or time is invalid!"); + } + if (!startString.equals(df.format(start))) { + startDate = null; + System.err.println("\nStart date or time is invalid!"); + } + String stopString = stopDate + " " + stopTime; + Date stop = null; + try { + stop = df.parse(stopString); + } catch (ParseException e) { + System.err.println("\nStop date or time is invalid!"); + } + if (!stopString.equals(df.format(stop))) { + stopDate = null; + System.err.println("\nStop date or time is invalid!"); + } + + // process exclude variables: create HashMap with variable:value pairs + HashMap> map = new HashMap>(); + if (excludeVariables.length > 0) { + for (int i = 0; i < excludeVariables.length; i++) { + ArrayList values = map.get(excludeVariables[i]); + if (values == null) { + values = new ArrayList(); + } + if (!values.contains(excludeValues[i])) { + values.add(excludeValues[i]); + } + Collections.sort(values); + map.put(excludeVariables[i], values); + } + } + if (invertValues == true) { + Iterator mapIterator = map.keySet().iterator(); + while (mapIterator.hasNext()) { + String key = mapIterator.next(); + ArrayList values = map.get(key); + String[] labels = this.exportHelper.extractLabels(data.getStatements(), data.getStatements(), data.getDocuments(), key, false, statementTypeId, includeIsolates); + ArrayList newValues = new ArrayList(); + for (int i = 0; i < labels.length; i++) { + if (!values.contains(labels[i])) { + newValues.add(labels[i]); + } + } + map.put(key, newValues); + } + } + + // process document-level exclude variables using repeated calls of private function 'processExcludeDocument' + ArrayList authorExclude = processExcludeDocument("author", excludeAuthors, invertAuthors, data.getStatements(), data.getStatements(), + data.getDocuments(), statementTypeId, includeIsolates); + ArrayList sourceExclude = processExcludeDocument("source", excludeSources, invertSources, data.getStatements(), data.getStatements(), + data.getDocuments(), statementTypeId, includeIsolates); + ArrayList sectionExclude = processExcludeDocument("section", excludeSections, invertSections, data.getStatements(), data.getStatements(), + data.getDocuments(), statementTypeId, includeIsolates); + ArrayList typeExclude = processExcludeDocument("type", excludeTypes, invertTypes, data.getStatements(), data.getStatements(), + data.getDocuments(), statementTypeId, includeIsolates); + + + } + */ + /** * Compute one-mode or two-mode network matrix based on R arguments. * diff --git a/rDNA/DESCRIPTION b/rDNA/DESCRIPTION index daa09e24..d883d599 100755 --- a/rDNA/DESCRIPTION +++ b/rDNA/DESCRIPTION @@ -21,7 +21,7 @@ Imports: dplyr (>= 0.7.0), ggforce (>= 0.1.3), ggplot2 (>= 2.2.1), - ggraph (>= 1.0.0), + ggraph (>= 2.0.0), ggrepel (>= 0.7.0), grDevices (>= 3.0.0), MASS (>= 7.3.0),