Changeset 2179 for SRUCQIBridge
- Timestamp:
- 08/30/12 13:12:47 (12 years ago)
- Location:
- SRUCQIBridge
- Files:
-
- 3 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUCQIBridge/pom.xml
r2105 r2179 18 18 <artifactId>sru-server</artifactId> 19 19 <version>0.6.0-SNAPSHOT</version> 20 </dependency> 21 <dependency> 22 <groupId>eu.clarin.cqi</groupId> 23 <artifactId>cqi-client</artifactId> 24 <version>1.0-SNAPSHOT</version> 20 25 </dependency> 21 26 </dependencies> -
SRUCQIBridge/src/main/java/eu/clarin/sru/cqibridge/CqiSRUSearchEngine.java
r2105 r2179 16 16 package eu.clarin.sru.cqibridge; 17 17 18 import eu.clarin.cqi.client.CqiClient; 19 import eu.clarin.cqi.client.CqiClientException; 20 import eu.clarin.cqi.client.CqiResult; 18 21 import eu.clarin.sru.server.*; 19 22 import eu.clarin.sru.server.utils.SRUSearchEngineBase; … … 55 58 private static final Pattern SPACE_PATTERN = Pattern.compile("\\s+"); 56 59 private static final String WORD_POSITIONAL_ATTRIBUTE = "word"; 60 private static final String CONTEXT_STRUCTURAL_ATTRIBUTE = "s"; 57 61 private static final Logger logger = 58 62 LoggerFactory.getLogger(CqiSRUSearchEngine.class); … … 158 162 new Object[]{cqpQuery, startRecord, maximumRecords}); 159 163 try { 160 final CqiResult result = client. cqpQuery(defaultCorpusName, cqpQuery);161 if ( !result.absolute(startRecord)) {164 final CqiResult result = client.query(defaultCorpusName, cqpQuery, CONTEXT_STRUCTURAL_ATTRIBUTE); 165 if ((result.size() > 0 && !result.absolute(startRecord)) || (result.size() == 0 && startRecord > 0)) { 162 166 diagnostics.addDiagnostic(SRUConstants.SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE, Integer.toString(startRecord + 1), null); 163 167 } … … 204 208 public void writeRecord(XMLStreamWriter writer) 205 209 throws XMLStreamException { 206 final CqiResult.Range context; 207 try { 208 context = result.getRange(CqiResult.Field.CONTEXT); 209 } catch (CqiClientException e) { 210 throw new XMLStreamException("can't obtain the context range", e); 211 } 212 final CqiResult.Range match; 213 try { 214 match = result.getRange(CqiResult.Field.MATCH); 215 } catch (CqiClientException e) { 216 throw new XMLStreamException("can't obtain the match range", e); 217 } 218 int matchStart = match.getStart() - context.getStart(); 219 int matchEnd = match.getEnd() - context.getStart() + 1; 220 int contextEnd = context.getEnd() - context.getStart() + 1; 210 final int contextStart = result.getContextStart(); 211 final int contextEnd = result.getContextEnd(); 212 final int matchStart = result.getMatchStart(); 213 final int matchEnd = result.getMatchEnd(); 214 final int relMatchStart = matchStart - contextStart; 215 final int relMatchEnd = matchEnd - contextStart + 1; 216 final int relContextEnd = contextEnd - contextStart + 1; 221 217 final StringBuilder leftContext = new StringBuilder(); 222 218 final StringBuilder keyWord = new StringBuilder(); … … 224 220 String[] words; 225 221 try { 226 words = context.getValues(WORD_POSITIONAL_ATTRIBUTE);222 words = result.getValues(WORD_POSITIONAL_ATTRIBUTE, contextStart, contextEnd); 227 223 } catch (CqiClientException e) { 228 224 throw new XMLStreamException("can't obtain the values of the positional attribute '" + WORD_POSITIONAL_ATTRIBUTE + "'", e); 229 225 } 230 226 boolean isFirst = true; 231 for (int i = 0; i < matchStart; i++) {227 for (int i = 0; i < relMatchStart; i++) { 232 228 if (isFirst) { 233 229 isFirst = false; … … 238 234 } 239 235 isFirst = true; 240 for (int i = matchStart; i < matchEnd; i++) {236 for (int i = relMatchStart; i < relMatchEnd; i++) { 241 237 if (isFirst) { 242 238 isFirst = false; … … 247 243 } 248 244 isFirst = true; 249 for (int i = matchEnd; i < contextEnd; i++) {245 for (int i = relMatchEnd; i < relContextEnd; i++) { 250 246 if (isFirst) { 251 247 isFirst = false; -
SRUCQIBridge/src/main/webapp/META-INF/context.xml
r2105 r2179 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <Context antiJARLocking="true" path="/ SRUCQIBridge"/>2 <Context antiJARLocking="true" path="/sru"/>
Note: See TracChangeset
for help on using the changeset viewer.