dca_interface  6.3.4
dca::UrlDbClassifier Class Reference

#include <urldb_classifier.h>

Detailed Description

URL database classifier class.

The classify function takes a given URL object and returns the database classification result.

This can be either

  • unknown (the URL is not in the database)
  • known but not categorised (result is empty)
  • known and has associated categories
See also
UrlClassification::createDbClassifier, UrlClassification, UrlClassificationResults,
// assume we have a valid DcaInstance (myDca), License (myLicense) and DbConnection (myDbConnection)
// initialize the URL Classification module
dca::UrlClassification myUrlClassification =
dca::UrlClassification::create( myDca, myLicense );
UrlDbClassifierOptions creationOptions;
// enable Feedback mechanism
creationOptions.enable_Feedback = true;
// enable detection of embedded URLs
creationOptions.enable_EmbeddedUrlDetection = true;
// create a UrlDbClassifier by using creationOptions
dca::UrlDbClassifier myUrlDbClassifier =
myUrlClassification.createDbClassifier( myDbConnection, creationOptions );
// create a URL object to classify
dca::Url myUrl = dca::Url::create( myDca, "www.ibm.com" );
// declare the classification results
dca::UrlClassificationResults myUrlClassificationResults;
// start URL Classification
myUrlDbClassifier.classify( myUrl, myUrlClassificationResults );
// if myResult returns false an error occurred.
if( !myResult ) {
cout << "Received an error from URL Classification (Error code:" <<
myResult.getReturnCode() << ", Description: " <<
myResult.getDescription() << ")." << endl;
return;
}
if( myUrlClassificationResults.isUnknownUrl() ) {
// if the given URL is unknown there are no resulting categories available
cout << "Received no results, URL is unknown." << endl;
return;
}
if( !myUrlClassificationResults.isCategorized() ) {
// given URL (or host) is KNOWN, but does not have any categories assigned
cout << "URL is known but has no assigned categories." << endl;
return;
}
// we got results and want to print them out
PrintResults( myUrlClassificationResults );

Definition at line 39 of file urldb_classifier.h.

Public Member Functions

FunctionResult classify (const Url &aUrl, UrlClassificationResults &urlResults) const
 Performs the URL classification and returns the results. More...
 
LogLevel setLogLevel (LogLevel newLevel)
 Sets the logging level for the given class instance. The old value will be returned. More...
 

Member Function Documentation

◆ classify()

FunctionResult dca::UrlDbClassifier::classify ( const Url aUrl,
UrlClassificationResults urlResults 
) const

Performs the URL classification and returns the results.

Parameters
[in]aUrlA URL object created by using Url::create()
[out]urlResultsThe classification results, containing all matched categories (if any)
Returns
DCA_SUCCESS or one of the following error codes

◆ setLogLevel()

LogLevel dca::UrlDbClassifier::setLogLevel ( LogLevel  newLevel)

Sets the logging level for the given class instance. The old value will be returned.

Usually the logging level is set to LOG_Notice.

Parameters
[in]newLevelThe new LogLevel the class instance should use for logging
Returns
The old used logging level.

The documentation for this class was generated from the following file:
bool isCategorized() const
Returns whether or not the URL matched one or more categories.
static Url create(const DcaInstance &aDcaInstance, const std::string &urlString)
Standard Url creation function.
DCA_RESULT_TYPE getReturnCode() const
Returns the last error code (if any).
FunctionResult classify(const Url &aUrl, UrlClassificationResults &urlResults) const
Performs the URL classification and returns the results.
bool isUnknownUrl() const
Returns whether a URL is known or unknown. A URL is unknown if it is not contained in the database.
Main class for the URL classification.
Results of an URL classification.
URL database classifier class.
static UrlClassification create(const DcaInstance &aDcaInstance, const License &aLicense)
Creates the URL classification module by using the given DcaInstance and License.
std::string getDescription() const
Returns the description for the error or warning.
Standard function result.
Definition: base_classes.h:148
Encapsulates a URL object.
Definition: base_url.h:44
UrlDbClassifier createDbClassifier(const DbConnection &aDbConnection, const UrlDbClassifierOptions &options=UrlDbClassifierOptions()) const
Create a URL database classifier. The classifier is created by using the provided database connection...