| | 313 | |
|---|
| | 314 | morphEdges.add(new MorphEdge("V/TNS", word |
|---|
| | 315 | .getEMdFValue("graphical_preformative") |
|---|
| | 316 | .getString(), morphEdges.size())); |
|---|
| | 317 | morphEdges.add(new MorphEdge("V/STM", word |
|---|
| | 318 | .getEMdFValue("graphical_root_formation") |
|---|
| | 319 | .getString(), morphEdges.size())); |
|---|
| | 320 | morphEdges.add(new MorphEdge("V/LEX", word |
|---|
| | 321 | .getEMdFValue("graphical_lexeme") |
|---|
| | 322 | .getString(), morphEdges.size())); |
|---|
| | 323 | morphEdges.add(new MorphEdge("V/PGN", word |
|---|
| | 324 | .getEMdFValue("graphical_verbal_ending") |
|---|
| | 325 | .getString(), morphEdges.size())); |
|---|
| | 333 | |
|---|
| | 334 | String type = "HEAD/NCOM"; |
|---|
| | 335 | if (psp.equals("proper_noun")) |
|---|
| | 336 | { |
|---|
| | 337 | type = "HEAD/NPROP"; |
|---|
| | 338 | } |
|---|
| | 339 | |
|---|
| | 340 | morphEdges.add(new MorphEdge(type, word |
|---|
| | 341 | .getEMdFValue("graphical_lexeme") |
|---|
| | 342 | .getString(), morphEdges.size())); |
|---|
| | 343 | morphEdges.add(new MorphEdge("MARK/N", word |
|---|
| | 344 | .getEMdFValue("graphical_nominal_ending") |
|---|
| | 345 | .getString(), morphEdges.size())); |
|---|
| | 350 | |
|---|
| | 351 | String type; |
|---|
| | 352 | if (psp.equals("adjective")) |
|---|
| | 353 | { |
|---|
| | 354 | type = "ADJ"; |
|---|
| | 355 | } |
|---|
| | 356 | else if (psp.equals("adverb")) |
|---|
| | 357 | { |
|---|
| | 358 | type = "ADV"; |
|---|
| | 359 | } |
|---|
| | 360 | else if (psp.equals("article")) |
|---|
| | 361 | { |
|---|
| | 362 | type = "DET"; |
|---|
| | 363 | } |
|---|
| | 364 | else if (psp.equals("conjunction")) |
|---|
| | 365 | { |
|---|
| | 366 | type = "CONJ"; |
|---|
| | 367 | } |
|---|
| | 368 | else if (psp.equals("demonstrative_pronoun")) |
|---|
| | 369 | { |
|---|
| | 370 | type = "PRON/DEM"; |
|---|
| | 371 | } |
|---|
| | 372 | else if (psp.equals("interjection")) |
|---|
| | 373 | { |
|---|
| | 374 | type = "INTJ"; |
|---|
| | 375 | } |
|---|
| | 376 | else if (psp.equals("interrogative")) |
|---|
| | 377 | { |
|---|
| | 378 | type = "INTR"; |
|---|
| | 379 | } |
|---|
| | 380 | else if (psp.equals("interrogative_pronoun")) |
|---|
| | 381 | { |
|---|
| | 382 | type = "PRON/INT"; |
|---|
| | 383 | } |
|---|
| | 384 | else if (psp.equals("negative")) |
|---|
| | 385 | { |
|---|
| | 386 | type = "NEG"; |
|---|
| | 387 | } |
|---|
| | 388 | else if (psp.equals("personal_pronoun")) |
|---|
| | 389 | { |
|---|
| | 390 | type = "PRON/PERS"; |
|---|
| | 391 | } |
|---|
| | 392 | else if (psp.equals("preposition")) |
|---|
| | 393 | { |
|---|
| | 394 | type = "P"; |
|---|
| | 395 | } |
|---|
| | 396 | else |
|---|
| | 397 | { |
|---|
| | 398 | throw new IllegalArgumentException("Unknown " + |
|---|
| | 399 | "part of speech: " + psp); |
|---|
| | 400 | } |
|---|
| | 401 | |
|---|
| | 402 | morphEdges.add(new MorphEdge(type, word |
|---|
| | 403 | .getEMdFValue("graphical_lexeme") |
|---|
| | 404 | .getString(), morphEdges.size())); |
|---|
| | 1233 | |
|---|
| | 1234 | <% |
|---|
| | 1235 | |
|---|
| | 1236 | { |
|---|
| | 1237 | Parser p = new Parser(sql); |
|---|
| | 1238 | p.setVerbose(true); |
|---|
| | 1239 | List sentences = p.parseFor(morphEdges, "SENTENCE"); |
|---|
| | 1240 | |
|---|
| | 1241 | if (sentences.size() == 0) |
|---|
| | 1242 | { |
|---|
| | 1243 | %> |
|---|
| | 1244 | <p> |
|---|
| | 1245 | Parse failed. Click |
|---|
| | 1246 | <a href="parsedebug.jsp?clause=<%= clauseId %>">here</a> |
|---|
| | 1247 | to fix it. |
|---|
| | 1248 | </p> |
|---|
| | 1249 | <% |
|---|
| | 1250 | } |
|---|
| | 1251 | else |
|---|
| | 1252 | { |
|---|
| | 1253 | for (int i = 0; i < sentences.size() && i < 3; i++) |
|---|
| | 1254 | { |
|---|
| | 1255 | Edge sentence = (Edge)( sentences.get(i) ); |
|---|
| | 1256 | |
|---|
| | 1257 | %><%= sentence.toTree().toHtml(rend) %><% |
|---|
| | 1258 | } |
|---|
| | 1259 | |
|---|
| | 1260 | %><p> |
|---|
| | 1261 | Click |
|---|
| | 1262 | <a href="parsedebug.jsp?clause=<%= clauseId %>">here</a> |
|---|
| | 1263 | to see and edit all <%= sentences.size() %> parses. |
|---|
| | 1264 | </p><% |
|---|
| | 1265 | } |
|---|
| | 1266 | } |
|---|
| | 1267 | |
|---|
| | 1268 | %> |
|---|
| 1331 | | |
|---|
| 1332 | | TreeNode clauseNode = new TreeNode("Clause"); |
|---|
| 1333 | | TreeNode coreNode = null; |
|---|
| 1334 | | TreeNode nucleusNode = null; |
|---|
| 1335 | | TreeNode leftPeripheryNode = null; |
|---|
| 1336 | | TreeNode rightPeripheryNode = null; |
|---|
| 1337 | | |
|---|
| 1338 | | SheafConstIterator phrases = null; |
|---|
| 1339 | | |
|---|
| 1340 | | if (clause != null) |
|---|
| 1341 | | { |
|---|
| 1342 | | phrases = clause.getSheaf().const_iterator(); |
|---|
| 1343 | | } |
|---|
| 1344 | | |
|---|
| 1345 | | while (phrases != null && phrases.hasNext()) |
|---|
| 1346 | | { |
|---|
| 1347 | | MatchedObject phrase = |
|---|
| 1348 | | phrases.next().const_iterator().next(); |
|---|
| 1349 | | |
|---|
| 1350 | | String function_name = (String)( phrase_functions.get( |
|---|
| 1351 | | phrase.getEMdFValue("function").toString()) |
|---|
| 1352 | | ); |
|---|
| 1353 | | |
|---|
| 1354 | | String phrase_type = (String)( phrase_types.get( |
|---|
| 1355 | | phrase.getEMdFValue("phrase_type").toString()) |
|---|
| 1356 | | ); |
|---|
| 1357 | | |
|---|
| 1358 | | TreeNode phraseNode = new TreeNode(phrase_type); |
|---|
| 1359 | | TreeNode phraseFunc = phraseNode.createChild(function_name); |
|---|
| 1360 | | |
|---|
| 1361 | | SheafConstIterator words = phrase.getSheaf().const_iterator(); |
|---|
| 1362 | | while (words.hasNext()) |
|---|
| 1363 | | { |
|---|
| 1364 | | MatchedObject word = |
|---|
| 1365 | | words.next().const_iterator().next(); |
|---|
| 1366 | | |
|---|
| 1367 | | String lexeme = |
|---|
| 1368 | | word.getEMdFValue("lexeme").getString() |
|---|
| 1369 | | .replaceAll("<", "<") |
|---|
| 1370 | | .replaceAll(">", ">"); |
|---|
| 1371 | | |
|---|
| 1372 | | TreeNode wordNode = phraseFunc.createChild(lexeme); |
|---|
| 1373 | | } |
|---|
| 1374 | | |
|---|
| 1375 | | if (phrase_type.equals("VP") && nucleusNode == null) |
|---|
| 1376 | | { |
|---|
| 1377 | | if (coreNode == null) |
|---|
| 1378 | | { |
|---|
| 1379 | | coreNode = clauseNode.createChild("Core"); |
|---|
| 1380 | | } |
|---|
| 1381 | | |
|---|
| 1382 | | nucleusNode = coreNode.createChild("Nucleus"); |
|---|
| 1383 | | nucleusNode.add(phraseNode); |
|---|
| 1384 | | } |
|---|
| 1385 | | else if (phrase_type.equals("NP") || |
|---|
| 1386 | | phrase_type.equals("IrPronNP") || |
|---|
| 1387 | | phrase_type.equals("PersPronNP") || |
|---|
| 1388 | | phrase_type.equals("DemPronNP") || |
|---|
| 1389 | | phrase_type.equals("PropNP") || |
|---|
| 1390 | | (phrase_type.equals("PP") && ! function_name.equals("Time"))) |
|---|
| 1391 | | { |
|---|
| 1392 | | if (coreNode == null) |
|---|
| 1393 | | { |
|---|
| 1394 | | coreNode = clauseNode.createChild("Core"); |
|---|
| 1395 | | } |
|---|
| 1396 | | |
|---|
| 1397 | | TreeNode argument = coreNode.createChild("Argument"); |
|---|
| 1398 | | argument.add(phraseNode); |
|---|
| 1399 | | } |
|---|
| 1400 | | else |
|---|
| 1401 | | { |
|---|
| 1402 | | TreeNode periphery; |
|---|
| 1403 | | |
|---|
| 1404 | | if (coreNode == null) |
|---|
| 1405 | | { |
|---|
| 1406 | | if (leftPeripheryNode == null) |
|---|
| 1407 | | { |
|---|
| 1408 | | leftPeripheryNode = clauseNode.createChild("Periphery"); |
|---|
| 1409 | | } |
|---|
| 1410 | | periphery = leftPeripheryNode; |
|---|
| 1411 | | } |
|---|
| 1412 | | else |
|---|
| 1413 | | { |
|---|
| 1414 | | if (rightPeripheryNode == null) |
|---|
| 1415 | | { |
|---|
| 1416 | | rightPeripheryNode = clauseNode.createChild("Periphery"); |
|---|
| 1417 | | } |
|---|
| 1418 | | periphery = rightPeripheryNode; |
|---|
| 1419 | | } |
|---|
| 1420 | | |
|---|
| 1421 | | TreeNode other = periphery.createChild(""); |
|---|
| 1422 | | other.add(phraseNode); |
|---|
| 1423 | | } |
|---|
| 1424 | | } |
|---|