LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
hasheddb.h
Go to the documentation of this file.
1// Copyright 2002-2013 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
11#ifndef HASHEDDB_H
12#define HASHEDDB_H
13
15#include <vector>
16#include <string>
17#include <stdio.h>
18#include <string.h>
19#include "lshsignature.h"
20
21
22namespace Lima
23{
24namespace LinguisticProcessing
25{
26namespace WordSenseDisambiguation
27{
28
29
30typedef struct
31{
32 int index;
33 int count;
35
37 vectorCount j );
38
40 private:
41 int signatureLength;
42 int nSignatures;
43 int *nbZero;
44 std::vector<LSHSignature> signatures;
45 class comparePermutedSignatures
46 {
47 std::vector<int> *myPermutations;
48 HashedDB * hashedDb;
49 public:
50 comparePermutedSignatures ( std::vector <int> &permutations,
51 HashedDB & _hashedDb )
52 {
53 myPermutations = &permutations ;
54 hashedDb = &_hashedDb;
55 }
56 bool operator () ( int i, int j )
57 {
58 return ( hashedDb->signatures[i].comparePermutedBits (
59 hashedDb->signatures[j],*myPermutations ) );
60 }
61 };
62
63public:
64 HashedDB();
65 HashedDB(int _signatureLength, int _nSignatures);
66 HashedDB(std::string dbFileName);
67
68 ~HashedDB();
69 std::vector<int> & fastKNNSearch1 (std::vector<int>& permutations,
70 int beam);
71 void append(LSHSignature & s);
72 void removeLast();
73 void insert(int ind, LSHSignature & s);
74 void writeToFile(std::string fileName, int rank, int nproc);
75 LSHSignature & getSignature(int key) { return signatures.at(key); }
76 void xorX(LSHSignature & s);
77 int getNSignatures() { return nSignatures; }
78 void setNSignatures(int n ) { nSignatures = n; }
79 void incrNSignatures() { nSignatures++; }
80 void decrNSignatures() { nSignatures--; }
81 int getSignatureLength() { return signatureLength; }
82 void printStats();
83};
84
85}
86}
87}
88
89#endif
#define LIMA_WORDSENSEANALYSIS_EXPORT
void writeToFile(std::string fileName, int rank, int nproc)
bool vectorCountCompare(vectorCount i, vectorCount j)
Definition hasheddb.cpp:38
NAUTITIA.