Return Type | Function name | Arguments |
---|---|---|
hzEcode | TokenizeFreetext | (hzVect<hzToken>&,hzChain&,) |
Declared and defined in file: hzTokens.cpp
Function Logic:
Function body:
hzEcode TokenizeFreetext (hzVect<hzToken>& toks, hzChain& C) { _hzfunc("TokenizeFreetext") ; hzChain raw ; chIter ci ; chIter ri ; hzToken T ; hzString word ; uint32_t ucVal ; uint32_t nPunct ; uint32_t nSymb ; uint32_t nDigit ; uint32_t nAlpha ; uint32_t nWeird ; uint32_t ucLen ; uint32_t nLine ; toks.Clear() ; if (!C.Size()) return E_NODATA ; ci = C ; ci.Line(1); for (; !ci.eof() ;) { if (!IsAlphanum(*ci)) { ci++ ; continue ; } raw.Clear() ; nPunct = nSymb = nDigit = nAlpha = nWeird = 0; nLine = ci.Line() ; for (; !ci.eof() && IsAlphanum(*ci) ;) { if (IsPunct(*ci)) { if (ci[1]<&eq; CHAR_SPACE) { ci++ ; break ; } nPunct++ ; raw.AddByte(*ci) ; ci++ ; continue ; } if (IsSymb(*ci)) { nSymb++ ; raw.AddByte(*ci) ; ci++ ; continue ; } if (IsDigit(*ci)) { nDigit++ ; raw.AddByte(*ci) ; ci++ ; continue ; } if (IsAlpha(*ci)) { nAlpha++ ; raw.AddByte(*ci) ; ci++ ; continue ; } if (AtUnicodeSeq(ucVal, ucLen, ci)) { if (ucVal > 255) { nWeird++ ; ci++ ; } else { raw.AddByte(ucVal & 0xff);ci+=ucLen ; } continue ; } raw.AddByte(*ci) ; } if (!raw.Size()) continue ; if (nAlpha) { if (!nDigit && !nPunct && !nSymb && !nWeird) { word = raw ; word.ToLower() ; T.Init(word, nLine, TOKEN_ALPHANUM) ; toks.Add(T) ; } } } return E_OK ; }