Changeset 989
- Timestamp:
- 12/14/10 10:32:42 (13 years ago)
- Location:
- vlo/trunk/vlo_webapp/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIData.java
r801 r989 17 17 } 18 18 19 public void addDocField(String name, String value ) {19 public void addDocField(String name, String value, boolean caseSensitive) { 20 20 if (doc == null) { 21 21 doc = new SolrInputDocument(); 22 22 } 23 23 if (value != null && !value.isEmpty()) { 24 doc.addField(name, value); 24 if (caseSensitive) { 25 doc.addField(name, value.toLowerCase()); 26 } else { 27 doc.addField(name, value); 28 } 25 29 } 26 30 } … … 43 47 return id; 44 48 } 45 46 49 } -
vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/CMDIDigester.java
r988 r989 78 78 List<FacetConfiguration> facetList = facetMapping.getFacets(); 79 79 for (FacetConfiguration facetConfiguration : facetList) { 80 matchDocumentField(result, facetConfiguration .getPattern(), facetConfiguration.getName(), doc, xpath);80 matchDocumentField(result, facetConfiguration, doc, xpath); 81 81 } 82 82 return result; 83 83 } 84 84 85 private void matchDocumentField(CMDIData result, String pattern, String fieldName, Document doc, XPath xpath)85 private void matchDocumentField(CMDIData result, FacetConfiguration facetConfig, Document doc, XPath xpath) 86 86 throws XPathExpressionException { 87 NodeList nodes = (NodeList) xpath.evaluate( pattern, doc, XPathConstants.NODESET);87 NodeList nodes = (NodeList) xpath.evaluate(facetConfig.getPattern(), doc, XPathConstants.NODESET); 88 88 if (nodes != null) { 89 89 for (int i = 0; i < nodes.getLength(); i++) { 90 result.addDocField(f ieldName, nodes.item(i).getNodeValue());90 result.addDocField(facetConfig.getName(), nodes.item(i).getNodeValue(), facetConfig.isCaseSensitive()); 91 91 } 92 92 } // else do nothing it is perfectly acceptable that not all data is in a cmdi file so not everything will be matched. E.G xpath expression evaluation CMDI session files will never match on CMD corpus files. -
vlo/trunk/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/CMDIDigesterTest.java
r988 r989 375 375 assertEquals("Netherlands", doc.getFieldValue("country")); 376 376 assertEquals("Max Planck Institute for Psycholinguistics", doc.getFieldValue("organisation")); 377 assertEquals(" Unspecified", doc.getFieldValue("genre"));377 assertEquals("unspecified", doc.getFieldValue("genre")); 378 378 assertEquals( 379 379 "This recording was made to generate a freely available test resource including speech and gestures. The annotations were created by Peter and Kita who is gesture researcher at the MPI for Psycholinguistics.", … … 466 466 assertEquals("Europe", doc.getFieldValue("continent")); 467 467 assertEquals("Netherlands", doc.getFieldValue("country")); 468 assertEquals(" Unspecified", doc.getFieldValue("genre"));468 assertEquals("unspecified", doc.getFieldValue("genre")); 469 469 assertEquals("Test.", doc.getFieldValue("description")); 470 470 assertEquals("Should be null not empty string", null, doc.getFieldValue("organisation")); … … 533 533 assertEquals(null, doc.getFieldValue("country")); 534 534 assertEquals(null, doc.getFieldValue("organisation")); 535 assertEquals(" Transcription", doc.getFieldValue("genre"));535 assertEquals("transcription", doc.getFieldValue("genre")); 536 536 // assertEquals("Kuna", doc.getFieldValue("subject")); 537 537 assertEquals(2, doc.getFieldValues("description").size());
Note: See TracChangeset
for help on using the changeset viewer.