-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsimilarity_binary.c
57 lines (49 loc) · 1.79 KB
/
similarity_binary.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Copyright (c) 2019-present, All rights reserved.
* Written by Julien Tissier <30314448+tca19@users.noreply.github.com>
*
* This file is part of the "Near-lossless Binarization of Word Embeddings"
* software (https://github.com/tca19/near-lossless-binarization).
*
* 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 3 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 General Public License at the root of this repository for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <time.h>
#include "utils.h"
#define DATADIR "datasets/"
int main(int argc, char *argv[])
{
int n_bits, n_long; /* #bits per vector, #long per array */
long n_vecs; /* #vectors in embedding file */
unsigned long **embedding;
clock_t start, end;
if (argc != 2)
{
printf("usage: ./similarity_binary EMBEDDING\n");
return 1;
}
start = clock();
create_vocab(DATADIR);
end = clock();
printf("create_vocab(): %fs\n", (double) (end-start) / CLOCKS_PER_SEC);
start = clock();
embedding = load_vectors(*++argv, &n_vecs, &n_bits, &n_long, 0);
end = clock();
printf("load_vectors(): %fs\n", (double) (end-start) / CLOCKS_PER_SEC);
start = clock();
evaluate(DATADIR, (void**) embedding, n_long, binary_sim);
end = clock();
printf("evaluate(): %fs\n", (double) (end-start) / CLOCKS_PER_SEC);
return 0;
}