hldata: comments + map->unordered_map
This commit is contained in:
parent
d3a9ce167f
commit
6a405e2089
@ -21,7 +21,7 @@
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
@ -29,6 +29,7 @@ using std::vector;
|
||||
using std::list;
|
||||
using std::pair;
|
||||
using std::set;
|
||||
using std::unordered_map;
|
||||
|
||||
#include "rcldb.h"
|
||||
#include "rclconfig.h"
|
||||
@ -123,8 +124,8 @@ private:
|
||||
const HighlightData& m_hdata;
|
||||
|
||||
// group/near terms word positions.
|
||||
map<string, vector<int> > m_plists;
|
||||
map<int, pair<int, int> > m_gpostobytes;
|
||||
unordered_map<string, vector<int> > m_plists;
|
||||
unordered_map<int, pair<int, int> > m_gpostobytes;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <deque>
|
||||
#include <algorithm>
|
||||
@ -270,8 +269,7 @@ public:
|
||||
|
||||
|
||||
// After the text is split: use the group terms positions lists to
|
||||
// find the group matches. We process everything as NEAR (no
|
||||
// PHRASE specific processing).
|
||||
// find the group matches.
|
||||
void updgroups() {
|
||||
LOGDEB("TextSplitABS: stored total " << m_fragments.size() <<
|
||||
" fragments" << endl);
|
||||
@ -361,8 +359,8 @@ private:
|
||||
// Group terms, extracted from m_hdata
|
||||
unordered_set<string> m_gterms;
|
||||
// group/near terms word positions.
|
||||
map<string, vector<int> > m_plists;
|
||||
map<int, pair<int, int> > m_gpostobytes;
|
||||
unordered_map<string, vector<int> > m_plists;
|
||||
unordered_map<int, pair<int, int> > m_gpostobytes;
|
||||
|
||||
// Input
|
||||
unordered_set<string> m_terms;
|
||||
|
||||
@ -81,9 +81,9 @@ public:
|
||||
// Data: source text (for display),
|
||||
string text1{"0 1 2 3 4"};
|
||||
// Positions produced by textsplit -d from the above
|
||||
map<string, vector<int> > plists1
|
||||
unordered_map<string, vector<int> > plists1
|
||||
{{"0", {0,}}, {"1", {1,}}, {"2", {2,}}, {"3", {3,}}, {"4", {4,}}, };
|
||||
map<int, pair<int,int>> gpostobytes1
|
||||
unordered_map<int, pair<int,int>> gpostobytes1
|
||||
{{0, {0, 1}}, {1, {2, 3}}, {2, {4, 5}}, {3, {6, 7}}, {4, {8, 9}}, };
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
/* Copyright (C) 2016 J.F.Dockes
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
/* Copyright (C) 2017-2019 J.F.Dockes
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* License: GPL 2.1
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
@ -25,7 +28,7 @@
|
||||
#include "smallut.h"
|
||||
|
||||
using std::string;
|
||||
using std::map;
|
||||
using std::unordered_map;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
|
||||
@ -169,8 +172,8 @@ static bool do_proximity_test(
|
||||
// Find matches for one group of terms
|
||||
bool matchGroup(const HighlightData& hldata,
|
||||
unsigned int grpidx,
|
||||
const map<string, vector<int>>& inplists,
|
||||
const map<int, pair<int,int>>& gpostobytes,
|
||||
const unordered_map<string, vector<int>>& inplists,
|
||||
const unordered_map<int, pair<int,int>>& gpostobytes,
|
||||
vector<GroupMatchEntry>& tboffs)
|
||||
{
|
||||
|
||||
|
||||
@ -1,10 +1,28 @@
|
||||
/* Copyright (C) 2017-2019 J.F.Dockes
|
||||
*
|
||||
* License: GPL 2.1
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef _hldata_h_included_
|
||||
#define _hldata_h_included_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
/** Store data about user search terms and their expansions. This is used
|
||||
@ -84,16 +102,17 @@ struct GroupMatchEntry {
|
||||
}
|
||||
};
|
||||
|
||||
// Find NEAR matches for one group of terms.
|
||||
// Find NEAR or PHRASE matches for one group of terms.
|
||||
//
|
||||
// @param hldata User query expansion descriptor (see above). We only use
|
||||
// the index_term_groups entry
|
||||
//
|
||||
// @param grpidx Index in hldata.index_term_groups for the group we
|
||||
// process. This is used by us to get the terms and slacks, and
|
||||
// set in the output GroupMatchEntry structures to allow the
|
||||
// caller to link a match with a specific user input (e.g. for
|
||||
// walking the match in the GUI preview)
|
||||
// process. This is used by us to get the terms, group type
|
||||
// (phrase/near) and slacks. We also set it in the output
|
||||
// GroupMatchEntry structures to allow the caller to link a match
|
||||
// with a specific user input (e.g. for walking the match in the
|
||||
// GUI preview)
|
||||
//
|
||||
// @param inplists Position lists for the the group terms. This is the
|
||||
// data used to look for matches.
|
||||
@ -108,8 +127,8 @@ struct GroupMatchEntry {
|
||||
extern bool matchGroup(
|
||||
const HighlightData& hldata,
|
||||
unsigned int grpidx,
|
||||
const std::map<std::string, std::vector<int>>& inplists,
|
||||
const std::map<int, std::pair<int,int>>& gpostobytes,
|
||||
const std::unordered_map<std::string, std::vector<int>>& inplists,
|
||||
const std::unordered_map<int, std::pair<int,int>>& gpostobytes,
|
||||
std::vector<GroupMatchEntry>& tboffs
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user