@Test public void testGetYearAndAssociation() throws Exception { assertEquals(Arrays.asList(new YearAndValue[] { new YearAndValue(1910, 0.4f), new YearAndValue(1920, 0.5f), new YearAndValue(1930, 0.2f), new YearAndValue(1940, 0.1f) }), db.getYearAndAssociation(CORPUS, DatabaseService.SIMILARITY_TABLE, "bar", "foo")); assertEquals( Arrays.asList(new YearAndValue[] { new YearAndValue(1910, 23f), new YearAndValue(1930, 29f) }), db.getYearAndAssociation(CORPUS, DatabaseService.PPMI_TABLE, "foo", "bar")); assertEquals( Arrays.asList(new YearAndValue[] { new YearAndValue(1920, 11f), new YearAndValue(1930, 31f), new YearAndValue(1940, 3f) }), db.getYearAndAssociation(CORPUS, DatabaseService.PPMI_TABLE, "bar", "foo")); assertEquals( Arrays.asList( new YearAndValue[] { new YearAndValue(1950, 23f), }), db.getYearAndAssociation(CORPUS, DatabaseService.CHI_TABLE, "foo", "bar")); assertEquals( Arrays.asList(new YearAndValue[] { new YearAndValue(1960, 11f), new YearAndValue(1970, 31f), new YearAndValue(1980, 3f) }), db.getYearAndAssociation(CORPUS, DatabaseService.CHI_TABLE, "bar", "foo")); }
List<YearAndValue> getYearAndAssociation(final int corpus, final String tableName, final int word1Id, final int word2Id) throws Exception { final String sql = String.format(ASSOCIATION_QUERY, tableName); try (Connection con = sql2o.open()) { final List<YearAndValue> mostSimilar = con.createQuery(sql) .addParameter("word1", word1Id) .addParameter("word2", word2Id) .addParameter("corpus", corpus) .executeAndFetch(YearAndValue.class); return mostSimilar; } }
DatabaseService { List<YearAndValue> getYearAndAssociation(final int corpus, final String tableName, final int word1Id, final int word2Id) throws Exception { final String sql = String.format(ASSOCIATION_QUERY, tableName); try (Connection con = sql2o.open()) { final List<YearAndValue> mostSimilar = con.createQuery(sql) .addParameter("word1", word1Id) .addParameter("word2", word2Id) .addParameter("corpus", corpus) .executeAndFetch(YearAndValue.class); return mostSimilar; } } }
DatabaseService { List<YearAndValue> getYearAndAssociation(final int corpus, final String tableName, final int word1Id, final int word2Id) throws Exception { final String sql = String.format(ASSOCIATION_QUERY, tableName); try (Connection con = sql2o.open()) { final List<YearAndValue> mostSimilar = con.createQuery(sql) .addParameter("word1", word1Id) .addParameter("word2", word2Id) .addParameter("corpus", corpus) .executeAndFetch(YearAndValue.class); return mostSimilar; } } DatabaseService(final Sql2o sql2o, final Configuration config); }
DatabaseService { List<YearAndValue> getYearAndAssociation(final int corpus, final String tableName, final int word1Id, final int word2Id) throws Exception { final String sql = String.format(ASSOCIATION_QUERY, tableName); try (Connection con = sql2o.open()) { final List<YearAndValue> mostSimilar = con.createQuery(sql) .addParameter("word1", word1Id) .addParameter("word2", word2Id) .addParameter("corpus", corpus) .executeAndFetch(YearAndValue.class); return mostSimilar; } } DatabaseService(final Sql2o sql2o, final Configuration config); static void importTables(final Configuration config,
			final Sql2o sql2o); static void initializeTables(final Sql2o sql2o); void dropAll(); String getCorpusLink(final String corpus, final String word); String getCorpusName(final String corpus); String getCorpusNote(final String corpus); Map<Integer, Embedding> getEmbedding(final String corpusName,
			final String word); Map<String, List<YearAndValue>> getEmotion(final String corpusName,
			final String word); Integer getFirstYear(final String corpusName, final String word); Integer getLastYear(final String corpusName, final String word); List<YearAndValue> getSimilarity(final String corpusName,
			final String word1, final String word2); List<String> getTopContextWordsInYear(final String corpusName,
			final String table, final String word, final Integer year,
			final int limit); List<YearAndValue> getYearAndAssociation(final String corpusName,
			final String tableName, final String word1, final String word2); List<YearAndValue> getYearAndFrequency(final String corpusName,
			final String word); boolean knowCorpus(final String corpus); boolean wordInCorpus(final String word, final String corpus); }
DatabaseService { List<YearAndValue> getYearAndAssociation(final int corpus, final String tableName, final int word1Id, final int word2Id) throws Exception { final String sql = String.format(ASSOCIATION_QUERY, tableName); try (Connection con = sql2o.open()) { final List<YearAndValue> mostSimilar = con.createQuery(sql) .addParameter("word1", word1Id) .addParameter("word2", word2Id) .addParameter("corpus", corpus) .executeAndFetch(YearAndValue.class); return mostSimilar; } } DatabaseService(final Sql2o sql2o, final Configuration config); static void importTables(final Configuration config,
			final Sql2o sql2o); static void initializeTables(final Sql2o sql2o); void dropAll(); String getCorpusLink(final String corpus, final String word); String getCorpusName(final String corpus); String getCorpusNote(final String corpus); Map<Integer, Embedding> getEmbedding(final String corpusName,
			final String word); Map<String, List<YearAndValue>> getEmotion(final String corpusName,
			final String word); Integer getFirstYear(final String corpusName, final String word); Integer getLastYear(final String corpusName, final String word); List<YearAndValue> getSimilarity(final String corpusName,
			final String word1, final String word2); List<String> getTopContextWordsInYear(final String corpusName,
			final String table, final String word, final Integer year,
			final int limit); List<YearAndValue> getYearAndAssociation(final String corpusName,
			final String tableName, final String word1, final String word2); List<YearAndValue> getYearAndFrequency(final String corpusName,
			final String word); boolean knowCorpus(final String corpus); boolean wordInCorpus(final String word, final String corpus); static final String SIMILARITY_TABLE; static final String EMOTION_TABLE; static final String PPMI_TABLE; static final String EMBEDDING_TABLE; static final String CHI_TABLE; final Map<String, Corpus> corpora; }