Class Index | File Index

Classes


Class kwicIS.KWIC

kwicIS.KWIC This is the class for the KWIC

The constructor
Defined in: kwicIS.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
kwicIS.KWIC(container)
Method Summary
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
 
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
 
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
 
 
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
 
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
 
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
Class Detail
kwicIS.KWIC(container)
Parameters:
container
is the html element that will contain the KWIC. An id can be used instead.
Method Detail
actualFields()
Returns the actual fields used in the item objects
Returns:
a d3.set

cellTitle(theFun)
Sets the function to be used for the mouse hover title
Parameters:
theFun
is a function(itemObject, i) and returns a string. i is the number in the current page

colHeaderClick(theFun)
Sets the function to be called when the column header is clicked
Parameters:
theFun
is a function(headerContent, column)

contextLen(value)
Convenience Getter/setter when both contexts are the same length
Parameters:
value
is an integer

Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.


data(input)
Getter/setter for the data for the KWIC
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


exclude_filter_function(field, val)
Convenience filter function factory for excluding items whose field is val
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

fieldDelim(value)
Getter/setter for the delimiter when the input is delimited strings
Parameters:
value
is a string

fieldNames(value)
Getter/setter for the field names when the input is delimited strings
Parameters:
value
is an array of strings — the field names

filteredIDs()
Returns:
just the ids of the data that satisfies the current filters

filters(value)
Getter/setter for the 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.


hitsByField(field)
Returns the number of hits for these (possibly filtered) results, aggregated by the given field
Parameters:
field
is the field to use for the aggregation
Returns:
a hash of the results

hitsCount()
Returns:
the number of hits for these (possibly filtered) results

include_filter_function(field, val)
Convenience filter function factory for including items whose field is val
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

itemCellClick(theFun)
Sets the function to be called when an item cell is clicked
Parameters:
theFun
is a function(itemObject, i). i is the number in the current page

leftContextLen(value)
Getter/setter for the length of the left-hand context
Parameters:
value
is an integer

Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.


numToShow(value)
Getter/setter for the number of results to show per page
Parameters:
value
is an integer

Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.


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. Default is no extra string.
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.

rtContextLen(value)
Getter/setter for the length of the right-hand context
Parameters:
value
is an integer

Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.


rtToLeft(value)
Getter/setter for the script is right to left
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.


show()
Show the current page of results. This is the function that does the work of showing the KWIC.

showFirstPage()
Show the first page of results

showLastPage()
Show the last page of results

showNextPage()
Show the next page of results

showPage(pageNum)
Show the given page of results
Parameters:
pageNum
is an integer. Page numbers are 1-based.

showPrevPage()
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
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.

textInfoToString(value)
Getter/setter for the toString function of TextInfor when the input is delimited strings
Parameters:
value
is a string

whichPage(value)
Getter/setter for the number of the current page of results
Parameters:
value
is an integer

Note: this does not redraw the KWIC. Use kwicIS.KWIC#show for that.


Documentation generated by JsDoc Toolkit 2.4.0 on Sun Sep 24 2017 15:56:41 GMT-0500 (CDT)