@Test public void testGetEmbedding() throws DatabaseUnitException, Exception { final Map<Integer, Embedding> year2Embedding = db.getEmbedding(CORPUS, "foo"); assertEquals(Sets.newHashSet(1910, 1920, 1930, 1940), year2Embedding.keySet()); assertEquals(1, year2Embedding.get(1910).similarity(year2Embedding.get(1920)), 0.00001); }
List<YearAndString> getEmbedding(final int corpus, final int wordId) throws Exception { try (Connection con = sql2o.open()) { return con.createQuery(EMBEDDING_QUERY) .addParameter("corpus", corpus).addParameter("word", wordId) .executeAndFetch(YearAndString.class); } }
DatabaseService { List<YearAndString> getEmbedding(final int corpus, final int wordId) throws Exception { try (Connection con = sql2o.open()) { return con.createQuery(EMBEDDING_QUERY) .addParameter("corpus", corpus).addParameter("word", wordId) .executeAndFetch(YearAndString.class); } } }
DatabaseService { List<YearAndString> getEmbedding(final int corpus, final int wordId) throws Exception { try (Connection con = sql2o.open()) { return con.createQuery(EMBEDDING_QUERY) .addParameter("corpus", corpus).addParameter("word", wordId) .executeAndFetch(YearAndString.class); } } DatabaseService(final Sql2o sql2o, final Configuration config); }
DatabaseService { List<YearAndString> getEmbedding(final int corpus, final int wordId) throws Exception { try (Connection con = sql2o.open()) { return con.createQuery(EMBEDDING_QUERY) .addParameter("corpus", corpus).addParameter("word", wordId) .executeAndFetch(YearAndString.class); } } 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<YearAndString> getEmbedding(final int corpus, final int wordId) throws Exception { try (Connection con = sql2o.open()) { return con.createQuery(EMBEDDING_QUERY) .addParameter("corpus", corpus).addParameter("word", wordId) .executeAndFetch(YearAndString.class); } } 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; }