+ else if (lex_match_id (lexer, "CRITERIA"))
+ {
+ lex_match (lexer, T_EQUALS);
+ while (lex_token (lexer) != T_ENDCMD
+ && lex_token (lexer) != T_SLASH)
+ {
+ if (lex_match_id (lexer, "CLUSTERS"))
+ {
+ if (!lex_force_match (lexer, T_LPAREN)
+ || !lex_force_int_range (lexer, "CLUSTERS", 1, INT_MAX))
+ return false;
+ qc->ngroups = lex_integer (lexer);
+ lex_get (lexer);
+ if (!lex_force_match (lexer, T_RPAREN))
+ return false;
+ }
+ else if (lex_match_id (lexer, "CONVERGE"))
+ {
+ if (!lex_force_match (lexer, T_LPAREN)
+ || !lex_force_num_range_open (lexer, "CONVERGE",
+ 0, DBL_MAX))
+ return false;
+ qc->epsilon = lex_number (lexer);
+ lex_get (lexer);
+ if (!lex_force_match (lexer, T_RPAREN))
+ return false;
+ }
+ else if (lex_match_id (lexer, "MXITER"))
+ {
+ if (!lex_force_match (lexer, T_LPAREN)
+ || !lex_force_int_range (lexer, "MXITER", 1, INT_MAX))
+ return false;
+ qc->maxiter = lex_integer (lexer);
+ lex_get (lexer);
+ if (!lex_force_match (lexer, T_RPAREN))
+ return false;
+ }
+ else if (lex_match_id (lexer, "NOINITIAL"))
+ qc->initial = false;
+ else if (lex_match_id (lexer, "NOUPDATE"))
+ qc->update = false;
+ else
+ {
+ lex_error_expecting (lexer, "CLUSTERS", "CONVERGE", "MXITER",
+ "NOINITIAL", "NOUPDATE");
+ return false;
+ }
+ }
+ }
+ else
+ {
+ lex_error_expecting (lexer, "MISSING", "PRINT", "SAVE", "CRITERIA");
+ return false;
+ }
+ }
+ return true;
+}
+
+int
+cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
+{
+ struct qc qc = {
+ .dataset = ds,
+ .dict = dataset_dict (ds),
+ .ngroups = 2,
+ .maxiter = 10,
+ .epsilon = DBL_EPSILON,
+ .missing_type = MISS_LISTWISE,
+ .exclude = MV_ANY,
+ .initial = true,
+ .update = true,
+ };
+
+ if (!quick_cluster_parse (lexer, &qc))
+ goto error;
+
+ qc.wv = dict_get_weight (qc.dict);
+
+ struct casegrouper *grouper = casegrouper_create_splits (proc_open (ds), qc.dict);
+ struct casereader *group;
+ while (casegrouper_get_next_group (grouper, &group))
+ {
+ if (qc.missing_type == MISS_LISTWISE)
+ group = casereader_create_filter_missing (group, qc.vars, qc.n_vars,
+ qc.exclude, NULL, NULL);
+
+ struct Kmeans *kmeans = kmeans_create (&qc);
+ kmeans_cluster (kmeans, group, &qc);
+ quick_cluster_show_results (kmeans, group, &qc);
+ kmeans_destroy (kmeans);
+ casereader_destroy (group);