dca_interface  6.3.4
dca::UrlClassification Class Reference

#include <url_classification.h>

Detailed Description

Main class for the URL classification.

See also
UrlDbClassifier
// 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 109 of file url_classification.h.

Public Member Functions

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. The DbClassifier is automatically connected to the database via the DbConnection after successful initialization. More...
 
LogLevel setLogLevel (LogLevel newLevel)
 Sets the logging level for the given class instance. The old value will be returned. More...
 

Static Public Member Functions

static UrlClassification create (const DcaInstance &aDcaInstance, const License &aLicense)
 Creates the URL classification module by using the given DcaInstance and License. More...
 

Static Public Attributes

static DCA_MODULE_ID_TYPE ID
 The unique ID of the URL classification module.
 

Member Function Documentation

◆ create()

static UrlClassification dca::UrlClassification::create ( const DcaInstance aDcaInstance,
const License aLicense 
)
static

Creates the URL classification module by using the given DcaInstance and License.

This is the package creation function.

Before using any other functions of the URL classification package, a UrlClassification instance must be created by sumitting a valid DcaInstance and License.

Parameters
[in]aDcaInstanceA previously initialized DcaInstance object
[in]aLicenseAn initialized License object
Returns
An initialized UrlClassification instance.
Exceptions
ExDcaOne of the following error codes (available by using ExDca::getReturnCode() in your catch-handler)

◆ createDbClassifier()

UrlDbClassifier dca::UrlClassification::createDbClassifier ( const DbConnection aDbConnection,
const UrlDbClassifierOptions options = UrlDbClassifierOptions() 
) const

Create a URL database classifier. The classifier is created by using the provided database connection. The DbClassifier is automatically connected to the database via the DbConnection after successful initialization.

Parameters
[in]aDbConnectionThe database connection to be used for classification
[in]optionsThe Options that define several aspects on how embedded URLs should be handled, and whether or not WebLearn should be enabled. This paramter is optional.
Returns
A UrlDbClassifier that is associated with the specified db connection, using the specified options (if any).
Exceptions
ExDcaOne of the following error codes (available by using ExDca::getReturnCode() in your catch-handler)

◆ setLogLevel()

LogLevel dca::UrlClassification::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...