Skip to main content

Pricetag

A pure-Python library for extracting price and currency information from unstructured text, with a primary focus on salary data in job postings.

Features

  • Zero Dependencies: Uses only Python standard library
  • High Performance: Processes 1000+ documents per second
  • Comprehensive Pattern Support:
    • Individual amounts: $50,000, $50k, 50k USD
    • Ranges: $50k-$75k, $50,000 to $75,000
    • Hourly/Annual/Monthly rates: $25/hour, $50k/year, $4k/month
    • Contextual terms: six figures, competitive, DOE
  • Smart Normalization: Converts all amounts to annual USD for easy comparison
  • Confidence Scoring: Each extraction includes a confidence score
  • Validation & Sanity Checks: Flags unusual or problematic values

Installation

pip install pricetag

Quick Start

from pricetag import PriceExtractor

# Initialize the extractor
extractor = PriceExtractor()

# Extract prices from text
text = "Senior Engineer position paying $120,000 - $150,000 annually"
results = extractor.extract(text)

# Access the results
for result in results:
    print(f"Value: {result['value']}")
    print(f"Type: {result['type']}")
    print(f"Confidence: {result['confidence']}")
    print(f"Annual value: {result['normalized_annual']}")

Configuration Options

extractor = PriceExtractor(
    min_confidence=0.5,        # Minimum confidence score to include
    include_contextual=True,   # Extract terms like "six figures"
    normalize_to_annual=True,  # Convert to annual amounts
    min_salary=10000,          # Minimum reasonable salary
    max_salary=10000000,       # Maximum reasonable salary
    assume_hours_per_year=2080,# For hourly→annual conversion
    fast_mode=False,           # Enable for better performance
    max_results_per_text=None  # Limit number of results
)

Examples

Basic Salary Extraction

text = "The position offers $75,000 per year with benefits"
results = extractor.extract(text)
# Returns: [{'value': 75000.0, 'type': 'annual', ...}]

Hourly Rate with Normalization

text = "Paying $45/hour for senior developers"
results = extractor.extract(text)
# Returns: [{'value': 45.0, 'type': 'hourly', 'normalized_annual': 93600.0, ...}]

Salary Range

text = "Salary range: $60k-$80k depending on experience"
results = extractor.extract(text)
# Returns: [{'value': (60000.0, 80000.0), 'is_range': True, ...}]

Contextual Terms

text = "Looking for someone with 5+ years experience, six figures"
results = extractor.extract(text)
# Returns: [{'value': (100000, 999999), 'type': 'unknown', 'confidence': 0.7, ...}]

Multiple Prices

text = "Base: $100k, Bonus: up to $30k, Equity: 0.5%"
results = extractor.extract(text)
# Returns multiple results with appropriate flags

Batch Processing

texts = [
    "Salary: $50,000",
    "Rate: $30/hour", 
    "Competitive pay"
]
results_batch = extractor.extract_batch(texts)

Output Format

Each extraction returns a PriceResult dictionary:

{
    'value': float | tuple[float, float],  # Single value or (min, max)
    'raw_text': str,                       # Original matched text
    'position': tuple[int, int],           # Character positions
    'type': str,                           # 'hourly', 'annual', 'monthly', etc.
    'confidence': float,                   # 0.0 to 1.0
    'normalized_annual': float | tuple,    # Annual USD amount
    'currency': str,                       # Always 'USD' in v1
    'is_range': bool,                      # True for ranges
    'flags': list[str]                     # Validation flags
}

Validation Flags

  • invalid_range: Max less than min
  • below_minimum: Below configured threshold
  • above_maximum: Above configured threshold
  • unreasonable_hourly_rate: Outside $7-$500/hour
  • potential_inconsistency: Large discrepancy with other prices
  • ambiguous_type: Unclear if hourly/annual
  • approximate: Estimated from "approximately"
  • requires_market_data: Needs external data (e.g., "competitive")
  • experience_dependent: Depends on experience (e.g., "DOE")

Performance

The library is optimized for high-volume processing:

  • Pre-compiled regex patterns
  • Number parsing cache
  • Quick pre-filtering
  • Fast mode for bulk processing
  • Batch processing support
# Fast mode for high-volume processing
extractor = PriceExtractor(fast_mode=True, max_results_per_text=5)

# Process 1000 documents
texts = ["..." for _ in range(1000)]
results = extractor.extract_batch(texts)  # < 1 second

Testing

Run the test suite:

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

# Run with coverage
pytest tests/ --cov=pricetag

Limitations

  • Currently supports USD only
  • Optimized for US salary formats
  • Context window limited to surrounding text
  • Does not handle equity/stock compensation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Author

Michelle Pellon - mgracepellon@gmail.com

Acknowledgments

Built with pure Python for maximum compatibility and zero dependencies.

Metadata

Release files for pricetag 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pricetag 1.0.1
File Size Uploaded Provenance Actions
pricetag-1.0.1.tar.gz 28.8 kB Without provenance Details for pricetag-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pricetag 1.0.1
File Interpreter ABI Platform Actions
pricetag-1.0.1-py3-none-any.whl Python 3 none any Details for pricetag-1.0.1-py3-none-any.whl

Total release size: 48.2 kB

Release files / pricetag-1.0.1.tar.gz

Download URL pricetag-1.0.1.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
57a4872a14e84e272f666afb37774580bb64c8762f4bedbfa983051861f04edc
BLAKE2b-256 checksum
How to use checksums
2ac7e36b97d51c4289a838ba1a4a3ea80c8ca6aac39bfdf3fa97e6b19eec6996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pricetag-1.0.1-py3-none-any.whl

Download URL pricetag-1.0.1-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86d44eaf59de6c561c08a299e9cd33c944ce642cac4213135af390d7393ffeb5
BLAKE2b-256 checksum
How to use checksums
66541dc49d2344575b86c7cd43a4b077b5c1768479ae412c5521384f9aacbce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pricetag 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page