SummerOfCode/2013/AutosuggestDocs

< SummerOfCode
Revision as of 21:06, 23 September 2013 by Sankha93 (talk | contribs) (Created page with "==Overview== Autosuggest Search Engine module tracks an form submission made by the user, and tries to infer from the user's activity whether the user has been trying to submi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

Autosuggest Search Engine module tracks an form submission made by the user, and tries to infer from the user's activity whether the user has been trying to submit a form that is possibly a search form.

To use it use the following module into your code:

Components.utils.import("resource://gre/modules/AutosuggestSearchEngine.jsm");

It tracks different fields in the forms, and its contents, frecency score of the website hosting the form and decides which is the most likely field to be a search field. Once it gets a postive hit, it fires a notification that can be tracked by an observer that can consume useful information from the notification, such as the form website, the most likely field.

It stores the temporary data collected from the forms in the autosuggestsearch-history.json file in the user profile directory.

Using Autosuggest Search Engine

Method Overview

  • init

init

Initialize the Autosuggest Search Engine module.

void init();

Storage Handler

Storage Handler handles the storage part of the module and save the data in the storage section in the profile directory in a flat JSON file autosuggestsearch-history.json.

It can be accessed via:

AutosuggestSearchEngine.storageHandler

It provides the following methods:

  • createNew
  • getForm
  • updateForm
  • saveData

createNew

Creates a new entry in case the URI is not present in storage already.

void createNew(actionURL);
  • actionURL: The URL whose entry is to be created.

getForm

Helper method to get the number of submission for an URI. The returned data looks like:

{ submissionCount: Number of submissions,
  mostLikelyField: most likely field in the form,
  formScore: the score of the form
}
Object getForm(actionURL)
  • actionURL: The URL whose form data is to be returned.