Spaces:
Sleeping
Sleeping
Download test_specific_content.py from brightmind-ai/test: direct link, hf CLI and curl.
- Browser
- Download file 3.13 kB
-
https://huggingface.co/spaces/brightmind-ai/test/resolve/main/test_specific_content.py
- Command line
-
hf download hf://spaces/brightmind-ai/test/test_specific_content.py
-
curl -L -o test_specific_content.py https://huggingface.co/spaces/brightmind-ai/test/resolve/main/test_specific_content.py
3.13 kB
| #!/usr/bin/env python3 | |
| """ | |
| Test script to verify specific content from user's example | |
| """ | |
| import sys | |
| import os | |
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
| from app import convert_math_to_html | |
| def test_user_content(): | |
| """Test the specific content patterns from the user's example""" | |
| print("🧪 Testing specific content patterns from user's example...") | |
| # Test cases based on the user's actual content | |
| test_cases = [ | |
| # From the user's content | |
| r"\text{Speed} = \frac{\text{Distance}}{\text{Time}}", | |
| r"m = d × v", | |
| r"d = density (5 g/cm³)", | |
| r"v = volume (10 cm³)", | |
| r"m = \_\_\_ × \_\_\_ = \_\_\_ \text{ g}", | |
| r"2H2 + O2 → \_\H2O", | |
| r"2H2 + O2 → \boxed{\_\_}H2O", | |
| r"W = F × d", | |
| r"F = force (50 N)", | |
| r"d = distance (10 m)", | |
| r"W = \_\_\_ × \_\_\_ = \_\_\_ \text{ J}", | |
| r"m = 5 × 10 = 50 \text{ g}", | |
| r"2H2 + O2 → 2H2O", | |
| r"\text{Speed} = \frac{120}{2} = 60 \text{ km/h}", | |
| r"W = 50 × 10 = 500 \text{ J}" | |
| ] | |
| for i, test_case in enumerate(test_cases, 1): | |
| print(f"\n{i}. Input: {test_case}") | |
| result = convert_math_to_html(test_case) | |
| print(f" Output: {result}") | |
| print(f" Length: {len(result)} chars") | |
| # Check if LaTeX commands were converted | |
| if '\\text{' in result: | |
| print(" ⚠️ Still contains \\text{} commands") | |
| if '\\frac{' in result: | |
| print(" ⚠️ Still contains \\frac{} commands") | |
| if '\\_' in result: | |
| print(" ⚠️ Still contains \\_ commands") | |
| def test_complex_content(): | |
| """Test a complex example that matches the user's content""" | |
| print("\n🎯 Testing complex content example...") | |
| complex_content = """ | |
| A scientist measures the mass (m) of a substance using the formula: | |
| m = d × v | |
| where: - d = density (5 g/cm³) - v = volume (10 cm³) | |
| **Find the mass (m).** **Solution:** | |
| m = \_\_\_ × \_\_\_ = \_\_\_ \\text{ g} | |
| Balance the chemical equation using algebra: | |
| 2H2 + O2 → \\_\\H2O | |
| **Fill in the blank:** | |
| 2H2 + O2 → \\boxed{\\_\\_}H2O | |
| A car travels **120 km** in **2 hours**. Use the formula: | |
| \\text{Speed} = \\frac{\\text{Distance}}{\\text{Time}} | |
| **Calculate the speed.** | |
| \\text{Speed} = | |
| \\_\\_\\_ | |
| \\_\\_\\_ | |
| = \\_\\_\\_ \\text{ km/h} | |
| The work done (W) is calculated by: | |
| W = F × d | |
| where: - F = force (50 N) - d = distance (10 m) | |
| **Find the work done.** | |
| W = \\_\\_\\_ × \\_\\_\\_ = \\_\\_\\_ \\text{ J} | |
| """ | |
| print("Original content:") | |
| print(complex_content) | |
| print("\nConverted content:") | |
| converted = convert_math_to_html(complex_content) | |
| print(converted) | |
| # Save to file | |
| with open("test_complex_output.html", "w", encoding="utf-8") as f: | |
| f.write(converted) | |
| print("\n💾 Complex content saved to test_complex_output.html") | |
| if __name__ == "__main__": | |
| test_user_content() | |
| test_complex_content() | |
| print("\n✅ Testing completed!") | |