initRangeSlider

Function to initialize the slider for the min max sliders

initRangeSlider(range: Object, min: number, max: number, initValues: Array<int>)
Parameters
range (Object) is the div html object where slider should appear
min (number) is the minimal slider value
max (number) is the maximal slider value
initValues (Array<int>) contains the initial min and max value of the slider handles

normalize

This function maps a value of an interval between 0 and 1

normalize(val: number, min: number, max: number): number
Parameters
val (number) is the value to map
min (number) is the minimal interval boundary
max (number) is the maximal interval boundary
Returns
number: a value between 0 and 1

checkSentenceStructure

This function checks the complexity of the structure of the given sentence and returns a complexity ratiing. The complexity of a sentence is based on the number of occured splitting words normalzed by the sentence length.

checkSentenceStructure(sentence: string): number
Parameters
sentence (string) the sentence of which to calculate the complexity ratio
Returns
number: a rating between 0 and 1

checkSentenceStructure

This function calculates a normalized rating based of a sentence length the used measurement is based on a study https://strainindex.wordpress.com/2008/07/28/the-average-sentence-length/

checkSentenceStructure(sentence: any, sentenceLenth: number): number
Parameters
sentence (any)
sentenceLenth (number) the length of the sentence to get a rating from
Returns
number: a rating between 0 and 1

analyzeSentence

This function calculates the different readability factors of a single sentence

analyzeSentence(sentence: string): Object
Parameters
sentence (string) the sentence of which to calculate the readability ratios.
Returns
Object: the different measurements how difficult the given sentence is. 0 means very easy, 1 means very difficult.

analyzePageAverageReadability

calculates the average readability of a page

analyzePageAverageReadability(page: Object)
Parameters
page (Object)

pdfFinishedGettingSentences

PDF Import

pdfFinishedGettingSentences(pdf: any)
Parameters
pdf (any)

getColorForNorm

Function that calculates the color from a red-white-blue gradient, based on a norm.

getColorForNorm(norm: number): any
Parameters
norm (number) The norm to get a color from
Returns
any: red, green and blue color values based on the norm(0 = red, 0.5 = white, 1 = blue)

renderPage

This function renders a pdf page into a canvas with a given scal

renderPage(page: Object, scale: number): Element
Parameters
page (Object) PDFJs page to render
scale (number) how much to scale the page with
Returns
Element: canvas where the pdf page renders on(may not be finished rendering when the function returns)

getBlocIndexForTextIndex

Given a page and a character index of the text in the page, this function will return the bloc index that that character is in

getBlocIndexForTextIndex(page: Object, index: number): number
Parameters
page (Object) The page object from which you have the text character index
index (number) The character index in the text of the page
Returns
number: The index of the bloc the character is in

getTextWidth

This function returns the width of a text with a given font

getTextWidth(canvas: Element, text: string, font: string): number
Parameters
canvas (Element) A temporary/hidden canvas to draw onto
text (string) The text to calculate the widh on
font (string) The name/size of the font
Returns
number: the width of the text with the given font

drawRect

Draws a filled rectanle inside a document element

drawRect(parent: Element, x: number, y: number, width: number, height: number, scale: number, color: string, classname: string)
Parameters
parent (Element) The element in which the rectangle should be drawn in
x (number) The x coordinate relative to the parent
y (number) The y coordinate relative to the parent
width (number) The width of the rectangle
height (number) The height of the rectangle
scale (number) Global scale of width and height
color (string) the fill color. Same as color in css attributes.(ex: rgb(255, 0, 0))
classname (string) additional css class to give to the element

getHeight

Gets the height of the viewport

getHeight(): number
Returns
number: the height of the viewport

renderPageDetail

This function renders the detail view of a pdf page. This page consists of the pdf preview with the text highlighted in the respective color and the table with more details about every sentence. To highlight the text parts in the pdf preview, colored+transparent HTML-divs get rendered over the canvas with the respective position and size. Finding the correct position proved a difficult task, as sentence might span multiple lines and start/end at the middle of the page. As PDFjs only returns coordinates of blocs of texts and not the actual coordinates of sentences, some calculations must be done. A sentence might begin/end in the middle of a bloc, span across multiple blocs or one bloc might even contain multiple sentences. This function handles all these scenarios so that the overlayed divs are positioned correctly.

renderPageDetail(page: Object)
Parameters
page (Object) The pdf page object

renderPageOverviewItem

This function renders a single page overview item in the overview screen.

renderPageOverviewItem(page: Object): Element
Parameters
page (Object) the page object which to render in the overview.
Returns
Element: the rendered element

renderPageOverview

renders the pages of a given pdf file in overview screen

renderPageOverview(pdf: Object)
Parameters
pdf (Object) Object that stores the information stored in the loaded pdf

showOverview

calls the function to render the overview of the pdf pages

showOverview()

getPageText

Returns all text from a pdf

getPageText(pageNum: any, PDFDocumentInstance: any)
Parameters
pageNum (any)
PDFDocumentInstance (any)

extractVocabulary

Extracts vocabulary out of a reference paper

extractVocabulary(e: any)
Parameters
e (any)

showErrorWithMessage

Shows an error message at the bottom of the screen

showErrorWithMessage(message: string)
Parameters
message (string) the error message to show

startAnalysis

call this function on the start screen, when the user finished providing information.

startAnalysis()

initAccordion

Initializes the accorion on the start screen

initAccordion()

init

This function get called when the page is first loaded, or whenever the user comes back to the start screen. It resets all the components back to its initial values.

init()

resize

This function gets called whenever the user resizes the window

resize()

createLineElement

Creates a line with a given start position, length and angle

createLineElement(x: number, y: number, length: number, angle: number): Element
Parameters
x (number) x start coordinate of the line
y (number) y start coordinate of the line
length (number) length of the line
angle (number) orientation of the line
Returns
Element: an element that renders as a line

createLine

Creates a line with a given start and end position

createLine(x1: number, y1: number, x2: number, y2: any, yy: number): Element
Parameters
x1 (number) x start coordinate of the line
y1 (number) y start coordinate of the line
x2 (number) x end coordinate of the line
y2 (any)
yy (number) y end coordinate of the line
Returns
Element: an element that renders as a line