Skip to main content

pd_cipher::crypto::numeric_detection

Numeric detection for token classification. Locale-agnostic numeric detection for token classification.

This module provides sophisticated detection of numeric values in various international formats while excluding common non-numeric identifiers like phone numbers and Social Security Numbers.

Functions

parse_numeric

Parses a token as a numeric value if it represents a valid number.

This function handles various international number formats including:

  • US format: 1,234.56
  • European format: 1.234,56
  • Swiss format: 1'234.56
  • SI/Spaced format: 1 234.56
  • Scientific notation: 1.23e-4
  • Special values: Infinity, -Infinity, NaN

It explicitly excludes:

  • Social Security Numbers (XXX-XX-XXXX)
  • Phone numbers (various formats)
  • Currency symbols
  • Invalid numeric formats

Arguments

  • token - The byte slice to parse

Returns

  • Some(f64) if the token is a valid number
  • None if the token is not numeric or is an excluded identifier
pub fn parse_numeric(...)