method of static class JsNgram
Description
Rebuild and sort the result of partial matches by document and position for reporting.
Example
JsNgram.sortFoundByDocumentPosition(found);
Usage
sortFoundByDocumentPosition(found);
Argument found is a result data used for N-gram matching.
The data should be the output of the method sortResultsByLocation
.
The output is compatible format with the method findPerfection
.
The input found format is:
{ document id: { N-gram key number: [position, position, position, ... ], N-gram key number: [position, position, position, ... ], N-gram key number: [position, position, position, ... ] }, document id: { N-gram key number: [position, position, position, ... ], N-gram key number: [position, position, position, ... ] } }
In above notation, N-gram key number is a sequence number of each N-gram key. For example, for searching "alice", following four N-gram keys are generated: "al", "li", "ic" and "ce" with the N-gram key number is 0, 1, 2 and 3, respectively.
The output format is:
{ document id: [ # list is sorted [position, matched N-gram key text], [position, matched N-gram key text], [position, matched N-gram key text] ], document id: [ # list is sorted [position, matched N-gram key text], [position, matched N-gram key text] ] }