Compute and set thresholds considering the occurrence of only unique tokens.
(
minimum_coverage,
length,
length_unique,
high_length_unique,
_MIN_MATCH_HIGH_LENGTH=MIN_MATCH_HIGH_LENGTH,
_MIN_MATCH_LENGTH=MIN_MATCH_LENGTH,
)
| 2670 | |
| 2671 | |
| 2672 | def compute_thresholds_unique( |
| 2673 | minimum_coverage, |
| 2674 | length, |
| 2675 | length_unique, |
| 2676 | high_length_unique, |
| 2677 | _MIN_MATCH_HIGH_LENGTH=MIN_MATCH_HIGH_LENGTH, |
| 2678 | _MIN_MATCH_LENGTH=MIN_MATCH_LENGTH, |
| 2679 | ): |
| 2680 | """ |
| 2681 | Compute and set thresholds considering the occurrence of only unique tokens. |
| 2682 | """ |
| 2683 | if minimum_coverage == 100: |
| 2684 | min_matched_length_unique = length_unique |
| 2685 | min_high_matched_length_unique = high_length_unique |
| 2686 | return min_matched_length_unique, min_high_matched_length_unique |
| 2687 | |
| 2688 | if length > 200: |
| 2689 | min_matched_length_unique = length // 10 |
| 2690 | min_high_matched_length_unique = high_length_unique // 10 |
| 2691 | |
| 2692 | elif length < 5: |
| 2693 | min_matched_length_unique = length_unique |
| 2694 | min_high_matched_length_unique = high_length_unique |
| 2695 | |
| 2696 | elif length < 10: |
| 2697 | if length_unique < 2: |
| 2698 | min_matched_length_unique = length_unique |
| 2699 | else: |
| 2700 | min_matched_length_unique = length_unique - 1 |
| 2701 | min_high_matched_length_unique = high_length_unique |
| 2702 | |
| 2703 | elif length < 20: |
| 2704 | min_matched_length_unique = high_length_unique |
| 2705 | min_high_matched_length_unique = high_length_unique |
| 2706 | |
| 2707 | else: |
| 2708 | min_matched_length_unique = _MIN_MATCH_LENGTH |
| 2709 | highu = (int(high_length_unique // 2)) or high_length_unique |
| 2710 | min_high_matched_length_unique = min(highu, _MIN_MATCH_HIGH_LENGTH) |
| 2711 | |
| 2712 | return min_matched_length_unique, min_high_matched_length_unique |
| 2713 | |
| 2714 | |
| 2715 | class SynthethicRule(Rule): |