Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseGlobalConceptStore.java |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | protected RelationTable originTable; |
48 | 48 | protected RelationTable relationTable; |
49 | 49 | protected RelationTable mergeTable; |
| 50 | + protected RelationTable meaningTable; |
50 | 51 | |
51 | 52 | //protected TweakSet tweaks; |
52 | 53 | |
— | — | @@ -98,6 +99,7 @@ |
99 | 100 | originTable = (RelationTable)database.getTable("origin"); |
100 | 101 | relationTable = (RelationTable)database.getTable("relation"); |
101 | 102 | mergeTable = (RelationTable)database.getTable("merge"); |
| 103 | + meaningTable = (RelationTable)database.getTable("meaning"); |
102 | 104 | } |
103 | 105 | |
104 | 106 | @Override |
— | — | @@ -114,7 +116,8 @@ |
115 | 117 | } |
116 | 118 | |
117 | 119 | protected String meaningsSQL(String lang, String term) throws PersistenceException { |
118 | | - DatabaseLocalConceptStore db = getLocalConceptStore(lang); |
| 120 | + /* |
| 121 | + DatabaseLocalConceptStore db = getLocalConceptStore(lang); |
119 | 122 | |
120 | 123 | String sql = " JOIN "+originTable.getSQLName()+" as L ON C.id = L.global_concept AND L.lang = " +database.quoteString(lang) + " " + |
121 | 124 | " JOIN "+db.meaningTable.getSQLName()+" as M ON M.concept = L.local_concept " + |
— | — | @@ -122,6 +125,16 @@ |
123 | 126 | " ORDER BY freq DESC"; |
124 | 127 | |
125 | 128 | return sql; |
| 129 | + */ |
| 130 | + |
| 131 | + String sql = " JOIN "+meaningTable.getSQLName()+" as M on C.id = M.concept " + |
| 132 | + " WHERE M.term_text = "+database.quoteString(term)+" "; |
| 133 | + |
| 134 | + if ( lang != null ) sql += " AND M.lang = "+database.quoteString(lang)+" "; |
| 135 | + |
| 136 | + sql += " ORDER BY freq DESC"; |
| 137 | + |
| 138 | + return sql; |
126 | 139 | } |
127 | 140 | |
128 | 141 | /* |
— | — | @@ -216,6 +229,10 @@ |
217 | 230 | return ((DatabaseGlobalConceptInfoStore)getConceptInfoStore()).getMeanings(lang, term, spec); |
218 | 231 | } |
219 | 232 | |
| 233 | + public DataSet<GlobalConcept> getMeanings(String term, ConceptQuerySpec spec) throws PersistenceException { |
| 234 | + return ((DatabaseGlobalConceptInfoStore)getConceptInfoStore()).getMeanings(term, spec); |
| 235 | + } |
| 236 | + |
220 | 237 | public List<LocalConcept> getLocalConcepts(int id, ConceptQuerySpec spec) throws PersistenceException { |
221 | 238 | return ((DatabaseGlobalConceptInfoStore)getConceptInfoStore()).getLocalConcepts(id, spec); |
222 | 239 | } |
— | — | @@ -358,6 +375,13 @@ |
359 | 376 | String sql = conceptSelect(spec, "M.freq") + meaningsSQL(lang, term); |
360 | 377 | return new QueryDataSet<GlobalConcept>(database, new ConceptFactory(spec), "getMeanings", sql, false); |
361 | 378 | } |
| 379 | + |
| 380 | + public DataSet<GlobalConcept> getMeanings(String term, ConceptQuerySpec spec) |
| 381 | + throws PersistenceException { |
| 382 | + |
| 383 | + String sql = conceptSelect(spec, "M.freq") + meaningsSQL(null, term); |
| 384 | + return new QueryDataSet<GlobalConcept>(database, new ConceptFactory(spec), "getMeanings", sql, false); |
| 385 | + } |
362 | 386 | } |
363 | 387 | |
364 | 388 | ////////////////////////////////////////////////////////////////////////////// |
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/GlobalConceptStore.java |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | import de.brightbyte.wikiword.Corpus; |
9 | 9 | import de.brightbyte.wikiword.model.GlobalConcept; |
10 | 10 | import de.brightbyte.wikiword.model.LocalConcept; |
| 11 | +import de.brightbyte.wikiword.store.WikiWordConceptStore.ConceptQuerySpec; |
11 | 12 | |
12 | 13 | |
13 | 14 | /** |
— | — | @@ -16,6 +17,8 @@ |
17 | 18 | |
18 | 19 | //TODO: relevance limit? order? |
19 | 20 | public DataSet<GlobalConcept> getMeanings(String lang, String term, ConceptQuerySpec spec) throws PersistenceException; |
| 21 | + |
| 22 | + public DataSet<GlobalConcept> getMeanings(String term, ConceptQuerySpec spec) throws PersistenceException; |
20 | 23 | |
21 | 24 | //public abstract ResultSet queryTermRefersTo() throws PersistenceException; |
22 | 25 | |