Changeset 6082


Ignore:
Timestamp:
2003-12-02T16:08:56+13:00 (20 years ago)
Author:
kjdon
Message:

added in NEAR to inside []

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/indexers/mgpp/text/GSDLQueryParser.cpp

    r5449 r6082  
    217217// expects starting brackets to have been parsed
    218218// sets error to true if something has gone wrong
    219 static void ParseSquareBrackets(UCArray::const_iterator &here,
     219static ProxMatchQueryNode *ParseSquareBrackets(UCArray::const_iterator &here,
    220220                UCArray::const_iterator end,
    221                 ProxMatchQueryNode *proxNode,
     221                /*ProxMatchQueryNode *proxNode,*/
    222222                int defaultStemMethod,
    223223                bool & error) {
    224224
     225  ProxMatchQueryNode *proxNode = new ProxMatchQueryNode;
    225226  LexEl el;
    226227  bool phrase=false;
    227228  bool first=true;
     229  bool near = false;
     230  UCArray near_string;
    228231  while (ParseLexEl (here, end, el)) {
    229232    if (el.lexType == TermE || el.lexType == IntegerE) {
     
    237240          termNode.endRange = -1;
    238241        }
    239       } 
     242      } else if (near) {
     243    SetRangeValues(termNode, near_string);
     244    near = false;
     245      }
    240246      proxNode->terms.push_back(termNode);
    241247    }
     
    245251    else if (el.lexType == QuoteE) {
    246252      // phrase inside square brackets
    247       if (phrase) phrase=false;
    248       else phrase=true;
    249     } else if (el.lexType == UnknownE) {
     253      if (phrase) { // end of phrase
     254    phrase=false;
     255    first = true;
     256      } else {
     257    phrase=true; // start of phrase
     258      }
     259    } else if (el.lexType == NearOpE) {
     260      if (phrase) {
     261    // cant have NEAR op in a phrase - just assume its an actual word
     262    TermNode termNode;
     263    termNode.term = el.text;
     264    ParseTermModifiers (here, end, termNode, defaultStemMethod);
     265    proxNode->terms.push_back(termNode);
     266      } else {
     267    // its a NEAR op
     268    near = true;
     269    near_string = el.text;
     270      }
     271     
     272    }
     273    else if (el.lexType == UnknownE) {
    250274      // just ignore it
    251275    }
     
    254278      cerr <<"GSDLQueryParser: bad syntax inside []\n";
    255279      error = true;
    256       return;
     280      return NULL;
    257281    }
    258282  } // while
    259 
     283  return proxNode;
    260284}
    261285// expects the starting quote to have been parsed
     
    354378  else if (el.lexType == OpenSquareBracketE) {
    355379    bool error = false;
    356     ParseSquareBrackets (here, end, proxNode, defaultStemMethod, error);
     380    proxNode = ParseSquareBrackets (here, end, /*proxNode, */defaultStemMethod, error);
    357381    if (error) {
    358382      delete proxNode;
  • trunk/mgpp/text/GSDLQueryParser.cpp

    r5449 r6082  
    217217// expects starting brackets to have been parsed
    218218// sets error to true if something has gone wrong
    219 static void ParseSquareBrackets(UCArray::const_iterator &here,
     219static ProxMatchQueryNode *ParseSquareBrackets(UCArray::const_iterator &here,
    220220                UCArray::const_iterator end,
    221                 ProxMatchQueryNode *proxNode,
     221                /*ProxMatchQueryNode *proxNode,*/
    222222                int defaultStemMethod,
    223223                bool & error) {
    224224
     225  ProxMatchQueryNode *proxNode = new ProxMatchQueryNode;
    225226  LexEl el;
    226227  bool phrase=false;
    227228  bool first=true;
     229  bool near = false;
     230  UCArray near_string;
    228231  while (ParseLexEl (here, end, el)) {
    229232    if (el.lexType == TermE || el.lexType == IntegerE) {
     
    237240          termNode.endRange = -1;
    238241        }
    239       } 
     242      } else if (near) {
     243    SetRangeValues(termNode, near_string);
     244    near = false;
     245      }
    240246      proxNode->terms.push_back(termNode);
    241247    }
     
    245251    else if (el.lexType == QuoteE) {
    246252      // phrase inside square brackets
    247       if (phrase) phrase=false;
    248       else phrase=true;
    249     } else if (el.lexType == UnknownE) {
     253      if (phrase) { // end of phrase
     254    phrase=false;
     255    first = true;
     256      } else {
     257    phrase=true; // start of phrase
     258      }
     259    } else if (el.lexType == NearOpE) {
     260      if (phrase) {
     261    // cant have NEAR op in a phrase - just assume its an actual word
     262    TermNode termNode;
     263    termNode.term = el.text;
     264    ParseTermModifiers (here, end, termNode, defaultStemMethod);
     265    proxNode->terms.push_back(termNode);
     266      } else {
     267    // its a NEAR op
     268    near = true;
     269    near_string = el.text;
     270      }
     271     
     272    }
     273    else if (el.lexType == UnknownE) {
    250274      // just ignore it
    251275    }
     
    254278      cerr <<"GSDLQueryParser: bad syntax inside []\n";
    255279      error = true;
    256       return;
     280      return NULL;
    257281    }
    258282  } // while
    259 
     283  return proxNode;
    260284}
    261285// expects the starting quote to have been parsed
     
    354378  else if (el.lexType == OpenSquareBracketE) {
    355379    bool error = false;
    356     ParseSquareBrackets (here, end, proxNode, defaultStemMethod, error);
     380    proxNode = ParseSquareBrackets (here, end, /*proxNode, */defaultStemMethod, error);
    357381    if (error) {
    358382      delete proxNode;
Note: See TracChangeset for help on using the changeset viewer.