Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

  • Adds terminating rules support to all language implementations (C#, Python, and Nim)
  • Implements proper Markov algorithm behavior where terminating rules stop transformation immediately
  • Maintains full backward compatibility with existing code

Implementation Details

C# Changes

  • Added IsTerminating property to ISubstitutionRule interface
  • Updated SubstitutionRule class with new constructors and implicit operators for terminating rules
  • Modified TextSteppedTransformer to handle terminating rule logic correctly
  • Added comprehensive unit tests covering various terminating rule scenarios

Python Changes

  • Added is_terminating field to SubRule class
  • Updated SteppedTranslator to process terminating rules and stop execution when applied
  • Added test cases for terminating rule functionality
  • Fixed import paths for proper module loading

Nim Changes

  • Added isTerminating field to RuleObj type
  • Updated transform function to handle terminating rules with immediate termination
  • Created test file for terminating rule verification

Test Coverage

  • C#: 6 comprehensive tests covering basic termination, complex patterns, and multiple matches
  • Python: 2 test cases covering basic and multi-match scenarios
  • Nim: Test file created with basic termination scenarios

Test plan

  • All existing tests continue to pass (backward compatibility maintained)
  • New terminating rule tests pass in C# implementation
  • New terminating rule tests pass in Python implementation
  • Nim implementation updated (tests require Nim compiler to verify)
  • Integration with existing sed-style behavior preserved
  • Terminating rules work correctly with multiple matches in text
  • Non-terminating rules continue processing as expected

🤖 Generated with Claude Code


Resolves #12

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #12
@konard konard self-assigned this Sep 14, 2025
This commit implements terminating rules across all three language implementations
(C#, Python, and Nim) as requested in issue #12. Terminating rules allow for
Markov algorithm behavior where a rule marked as terminating will stop the entire
transformation process immediately after being applied.

Changes:
- Added IsTerminating property to ISubstitutionRule interface and SubstitutionRule class (C#)
- Updated TextSteppedTransformer to handle terminating rule logic (C#)
- Added comprehensive tests for terminating rules functionality (C#)
- Added is_terminating field to SubRule class (Python)
- Updated SteppedTranslator to handle terminating rules (Python)
- Added terminating rule tests (Python)
- Added isTerminating field to RuleObj (Nim)
- Updated transform function to handle terminating rules (Nim)
- Fixed Python imports for proper module loading

The implementation maintains backward compatibility - existing rules continue to work
unchanged, and the new terminating behavior is only activated when explicitly set.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Do we need to add terminating rules support? Add terminating rules support for Markov algorithms Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do we need to add terminating rules support?

2 participants