1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include <data/procedure.h>
21 #include <language/lexer/variable-parser.h>
22 #include <language/lexer/value-parser.h>
23 #include <language/lexer/lexer.h>
26 #define _(msgid) gettext (msgid)
27 #define N_(msgid) msgid
32 const struct variable **vars;
34 struct variable *state_var ;
35 union value state_value;
37 /* Plot the roc curve */
39 /* Plot the reference line */
46 bool bi_neg_exp; /* True iff the bi-negative exponential critieria
48 enum mv_class exclude;
50 bool invert ; /* True iff a smaller test result variable indicates
57 cmd_roc (struct lexer *lexer, struct dataset *ds)
60 const struct dictionary *dict = dataset_dict (ds);
65 roc.print_coords = false;
68 roc.reference = false;
70 roc.bi_neg_exp = false;
73 if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars,
74 PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC))
77 if ( ! lex_force_match (lexer, T_BY))
82 roc.state_var = parse_variable (lexer, dict);
84 if ( !lex_force_match (lexer, '('))
89 parse_value (lexer, &roc.state_value, var_get_width (roc.state_var));
92 if ( !lex_force_match (lexer, ')'))
98 while (lex_token (lexer) != '.')
100 lex_match (lexer, '/');
101 if (lex_match_id (lexer, "MISSING"))
103 lex_match (lexer, '=');
104 while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
106 if (lex_match_id (lexer, "INCLUDE"))
108 roc.exclude = MV_SYSTEM;
110 else if (lex_match_id (lexer, "EXCLUDE"))
112 roc.exclude = MV_ANY;
116 lex_error (lexer, NULL);
121 else if (lex_match_id (lexer, "PLOT"))
123 lex_match (lexer, '=');
124 if (lex_match_id (lexer, "CURVE"))
127 if (lex_match (lexer, '('))
129 roc.reference = true;
130 lex_force_match_id (lexer, "REFERENCE");
131 lex_force_match (lexer, ')');
134 else if (lex_match_id (lexer, "NONE"))
140 lex_error (lexer, NULL);
144 else if (lex_match_id (lexer, "PRINT"))
146 lex_match (lexer, '=');
147 while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
149 if (lex_match_id (lexer, "SE"))
153 else if (lex_match_id (lexer, "COORDINATES"))
155 roc.print_coords = true;
159 lex_error (lexer, NULL);
164 else if (lex_match_id (lexer, "CRITERIA"))
166 lex_match (lexer, '=');
167 while (lex_token (lexer) != '.' && lex_token (lexer) != '/')
169 if (lex_match_id (lexer, "CUTOFF"))
171 lex_force_match (lexer, '(');
172 if (lex_match_id (lexer, "INCLUDE"))
174 roc.exclude = MV_SYSTEM;
176 else if (lex_match_id (lexer, "EXCLUDE"))
178 roc.exclude = MV_USER | MV_SYSTEM;
182 lex_error (lexer, NULL);
185 lex_force_match (lexer, ')');
187 else if (lex_match_id (lexer, "TESTPOS"))
189 lex_force_match (lexer, '(');
190 if (lex_match_id (lexer, "LARGE"))
194 else if (lex_match_id (lexer, "SMALL"))
200 lex_error (lexer, NULL);
203 lex_force_match (lexer, ')');
205 else if (lex_match_id (lexer, "CI"))
207 lex_force_match (lexer, '(');
208 lex_force_num (lexer);
209 roc.ci = lex_number (lexer);
211 lex_force_match (lexer, ')');
213 else if (lex_match_id (lexer, "DISTRIBUTION"))
215 lex_force_match (lexer, '(');
216 if (lex_match_id (lexer, "FREE"))
218 roc.bi_neg_exp = false;
220 else if (lex_match_id (lexer, "NEGEXPO"))
222 roc.bi_neg_exp = true;
226 lex_error (lexer, NULL);
229 lex_force_match (lexer, ')');
233 lex_error (lexer, NULL);
240 lex_error (lexer, NULL);