mapper.matchers.prefix_matcher
Prefix matcher for statistics-to-geo assignments.
This class has been adapted to the structure of other matchers
- Direct
setupUi(self)instead of wrapping inself.ui→ consistent API. - All UI accesses go through
self.<widget>(instead ofself.ui.<widget>). - Pure formatting/name changes – logic and return values remain the same.
PrefixMatcher
Bases: BaseMatcher, Ui_PrefixMatcher
Matcher for prefix-based matching between statistics and geo data.
Behavior
- Takes a prefix of configurable length from the selected columns.
- Finds unique common prefixes in both tables.
- Maps exactly one row per common prefix.
Source code in src/mapper/matchers/prefix_matcher.py
24 25 26 27 28 29 30 31 32 33 34 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 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 | |
__init__(nr, stats_cols, geo_cols, parent=None)
Initialize the prefix matcher widget.
Steps
- Call BaseMatcher constructor to store identifier and column lists.
- Call setupUi(self) to build UI controls from .ui file.
- Populate the Excel and geo combo boxes with provided column lists.
- Configure the spin box
spinLengthto choose prefix length (range 1–100). - Connect UI signals to the
updatedandremovedsignals.
Source code in src/mapper/matchers/prefix_matcher.py
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 | |
description()
Provide a description of this matcher's configuration.
Steps
- Combine the matcher ID, selected stats column, selected geo column, and prefix length into a string.
- Format as "PRE#
: → [ ]".
Source code in src/mapper/matchers/prefix_matcher.py
174 175 176 177 178 179 180 181 182 183 | |
match(stats_df, geo_df)
Match records using exact prefix matching.
Steps
- Retrieve selected column names and prefix length from UI.
- If the selected columns are not present, set stats to 0 and return.
- Compute prefixes by taking the first
lengthcharacters of string values. - Identify common prefixes between both DataFrames.
- For each common prefix, select exactly one statistics row and one geo row.
- Build combined result rows via
build_result(). - Concatenate parts into one DataFrame, update stats label, and return indices.
Source code in src/mapper/matchers/prefix_matcher.py
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 | |
set_stats(n)
Update the label that displays number of matches found.
Steps
- Convert integer
nto string and set it onlabelStats.
Source code in src/mapper/matchers/prefix_matcher.py
162 163 164 165 166 167 168 169 | |