mainWindow module

class mainWindow.ItemDelegate

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Re-implement the edit event to detect changes in the detail view.

cellEditingStarted
createEditor(parent, option, index)

Re-implement function to customize the edit behavior.

class mainWindow.Ui_MainWindow

Bases: object

The main window of the user interface. It defines all ui elements.

cell_edit_start(row, column)

Called when the user selects a cell to save the cell data.

Parameters
  • row – the row of the cell selected

  • column – the column of the cell selected

Returns

None

cell_edited()

Called when a cell in the detail view is changed. It updates all scores and colors of the sentence edited.

Returns

None.

connect_buttons()

Connect the pdf buttons with their processing methods.

Returns

None

static download_nltk()

Open the NLTK downloader.

Returns

None

generate_pdf_with_button()

Generate a pdf, highlight it, and open it with the standard program of the user.

Returns

None

static paint_text(pixmap, start_pos, end_pos, start_text, end_text, color)

Paint two text-strings on a pixmap.

Parameters
  • pixmap – the pixmap to paint the text on

  • start_pos – the position of the first text-string

  • end_pos – the position of the second text-string

  • start_text – the first text-string to paint

  • end_text – the second text-string to paint

  • color – the color used for painting

Returns

the pixmap with the text painted on

process_file(file_name)

Initiate the sentence extraction and set the scores for all sentence data.

Parameters

file_name – the name of the file selected

Returns

None

resizeEvent(event)
resize_detail_view()

Resize the columns of the detail view.

Returns

None

retranslateUi(MainWindow)

Retranslate the view of the ui.

Parameters

MainWindow – the main window of the ui

Returns

None

set_pdf()

Called when the user clicks the select-pdf button. It opens a pdf-file selection dialog. Further, it initiates the file processing.

Returns

None

setupUi(MainWindow)

Setup all ui elements.

Parameters

MainWindow – the main window of the ui

Returns

None

testPrint()

Prints a message when the generate-pdf-button is clicked.

Returns

None

mainWindow.calculate_sentence_score(score_matrix, row)

Calculate the score of a single sentence.

Parameters
  • score_matrix – the matrix with the score values

  • row – the row of the sentence, whose score is calculated

Returns

the calculated score of the sentence

mainWindow.interpolate_color(color2, color1, t)

Interpolate between two colors.

Parameters
  • color2 – one color for the interpolation

  • color1 – another color for the interpolation

  • t – the interpolation coefficient

Returns

the interpolated color value

mainWindow.interpolate_score_color(score, sentence)

Interpolate between colors based on the feature score.

Parameters
  • score – the score of the feature

  • sentence – the sentence whose feature color is interpolated

Returns

None

mainWindow.interpolate_sentence_color(sentence_score, sentence)

Interpolate between colors based on the sentence score.

Parameters
  • sentence_score – the score of the sentence

  • sentence – the sentence whose color is interpolated

Returns

None

mainWindow.nominal_form_slider_value_change(value)

Called when the user changes the nominal form slider in the ui. This leads to an update of the sentence score values and of the sentence color values.

Parameters

value – the updated value of the nominal form slider

Returns

None

mainWindow.sentence_length_slider_value_change(value)

Called when the user changes the sentence length slider in the ui. This leads to an update of the sentence score values and of the sentence color values.

Parameters

value – the updated value of the sentence length slider

Returns

None

mainWindow.sentence_structure_slider_value_change(value)

Called when the user changes the sentence structure slider in the ui. This leads to an update of the sentence score values and of the sentence color values.

Parameters

value – the updated value of the sentence structure slider

Returns

None

mainWindow.slider_count()

Count how many sliders have an effect on the result. These are all sliders with a weight higher than zero.

Returns

the number of sliders with a weight higher than zero

mainWindow.update_colors()

Update the colors of all sentences. First calculate an updated score value. Then interpolate the new sentence colors based on the scores calculated. Finally update the sentence colors.

Returns

None

mainWindow.update_overall_score(sum_score, num)

Calculate an overall score for the document and show it in the ui.

Parameters
  • sum_score – the sum of all sentence score values

  • num – the number of sentences

Returns

None

mainWindow.update_score_color(row, column, sentence)

Update the color of a feature.

Parameters
  • row – the row of the feature to update

  • column – the column of the feature to update

  • sentence – the sentence whose feature color is updated

Returns

None

mainWindow.update_sentence_color(row, sentence)

Update the color of a sentence.

Parameters
  • row – the row of the sentence to update

  • sentence – the sentence whose color is updated

Returns

None

mainWindow.vocabulary_slider_value_change(value)

Called when the user changes the vocabulary slider in the ui. This leads to an update of the sentence score values and of the sentence color values.

Parameters

value – the updated value of the vocabulary slider

Returns

None

mainWindow.word_length_slider_value_change(value)

Called when the user changes the word length slider in the ui. This leads to an update of the sentence score values and of the sentence color values.

Parameters

value – the updated value of the word length slider

Returns

None