Functions
Config
dataclass
Configuration for NLP input paths and processing flags.
Source code in src/pydistintox/common/config.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
calculate_rank_correlation(results)
Calculates the Kendall rank correlation coefficients between all pairs of measures in the input dictionary. It returns them as a 2-d matrix (np.ndarray)
As the input arrays are uniformly scaled, only rank correlation is meaningful. The resulting matrix is symmetric, with each entry representing the correlation between two measures.
Source code in src/pydistintox/distinct_measures/core.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
calculate_scores(matrices, config)
This is the main funktion, doing all the calculation. it takes and gives out a dictionary containing these keys: ['zeta_sd0', 'zeta_sd2', 'rrf_dr0', 'eta_sg0', 'welch_t_value', 'ranksumtest_value', 'chi_square_value', 'LLR_value', 'tf_idf'] This function implements several distinctive measures.
Source code in src/pydistintox/distinct_measures/core.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
compute_td_matrices_and_measures(config)
parses texts, then creates a whole corpus of lemmata calculates six TF-IDF measures of given the texts.
Source code in src/pydistintox/td_matrices/core.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
save_as_sparse(dense_matrix, output_dir, file_prefix, format)
Saves a dense matrix as sparse in the given directory using scipy.sparse.save_npz with the suffix 'npz'.
Source code in src/pydistintox/common/utils.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
save_results(result, path, write_header=True)
store results as textfile in csv format in given directory.
Source code in src/pydistintox/visualize/core.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
visualize_rank_correlations(matrix, index, dir_path)
visualize rank correlations between scores
Source code in src/pydistintox/visualize/core.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
visualize_score(score_processed, title, path)
Visualizes the top and bottom terms from a score DataFrame as a horizontal bar chart.
Displays the top 25 terms (highest scores) in lightgreen and the bottom 25 terms (lowest scores) in lightblue. The chart is saved as an interactive HTML file in the specified directory.
Source code in src/pydistintox/visualize/core.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |