1AI::Categorizer::KnowleUdsgeerSeCto(n3tprmi)buted Perl DAoIc:u:mCeantteagtoiroinzer::KnowledgeSet(3pm)
2
3
4
6 AI::Categorizer::KnowledgeSet - Encapsulates set of documents
7
9 use AI::Categorizer::KnowledgeSet;
10 my $k = new AI::Categorizer::KnowledgeSet(...parameters...);
11 my $nb = new AI::Categorizer::Learner::NaiveBayes(...parameters...);
12 $nb->train(knowledge_set => $k);
13
15 The KnowledgeSet class that provides an interface to a set of
16 documents, a set of categories, and a mapping between the two. Many
17 parameters for controlling the processing of documents are managed by
18 the KnowledgeSet class.
19
21 new()
22 Creates a new KnowledgeSet and returns it. Accepts the following
23 parameters:
24
25 load
26 If a "load" parameter is present, the load() method will be
27 invoked immediately. If the "load" parameter is a string, it
28 will be passed as the "path" parameter to load(). If the
29 "load" parameter is a hash reference, it will represent all the
30 parameters to pass to load().
31
32 categories
33 An optional reference to an array of Category objects
34 representing the complete set of categories in a KnowledgeSet.
35 If used, the "documents" parameter should also be specified.
36
37 documents
38 An optional reference to an array of Document objects
39 representing the complete set of documents in a KnowledgeSet.
40 If used, the "categories" parameter should also be specified.
41
42 features_kept
43 A number indicating how many features (words) should be
44 considered when training the Learner or categorizing new
45 documents. May be specified as a positive integer (e.g. 2000)
46 indicating the absolute number of features to be kept, or as a
47 decimal between 0 and 1 (e.g. 0.2) indicating the fraction of
48 the total number of features to be kept, or as 0 to indicate
49 that no feature selection should be done and that the entire
50 set of features should be used. The default is 0.2.
51
52 feature_selection
53 A string indicating the type of feature selection that should
54 be performed. Currently the only option is also the default
55 option: "document_frequency".
56
57 tfidf_weighting
58 Specifies how document word counts should be converted to
59 vector values. Uses the three-character specification strings
60 from Salton & Buckley's paper "Term-weighting approaches in
61 automatic text retrieval". The three characters indicate the
62 three factors that will be multiplied for each feature to find
63 the final vector value for that feature. The default weighting
64 is "xxx".
65
66 The first character specifies the "term frequency" component,
67 which can take the following values:
68
69 b Binary weighting - 1 for terms present in a document, 0 for
70 terms absent.
71
72 t Raw term frequency - equal to the number of times a feature
73 occurs in the document.
74
75 x A synonym for 't'.
76
77 n Normalized term frequency - 0.5 + 0.5 * t/max(t). This is
78 the same as the 't' specification