Class kwicIS.KWIC
kwicIS.KWIC This is the class for the KWIC
The constructor
Defined in: kwicIS.js.
Constructor Attributes | Constructor Name and Description |
---|---|
kwicIS.KWIC(container)
|
Method Attributes | Method Name and Description |
---|---|
Returns the actual fields used in the item objects
|
|
cellTitle(theFun)
Sets the function to be used for the mouse hover title
|
|
colHeaderClick(theFun)
Sets the function to be called when the column header is clicked
|
|
contextLen(value)
Convenience Getter/setter when both contexts are the same length
|
|
data(input)
Getter/setter for the data for the KWIC
|
|
exclude_filter_function(field, val)
Convenience filter function factory for excluding items whose field is val
|
|
fieldDelim(value)
Getter/setter for the delimiter when the input is delimited strings
|
|
fieldNames(value)
Getter/setter for the field names when the input is delimited strings
|
|
filters(value)
Getter/setter for the filters
|
|
hitsByField(field)
Returns the number of hits for these (possibly filtered) results, aggregated by the given field
|
|
include_filter_function(field, val)
Convenience filter function factory for including items whose field is val
|
|
itemCellClick(theFun)
Sets the function to be called when an item cell is clicked
|
|
leftContextLen(value)
Getter/setter for the length of the left-hand context
|
|
numToShow(value)
Getter/setter for the number of results to show per page
|
|
rowString(theFun, onRight)
Sets the function to display a string for the row in an extra column, and whether the column is on the right or left end of the row.
|
|
rtContextLen(value)
Getter/setter for the length of the right-hand context
|
|
rtToLeft(value)
Getter/setter for the script is right to left
|
|
show()
Show the current page of results.
|
|
Show the first page of results
|
|
Show the last page of results
|
|
Show the next page of results
|
|
showPage(pageNum)
Show the given page of results
|
|
Show the previous page of results
|
|
sort(column, settings)
Sorts the data according to the given column and the relevant settings for field, direction, and order
|
|
textInfoToString(value)
Getter/setter for the toString function of TextInfor when the input is delimited strings
|
|
whichPage(value)
Getter/setter for the number of the current page of results
|
- Parameters:
- container
- is the html element that will contain the KWIC. An id can be used instead.
- Returns:
- a d3.set
- Parameters:
- theFun
- is a function(itemObject, i) and returns a string. i is the number in the current page
- Parameters:
- theFun
- is a function(headerContent, column)
- Parameters:
- value
- is an integer
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.
- Parameters:
- input
- is the data. It can be either:
an array of of arrays [leftContextsArray, hitsArray, rightContextsArray, indexArray], where the i-th elements of the arrays correspond and the contexts and hits are delimited strings (as defined by kwicIS.KWIC#fieldNames and kwicIS.KWIC#fieldDelim
or
an array of objects, where each object is of the form: {left: array of leftContexts, hits:element, right: array of rightContexts, index:element}, and all the elements of the contexts and the hits are themselves objects, typically with at least a "token" key.
If the input is delimited strings, they will be converted internally to #textmodel.TextInfo objects
If not specified, the current data is returned
- Parameters:
- field
- is the field to use
- val
- is the value to test
- Returns:
- a function(itemObject) which returns true if itemObject[field] !== val and false otherwise
- Parameters:
- value
- is a string
- Parameters:
- value
- is an array of strings — the field names
- Returns:
- just the ids of the data that satisfies the current filters
- Parameters:
- value
- is an object: {left: array of filter_functions, hit:filter_function, right: array of filter_functions.
A filter_function gets an info object and returns Boolean. The function at index i filters position i + 1 away from the root. Default is no filtering (via empty arrays).
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.
- Parameters:
- field
- is the field to use for the aggregation
- Returns:
- a hash of the results
- Returns:
- the number of hits for these (possibly filtered) results
- Parameters:
- field
- is the field to use
- val
- is the value to test
- Returns:
- a function(itemObject) which returns true if itemObject[field] === val and false otherwise
- Parameters:
- theFun
- is a function(itemObject, i). i is the number in the current page
- Parameters:
- value
- is an integer
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.
- Parameters:
- value
- is an integer
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.
- Parameters:
- theFun
- is a function(itemObjectArray, hitNumber) and returns a string
- onRight
- is boolean (not just truthy) for position of rowString — true is on the right and false is on the left. Default is on the right.
- Parameters:
- value
- is an integer
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.
- Parameters:
- value
- is a boolean: true means the script is written right to left
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.
- Parameters:
- pageNum
- is an integer. Page numbers are 1-based.
- Parameters:
- column
- the column to be sorted by
- settings
- optional object with keys:
- field: the field to use as the sort key
- sortFun: function(a,b) where a and be are the values of field and returns -1,0,1 according to whether a is less than, equal to, or greater than b. Default is a case insensitive lexicographic sort
- reverse: true if the order of sortFun should be reversed. Default is false.
- Parameters:
- value
- is a string
- Parameters:
- value
- is an integer
Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.