-
Notifications
You must be signed in to change notification settings - Fork 1
/
pick.c
71 lines (63 loc) · 2.83 KB
/
pick.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/************************************************************************
* *
* Program package 'lvq_pak': *
* *
* pick.c *
* -picks a given number of entries from list *
* *
* Version 3.0 *
* Date: 1 mar 1995 *
* *
* NOTE: This program package is copyrighted in the sense that it *
* may be used for scientific purposes. The package as a whole, or *
* parts thereof, cannot be included or used in any commercial *
* application without written permission granted by its producents. *
* No programs contained in this package may be copied for commercial *
* distribution. *
* *
* All comments concerning this program package may be sent to the *
* e-mail address 'lvq@cochlea.hut.fi'. *
* *
************************************************************************/
#include <stdio.h>
#include "lvq_pak.h"
#include "lvq_rout.h"
#include "datafile.h"
static char *usage[] = {
" pick - picks a given number of entries from list\n",
"Required parameters:\n",
" -din filename data file\n",
" -cout filename output codebook file\n",
" -noc integer number of codes to pick\n",
NULL};
int main(int argc, char **argv)
{
int num;
char *in_data_file;
char *out_code_file;
struct entries *data, *codes;
global_options(argc, argv);
if (extract_parameter(argc, argv, "-help", OPTION2))
{
printhelp();
exit(0);
}
in_data_file = extract_parameter(argc, argv, IN_DATA_FILE, ALWAYS);
out_code_file = extract_parameter(argc, argv, OUT_CODE_FILE, ALWAYS);
num = oatoi(extract_parameter(argc, argv, NUMBER_OF_CODES, ALWAYS), 1);
ifverbose(2)
fprintf(stderr, "Input entries are read from file %s\n", in_data_file);
if ((data = open_entries(in_data_file)) == NULL)
{
fprintf(stderr, "Can't open data file '%s' for reading\n", in_data_file);
exit(1);
}
codes = pick_codes(num, data);
close_entries(data);
ifverbose(2)
fprintf(stderr, "Codebook entries are saved to file %s\n", out_code_file);
save_entries(codes, out_code_file);
close_entries(codes);
invalidate_alphafile(out_code_file);
return(0);
}