babalae/better-genshin-impact · error · Exception

未识别的副词条数值:{match.Groups[2].Value}

Error message

未识别的副词条数值:{match.Groups[2].Value}

What it means

Thrown when the minor-affix name was recognized (155 passed) but float.TryParse on match.Groups[2].Value (with '。' replaced by '.') fails under NumberStyles.Any and cultureInfo. The numeric portion of the affix is not parseable.

Source

Thrown at BetterGenshinImpact/GameTask/AutoArtifactSalvage/AutoArtifactSalvageTask.cs:679

            {
                artifactAffixType = ArtifactAffixType.CRITDMG;
            }
            else if (match.Groups[1].Value.Contains(dic[ArtifactAffixType.ElementalMastery]))
            {
                artifactAffixType = ArtifactAffixType.ElementalMastery;
            }
            else if (match.Groups[1].Value.Contains(dic[ArtifactAffixType.EnergyRecharge]))
            {
                artifactAffixType = ArtifactAffixType.EnergyRecharge;
            }
            else
            {
                throw new Exception($"未识别的副词条:{match.Groups[1].Value}");
            }

            if (!float.TryParse(match.Groups[2].Value.Replace("。", "."), NumberStyles.Any, cultureInfo, out float affixValue))
            {
                throw new Exception($"未识别的副词条数值:{match.Groups[2].Value}");
            }

            bool isUnactivated = false;
            // 只有在已经成功识别至少 3 个词条后才执行额外的直方图分析。
            if (minorAffixes.Count >= 3)
            {
                using var lineRoi = levelAndMinorAffixRoi.SubMat(r.Rect);
                using var lineHistogram = new Mat();
                Cv2.CalcHist(
                    images: [lineRoi],
                    channels: [0],
                    mask: null,
                    hist: lineHistogram,
                    dims: 1,
                    histSize: [256],
                    ranges: [new Rangef(0, 256)]
                );
                lineHistogram.GetArray(out float[] histogramFrequencies);

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Log match.Groups[2].Value to inspect the raw number text.
  2. Ensure cultureInfo matches the in-game number locale; convert full-width digits before parse.
  3. Pre-clean the value (strip spaces, normalize separators) before TryParse.
  4. Fall back to RecognitionFailurePolicy.Skip if parsing remains unreliable.
Defensive patterns

Strategy: validation

Validate before calling

static bool TryParseAffixValue(string raw, CultureInfo ci, out float v) =>
    float.TryParse(raw.Replace('。', '.').Replace(" ", ""), NumberStyles.Any, ci, out v);

Prevention

When it happens

Trigger: The captured value contains separators or characters not allowed by NumberStyles.Any under the culture (e.g. a thousands grouping that the culture rejects); OCR inserted noise into the digits; the value is empty or non-numeric.

Common situations: Decimal/thousands separator mismatch between OCR output and cultureInfo; OCR artifacts in the number; full-width digits or other numeral forms not converted.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/cdb95b7ff7b59de2. Report an issue: GitHub.