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