r68134 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68133‎ | r68134 | r68135 >
Date:20:44, 16 June 2010
Author:daniel
Status:deferred
Tags:
Comment:
use global meanings table to do language-independant lookups. usful for proper names with different transciptions, etc. Note that a good 50% of entries are for proper names.
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseGlobalConceptStore.java (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/GlobalConceptStore.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseGlobalConceptStore.java
@@ -46,6 +46,7 @@
4747 protected RelationTable originTable;
4848 protected RelationTable relationTable;
4949 protected RelationTable mergeTable;
 50+ protected RelationTable meaningTable;
5051
5152 //protected TweakSet tweaks;
5253
@@ -98,6 +99,7 @@
99100 originTable = (RelationTable)database.getTable("origin");
100101 relationTable = (RelationTable)database.getTable("relation");
101102 mergeTable = (RelationTable)database.getTable("merge");
 103+ meaningTable = (RelationTable)database.getTable("meaning");
102104 }
103105
104106 @Override
@@ -114,7 +116,8 @@
115117 }
116118
117119 protected String meaningsSQL(String lang, String term) throws PersistenceException {
118 - DatabaseLocalConceptStore db = getLocalConceptStore(lang);
 120+ /*
 121+ DatabaseLocalConceptStore db = getLocalConceptStore(lang);
119122
120123 String sql = " JOIN "+originTable.getSQLName()+" as L ON C.id = L.global_concept AND L.lang = " +database.quoteString(lang) + " " +
121124 " JOIN "+db.meaningTable.getSQLName()+" as M ON M.concept = L.local_concept " +
@@ -122,6 +125,16 @@
123126 " ORDER BY freq DESC";
124127
125128 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;
126139 }
127140
128141 /*
@@ -216,6 +229,10 @@
217230 return ((DatabaseGlobalConceptInfoStore)getConceptInfoStore()).getMeanings(lang, term, spec);
218231 }
219232
 233+ public DataSet<GlobalConcept> getMeanings(String term, ConceptQuerySpec spec) throws PersistenceException {
 234+ return ((DatabaseGlobalConceptInfoStore)getConceptInfoStore()).getMeanings(term, spec);
 235+ }
 236+
220237 public List<LocalConcept> getLocalConcepts(int id, ConceptQuerySpec spec) throws PersistenceException {
221238 return ((DatabaseGlobalConceptInfoStore)getConceptInfoStore()).getLocalConcepts(id, spec);
222239 }
@@ -358,6 +375,13 @@
359376 String sql = conceptSelect(spec, "M.freq") + meaningsSQL(lang, term);
360377 return new QueryDataSet<GlobalConcept>(database, new ConceptFactory(spec), "getMeanings", sql, false);
361378 }
 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+ }
362386 }
363387
364388 //////////////////////////////////////////////////////////////////////////////
Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/GlobalConceptStore.java
@@ -7,6 +7,7 @@
88 import de.brightbyte.wikiword.Corpus;
99 import de.brightbyte.wikiword.model.GlobalConcept;
1010 import de.brightbyte.wikiword.model.LocalConcept;
 11+import de.brightbyte.wikiword.store.WikiWordConceptStore.ConceptQuerySpec;
1112
1213
1314 /**
@@ -16,6 +17,8 @@
1718
1819 //TODO: relevance limit? order?
1920 public DataSet<GlobalConcept> getMeanings(String lang, String term, ConceptQuerySpec spec) throws PersistenceException;
 21+
 22+ public DataSet<GlobalConcept> getMeanings(String term, ConceptQuerySpec spec) throws PersistenceException;
2023
2124 //public abstract ResultSet queryTermRefersTo() throws PersistenceException;
2225

Status & tagging log