Changeset 99
- Timestamp:
- 02/18/07 13:18:42 (2 years ago)
- Files:
-
- lex/trunk/.project (modified) (1 diff)
- lex/trunk/.tomcatplugin (modified) (1 diff)
- lex/trunk/jsp/clause.jsp (modified) (10 diffs)
- lex/trunk/jsp/dump.jsp (modified) (1 diff)
- lex/trunk/jsp/navclause.jsp (modified) (7 diffs)
- lex/trunk/jsp/parse.jsp (modified) (3 diffs)
- lex/trunk/jsp/WEB-INF/lib/emdros-libs.tar.gz (modified) (previous)
- lex/trunk/jsp/WEB-INF/lib/jemdros.jar (modified) (previous)
- lex/trunk/src/com/qwirx/lex/emdros/EmdrosChange.java (modified) (5 diffs)
- lex/trunk/src/com/qwirx/lex/emdros/EmdrosDatabase.java (modified) (15 diffs)
- lex/trunk/src/com/qwirx/lex/Lex.java (modified) (1 diff)
- lex/trunk/src/com/qwirx/lex/morph/HebrewMorphemeGenerator.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lex/trunk/.project
r26 r99 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <projectDescription> 3 <name>lex </name>3 <name>lex-new-emdros</name> 4 4 <comment></comment> 5 5 <projects> lex/trunk/.tomcatplugin
r26 r99 8 8 <warLocation>/tmp/lex.war</warLocation> 9 9 <extraInfo></extraInfo> 10 <webPath>/lex </webPath>10 <webPath>/lex-new</webPath> 11 11 </tomcatProjectProperties> lex/trunk/jsp/clause.jsp
r89 r99 81 81 82 82 Map phrase_functions = emdros.getEnumerationConstants 83 ("phrase_function_ t",false);83 ("phrase_function_e",false); 84 84 85 85 Map phrase_types = emdros.getEnumerationConstants 86 ("phrase_type_ t",false);86 ("phrase_type_e",false); 87 87 88 88 Map parts_of_speech = emdros.getEnumerationConstants 89 ("psp_t",false); 90 91 Map verbal_stems = emdros.getEnumerationConstants 92 ("verbal_stem_t",false); 89 ("part_of_speech_e",false); 93 90 94 91 if (request.getParameter("savearg") != null) … … 122 119 " WHERE [clause self = "+selClauseId+ 123 120 " GET logical_struct_id, logical_structure "+ 124 " [phrase GET phrase_type, function, argument_name, "+121 " [phrase GET phrase_type, phrase_function, argument_name, "+ 125 122 " type_id, macrorole_number "+ 126 " [word GET lexeme, p dpsp, verbal_stem, verbal_tense, " +127 " wordnet_gloss, wordnet_synset, " +123 " [word GET lexeme, phrase_dependent_part_of_speech, " + 124 " tense, wordnet_gloss, wordnet_synset, " + 128 125 " graphical_preformative, " + 129 126 " graphical_locative, " + … … 189 186 190 187 String function_name = (String)( phrase_functions.get( 191 phrase.getEMdFValue(" function").toString())188 phrase.getEMdFValue("phrase_function").toString()) 192 189 ); 193 190 … … 198 195 199 196 String psp = (String)( parts_of_speech.get( 200 word.getEMdFValue("p dpsp").toString())197 word.getEMdFValue("phrase_dependent_part_of_speech").toString()) 201 198 ); 202 199 … … 426 423 427 424 String function_name = (String)( phrase_functions.get( 428 phrase.getEMdFValue(" function").toString())425 phrase.getEMdFValue("phrase_function").toString()) 429 426 ); 430 427 … … 443 440 String lexeme = 444 441 word.getEMdFValue("lexeme").getString(); 445 String verbal_stem =446 word.getEMdFValue("verbal_stem").toString();447 442 String part_of_speech = (String) 448 parts_of_speech.get(word.getEMdFValue("p dpsp")443 parts_of_speech.get(word.getEMdFValue("phrase_dependent_part_of_speech") 449 444 .toString()); 450 445 … … 728 723 } 729 724 } 730 731 {732 Cell stemCell = new Cell();733 cell.subcells.add(stemCell);734 735 stemCell.html =736 (String)( verbal_stems.get(verbal_stem) );737 if (stemCell.html.equals("NA"))738 stemCell.html = "";739 }740 725 } 741 726 } … … 744 729 { 745 730 Cell pCell = new Cell(); 746 pCell.label = phrase.getEMdFValue(" function").toString();731 pCell.label = phrase.getEMdFValue("phrase_function").toString(); 747 732 pCell.columns = column - first_col; 748 733 struct_row.addElement(pCell); … … 1304 1289 %> 1305 1290 1306 <h 2>Notes</h2>1291 <h3>Notes</h3> 1307 1292 1308 1293 <% … … 1444 1429 1445 1430 <hr> 1446 Book <%= session.getAttribute("bookNum") %> 1447 Chapter <%= session.getAttribute("chapterNum") %> 1448 Verse <%= session.getAttribute("verseNum") %> 1431 <%= session.getAttribute("book") %>, 1432 Chapter <%= session.getAttribute("chapterNum") %>, 1433 Verse <%= session.getAttribute("verseNum") %>, 1449 1434 Clause <%= session.getAttribute("clauseId") %> 1450 1435 </form> lex/trunk/jsp/dump.jsp
r31 r99 1 <% 2 response.setContentType("text/html; charset=UTF-8"); 3 %> 1 4 <%@ page import="java.util.Enumeration" %> 2 5 <%@ page import="java.util.Hashtable" %> lex/trunk/jsp/navclause.jsp
r69 r99 14 14 <% 15 15 16 int selBookNum = 1; 17 18 { 19 Integer sessionBookNum = (Integer)( session.getAttribute("bookNum") ); 20 if (sessionBookNum != null) 21 { 22 selBookNum = sessionBookNum.intValue(); 23 } 24 } 25 26 try 16 String selBook = "Genesis"; 17 18 { 19 String selBook2 = (String)( session.getAttribute("book") ); 20 if (selBook2 != null) 21 { 22 selBook = selBook2; 23 } 24 } 25 27 26 { 28 int newBookNum = Integer.parseInt(request.getParameter("book")); 29 selBookNum = newBookNum; 27 String selBook2 = request.getParameter("book"); 28 if (selBook2 != null) 29 { 30 selBook = selBook2; 31 } 30 32 } 31 catch (Exception e) { /* ignore it and use default book */ }32 33 33 34 { … … 55 56 Table featureTable = emdros.getTable 56 57 ( 57 "GET FEATURES book , book_numberFROM OBJECTS WITH ID_DS = " +58 "GET FEATURES book FROM OBJECTS WITH ID_DS = " + 58 59 id_dList.toString() + " [book]" 59 60 ); … … 63 64 { 64 65 TableRow row = rows.next(); 65 int thisBookNum = Integer.parseInt(row.getColumn(3));66 67 if (thisBook Num == selBookNum)66 String thisBook = row.getColumn(2); 67 68 if (thisBook.equals(selBook)) 68 69 { 69 70 foundBook = true; … … 82 83 %> 83 84 <option <%= 84 thisBook Num == selBookNum? "SELECTED" : ""85 thisBook.equals(selBook) ? "SELECTED" : "" 85 86 %> value="<%= 86 row.getColumn( 3)87 row.getColumn(2) 87 88 %>"><%= 88 89 row.getColumn(2) … … 92 93 if (foundBook) 93 94 { 94 session.setAttribute("book Num", new Integer(selBookNum));95 session.setAttribute("book", selBook); 95 96 } 96 97 } … … 211 212 emdros.getMonadSet(userTextAccess, min_m, max_m) + 212 213 " WHERE [verse "+ 213 " book _number = "+selBookNum+" AND "+214 " chapter = "+selChapNum+214 " book = "+selBook+" AND "+ 215 " chapter = "+selChapNum+ 215 216 " GET verse, verse_label]" 216 217 ); … … 276 277 emdros.getMonadSet(userTextAccess, min_m, max_m) + 277 278 " WHERE [verse "+ 278 " book _number = "+selBookNum+" AND "+279 " chapter = "+selChapNum+" AND "+280 " verse = "+selVerseNum+279 " book = "+selBook+" AND "+ 280 " chapter = "+selChapNum+" AND "+ 281 " verse = "+selVerseNum+ 281 282 " GET bart_gloss "+ 282 283 " [clause "+ lex/trunk/jsp/parse.jsp
r97 r99 248 248 <% 249 249 250 Map phrase_functions = emdros.getEnumerationConstants251 ("phrase_function_t",false);252 253 250 Map phrase_types = emdros.getEnumerationConstants 254 ("phrase_type_t",false); 255 256 Map verbal_stems = emdros.getEnumerationConstants 257 ("verbal_stem_t",false); 258 251 ("phrase_type_e",false); 252 259 253 OntologyDb ontology = Lex.getOntologyDb(); 260 254 … … 277 271 " WHERE [clause self = "+selClauseId+ 278 272 " GET logical_struct_id, logical_structure "+ 279 " [phrase GET phrase_type, function,argument_name, "+273 " [phrase GET phrase_type, argument_name, "+ 280 274 " type_id, macrorole_number "+ 281 " [word GET lexeme, p dpsp, verbal_stem, verbal_tense, "+282 " wordnet_gloss, wordnet_synset, " +275 " [word GET lexeme, phrase_dependent_part_of_speech, "+ 276 " tense, wordnet_gloss, wordnet_synset, " + 283 277 " graphical_preformative, " + 284 278 " graphical_locative, " + … … 330 324 MatchedObject phrase = 331 325 phrases.next().const_iterator().next(); 332 333 String function_name = (String)( phrase_functions.get(334 phrase.getEMdFValue("function").toString())335 );336 326 337 327 SheafConstIterator words = phrase.getSheaf().const_iterator(); lex/trunk/src/com/qwirx/lex/emdros/EmdrosChange.java
r26 r99 19 19 20 20 import jemdros.Table; 21 import jemdros.TableException; 21 22 import jemdros.TableIterator; 22 23 import jemdros.TableRow; … … 186 187 187 188 private void captureValues(boolean createRowChangeLogs, boolean storeAsNewValue) 188 throws SQLException, DatabaseException 189 throws SQLException, DatabaseException, TableException 189 190 { 190 191 /* … … 327 328 328 329 private void captureOldValues() 329 throws DatabaseException, SQLException 330 throws DatabaseException, SQLException, TableException 330 331 { 331 332 if (changeType != UPDATE && changeType != DELETE) … … 337 338 338 339 private void captureNewValues() 339 throws SQLException, DatabaseException 340 throws SQLException, DatabaseException, TableException 340 341 { 341 342 if (changeType != CREATE && changeType != UPDATE) … … 516 517 throw new DatabaseException(e, sb.toString()); 517 518 } 518 519 catch (TableException e) 520 { 521 m_log.error(sb.toString(), e); 522 throw new DatabaseException(e, sb.toString()); 523 } 519 524 } 520 525 lex/trunk/src/com/qwirx/lex/emdros/EmdrosDatabase.java
r26 r99 14 14 import java.util.Map; 15 15 16 import jemdros.BadMonadsException; 17 import jemdros.EMdFDBDBError; 16 18 import jemdros.EmdrosEnv; 19 import jemdros.EmdrosException; 17 20 import jemdros.MatchedObject; 18 21 import jemdros.MonadSetElement; … … 20 23 import jemdros.Sheaf; 21 24 import jemdros.Table; 25 import jemdros.TableException; 22 26 import jemdros.TableIterator; 23 27 import jemdros.TableRow; … … 59 63 boolean[] bCompilerResult = new boolean[1]; 60 64 61 boolean bDBResult = env.executeString(query, bCompilerResult, false, false); 65 boolean bDBResult = false; 66 67 try 68 { 69 bDBResult = env.executeString(query, bCompilerResult, false, false); 70 } 71 catch (TableException e) 72 { 73 throw new DatabaseException(e, query); 74 } 75 catch (BadMonadsException e) 76 { 77 throw new DatabaseException(e, query); 78 } 79 catch (EMdFDBDBError e) 80 { 81 throw new DatabaseException(e, query); 82 } 83 catch (EmdrosException e) 84 { 85 throw new DatabaseException(e, query); 86 } 62 87 63 88 if (!bDBResult) { … … 104 129 { 105 130 Table min_m_table = getTable("SELECT MIN_M"); 106 return Integer.parseInt( 107 min_m_table.iterator().next().iterator().next() 131 try 132 { 133 return Integer.parseInt 134 ( 135 min_m_table.iterator().next().iterator().next() 108 136 ); 137 } 138 catch (TableException e) 139 { 140 throw new DatabaseException(e, "SELECT MIN_M"); 141 } 109 142 } 110 143 … … 112 145 { 113 146 Table max_m_table = getTable("SELECT MAX_M"); 114 return Integer.parseInt( 115 max_m_table.iterator().next().iterator().next() 147 148 try 149 { 150 return Integer.parseInt 151 ( 152 max_m_table.iterator().next().iterator().next() 116 153 ); 154 } 155 catch (TableException e) 156 { 157 throw new DatabaseException(e, "SELECT MAX_M"); 158 } 117 159 } 118 160 … … 125 167 126 168 TableIterator rows = table.iterator(); 127 while (rows.hasNext()) { 128 TableRow row = rows.next(); 129 130 String name = row.getColumn(1); 131 String number = row.getColumn(2); 132 133 if (byName) 134 result.put(name, number); 135 else 136 result.put(number, name); 137 } 138 169 170 try 171 { 172 while (rows.hasNext()) 173 { 174 TableRow row = rows.next(); 175 176 String name = row.getColumn(1); 177 String number = row.getColumn(2); 178 179 if (byName) 180 result.put(name, number); 181 else 182 result.put(number, name); 183 } 184 } 185 catch (TableException e) 186 { 187 throw new DatabaseException(e, 188 "SELECT ENUMERATION CONSTANTS FROM "+type); 189 } 190 139 191 return result; 140 192 } … … 148 200 Table table = getTable("MONAD SET CALCULATION "+query); 149 201 TableIterator rows = table.iterator(); 150 151 while (rows.hasNext()) 152 { 153 TableRow row = rows.next(); 154 155 String min = row.getColumn(1); 156 String max = row.getColumn(2); 157 158 result.append(min+"-"+max); 159 if (rows.hasNext()) 160 { 161 result.append(","); 162 } 202 203 try 204 { 205 while (rows.hasNext()) 206 { 207 TableRow row = rows.next(); 208 209 String min = row.getColumn(1); 210 String max = row.getColumn(2); 211 212 result.append(min+"-"+max); 213 if (rows.hasNext()) 214 { 215 result.append(","); 216 } 217 } 218 } 219 catch (TableException e) 220 { 221 throw new DatabaseException(e, "MONAD SET CALCULATION "+query); 163 222 } 164 223 … … 188 247 } 189 248 } 190 catch ( SQLException e)249 catch (DatabaseException e) 191 250 { 192 251 throw new DatabaseException("Failed to determine object access", … … 205 264 TableIterator features = 206 265 getTable("SELECT FEATURES FROM ["+objectType+"]").iterator(); 207 208 while (features.hasNext()) 209 { 210 TableRow tr = features.next(); 211 String name = tr.getColumn(1); 212 if (name.equals(feature)) 213 { 214 return; 215 } 216 } 217 266 267 try 268 { 269 while (features.hasNext()) 270 { 271 TableRow tr = features.next(); 272 String name = tr.getColumn(1); 273 if (name.equals(feature)) 274 { 275 return; 276 } 277 } 278 } 279 catch (TableException e) 280 { 281 throw new DatabaseException(e, "SELECT FEATURES FROM ["+objectType+"]"); 282 } 283 218 284 executeDirect("UPDATE OBJECT TYPE "+ 219 285 "["+objectType+" ADD "+feature+" : "+featureType+";]"); … … 227 293 TableIterator features = 228 294 getTable("SELECT OBJECT TYPES").iterator(); 229 230 while (features.hasNext()) 231 { 232 TableRow tr = features.next(); 233 String name = tr.getColumn(1); 234 if (name.equals(objectType)) 235 { 236 haveType = true; 237 break; 238 } 295 296 try 297 { 298 while (features.hasNext()) 299 { 300 TableRow tr = features.next(); 301 String name = tr.getColumn(1); 302 if (name.equals(objectType)) 303 { 304 haveType = true; 305 break; 306 } 307 } 308 } 309 catch (TableException e) 310 { 311 throw new DatabaseException(e, "SELECT OBJECT TYPES"); 239 312 } 240 313 … … 288 361 289 362 public boolean canWriteTo(MatchedObject object) 290 throws SQLException363 throws DatabaseException 291 364 { 292 365 SetOfMonads monads = new SetOfMonads(); … … 296 369 297 370 public boolean canWriteTo(String objectType, int objectId) 298 throws DatabaseException , SQLException371 throws DatabaseException 299 372 { 300 373 return canWriteTo(objectType, new int[]{objectId}); … … 302 375 303 376 public boolean canWriteTo(String objectType, int[] objectIds) 304 throws DatabaseException , SQLException377 throws DatabaseException 305 378 { 306 379 String query = "GET MONADS FROM OBJECTS WITH ID_DS = "; … … 320 393 SetOfMonads monads = new SetOfMonads(); 321 394 322 while (rows.hasNext()) 323 { 324 TableRow row = rows.next(); 325 int first = Integer.parseInt(row.getColumn(2)); 326 int last = Integer.parseInt(row.getColumn(3)); 327 monads.add(first, last); 395 try 396 { 397 while (rows.hasNext()) 398 { 399 TableRow row = rows.next(); 400 int first = Integer.parseInt(row.getColumn(2)); 401 int last = Integer.parseInt(row.getColumn(3)); 402 monads.add(first, last); 403 } 404 } 405 catch (TableException e) 406 { 407 throw new DatabaseException(e, query); 328 408 } 329 409 … … 332 412 333 413 private boolean canWriteTo(SetOfMonads monads) 334 throws SQLException 335 { 336 PreparedStatement stmt = conn.prepareStatement 337 ( 338 "SELECT Monad_First, Monad_Last " + 339 "FROM user_text_access " + 340 "WHERE (User_Name = ? OR User_Name = 'anonymous') " + 341 "AND Write_Access = '1'" 342 ); 343 stmt.setString(1, username); 344 345 ResultSet rs = stmt.executeQuery(); 346 347 while (rs.next()) 348 { 349 int first = rs.getInt(1); 350 int last = rs.getInt(2); 351 MonadSetElement mse = new MonadSetElement(first, last); 352 monads.removeMSE(mse); 353 } 354 355 stmt.close(); 356 rs.close(); 357 414 throws DatabaseException 415 { 416 PreparedStatement stmt = null; 417 ResultSet rs = null; 418 419 String query = "SELECT Monad_First, Monad_Last " + 420 "FROM user_text_access " + 421 "WHERE (User_Name = ? OR User_Name = 'anonymous') " + 422 "AND Write_Access = '1'"; 423 424 try 425 { 426 stmt = conn.prepareStatement(query); 427 stmt.setString(1, username); 428 rs = stmt.executeQuery(); 429 } 430 catch (SQLException e) 431 { 432 throw new DatabaseException(e, query); 433 } 434 435 int first = 0; 436 int last = 0; 437 438 try 439 { 440 while (rs.next()) 441 { 442 first = rs.getInt(1); 443 last = rs.getInt(2); 444 MonadSetElement mse = new MonadSetElement(first, last); 445 monads.removeMSE(mse); 446 } 447 448 stmt.close(); 449 rs.close(); 450 } 451 catch (SQLException e) 452 { 453 throw new DatabaseException(e, "constructing monad set "+ 454 first+"-"+last); 455 } 456 catch (BadMonadsException e) 457 { 458 throw new DatabaseException(e, "constructing monad set "+ 459 first+"-"+last); 460 } 461 358 462 return monads.isEmpty(); 359 463 } lex/trunk/src/com/qwirx/lex/Lex.java
r90 r99 63 63 EmdrosEnv env = new EmdrosEnv(eOutputKind.kOKConsole, 64 64 eCharsets.kCSISO_8859_1, "localhost", "emdf", "changeme", 65 "wihebrew 1202");65 "wihebrew"); 66 66 67 67 if (!env.connectionOk()) lex/trunk/src/com/qwirx/lex/morph/HebrewMorphemeGenerator.java
r91 r99 17 17 private MorphemeHandler m_Handler; 18 18 private static Map m_Persons, m_Genders, m_Numbers, m_States, 19 m_PartsOfSpeech, m_Tenses , m_Stems;19 m_PartsOfSpeech, m_Tenses; 20 20 private OntologyDb m_Ontology; 21 21 … … 28 28 if (m_Persons == null) 29 29 { 30 m_Persons = emdros.getEnumerationConstants("person_ t", false);30 m_Persons = emdros.getEnumerationConstants("person_e", false); 31 31 } 32 32 33 33 if (m_Genders == null) 34 34 { 35 m_Genders = emdros.getEnumerationConstants("gender_ t", false);35 m_Genders = emdros.getEnumerationConstants("gender_e", false); 36 36 } 37 37 38 38 if (m_Numbers == null) 39 39 { 40 m_Numbers = emdros.getEnumerationConstants("number_ t", false);40 m_Numbers = emdros.getEnumerationConstants("number_e", false); 41 41 } 42 42 43 43 if (m_States == null) 44 44 { 45 m_States = emdros.getEnumerationConstants("state_ t", false);45 m_States = emdros.getEnumerationConstants("state_e", false); 46 46 } 47 47 48 48 if (m_PartsOfSpeech == null) 49 49 { 50 m_PartsOfSpeech = emdros.getEnumerationConstants("psp_t", false); 50 m_PartsOfSpeech = emdros.getEnumerationConstants("part_of_speech_e", 51 false); 51 52 } 52 53 53 54 if (m_Tenses == null) 54 55 { 55 m_Tenses = emdros.getEnumerationConstants("verbal_tense_t", false); 56 } 57 56 m_Tenses = emdros.getEnumerationConstants("tense_e", false); 57 } 58 59 /* 58 60 if (m_Stems == null) 59 61 { … … 61 63 62 64 } 65 */ 63 66 64 67 if (m_Ontology == null) … … 76 79 77 80 String psp = (String)( m_PartsOfSpeech.get( 78 word.getEMdFValue("p dpsp").toString())81 word.getEMdFValue("phrase_dependent_part_of_speech").toString()) 79 82 ); 80 83 81 84 String person = (String)m_Persons.get( 82 85 word.getEMdFValue("person").toString()); 83 if (person.equals(" pers_first")) person = "1";84 else if (person.equals(" pers_second")) person = "2";85 else if (person.equals(" pers_third")) person = "3";86 if (person.equals("first_person")) person = "1"; 87 else if (person.equals("second_person")) person = "2"; 88 else if (person.equals("third_person")) person = "3"; 86 89 87 90 String gender = ((String)m_Genders.get( … … 119 122 if (psp.equals("verb")) 120 123 { 121 String tenseNum = word.getEMdFValue(" verbal_tense").toString();124 String tenseNum = word.getEMdFValue("tense").toString(); 122 125 m_Handler.convert("graphical_preformative", false, 123 126 (String)m_Tenses.get(tenseNum), "V/TNS"); 124 127 125 String stemNum = word.getEMdFValue("verbal_stem").toString();128 // String stemNum = word.getEMdFValue("verbal_stem").toString(); 126 129 m_Handler.convert("graphical_root_formation", false, 127 (String)m_Stems.get(stemNum), "V/STM");130 "(stem)", "V/STM"); 128 131 129 132 m_Handler.convert("graphical_lexeme", false, … … 196 199 type = "PRON/PERS"; 197 200 } 201 else if (psp.equals("pronoun")) 202 { 203 type = "PRON"; 204 } 198 205 else if (psp.equals("preposition")) 199 206 {
