Skip to content
Snippets Groups Projects
Commit 866a5417 authored by Benedikt's avatar Benedikt
Browse files

added regEXGenerator

parent 48b25704
No related tags found
No related merge requests found
Pipeline #37960 passed
......@@ -720,6 +720,19 @@ def _getClosestStr(unkownStr):
possibleDsiKeys = _dsiPrefixesLatex.keys() | _dsiUnitsLatex.keys() | _dsiKeyWords.keys()
closestStr = difflib.get_close_matches(unkownStr, possibleDsiKeys, n=3,cutoff=0.66)
return closestStr
def generateRegeEXForDSIValidation():
import re
# Lists of prefixes and units
dsi_prefixes = _dsiPrefixesUTF8.keys()
dsi_units = _dsiUnitsLatex.keys()
# Constructing the regex pattern
prefix_pattern = '|'.join(re.escape(prefix) for prefix in dsi_prefixes)
unit_pattern = '|'.join(re.escape(unit) for unit in dsi_units)
regex_pattern = r'\\(?:{})(?:\\{})?(?:\\tothe{{[+-]?\d+}})?'.format(prefix_pattern, unit_pattern)
return regex_pattern
# mapping D-SI prefixes to latex
_dsiPrefixesLatex = {
'deca': r'\mathrm{da}',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment