<commit_before>package org.languagetool.rules.uk;

import java.util.*;

import org.languagetool.*;
import org.languagetool.rules.RuleMatch;
import org.languagetool.rules.WordRepeatRule;
import org.languagetool.tagging.uk.IPOSTag;
import org.languagetool.tagging.uk.PosTagHelper;

/**
 * @since 2.9
 */
public class UkrainianWordRepeatRule extends WordRepeatRule {
  private static final HashSet<String> REPEAT_ALLOWED_SET = new HashSet<>(
      Arrays.asList("ст.")
  );
  private static final HashSet<String> REPEAT_ALLOWED_CAPS_SET = new HashSet<>(
      Arrays.asList("Джей", "Бі", "Сі")
  );

  public UkrainianWordRepeatRule(ResourceBundle messages, Language language) {
    super(messages, language);
  }

  @Override
  public String getId() {
    return "UKRAINIAN_WORD_REPEAT_RULE";
  }

  @Override
  public boolean ignore(AnalyzedTokenReadings[] tokens, int position) {
    AnalyzedTokenReadings analyzedTokenReadings = tokens[position];
    String token = analyzedTokenReadings.getToken();
    
    // від добра добра не шукають
    if( position > 2 
        && token.equals("добра")
        && tokens[position-2].getToken().equalsIgnoreCase("від") )
      return true;
    
    // Тому що що?
    if( position > 1 
        && token.equals("що")
        && tokens[position-2].getToken().equalsIgnoreCase("тому") )
      return true;

    // ні так, ні ні
    if( position > 3
        && token.equals("ні")
        && tokens[position-2].getToken().equals(",")
        && tokens[position-3].getToken().equalsIgnoreCase("так") )
      return true;

    if( REPEAT_ALLOWED_SET.contains(token.toLowerCase()) )
      return true;

    if( REPEAT_ALLOWED_CAPS_SET.contains(token) )
      return true;
    
    if( PosTagHelper.hasPosTag(analyzedTokenReadings, "date|time|number") )
      return true;
    <commit_msg>[uk] new word repeat rule exception<commit_after>package org.languagetool.rules.uk;

import java.util.*;

import org.languagetool.*;
import org.languagetool.rules.RuleMatch;
import org.languagetool.rules.WordRepeatRule;
import org.languagetool.tagging.uk.IPOSTag;
import org.languagetool.tagging.uk.PosTagHelper;

/**
 * @since 2.9
 */
public class UkrainianWordRepeatRule extends WordRepeatRule {
  private static final HashSet<String> REPEAT_ALLOWED_SET = new HashSet<>(
      Arrays.asList("ст.")
  );
  private static final HashSet<String> REPEAT_ALLOWED_CAPS_SET = new HashSet<>(
      Arrays.asList("Джей", "Бі", "Сі", "Ла")
  );

  public UkrainianWordRepeatRule(ResourceBundle messages, Language language) {
    super(messages, language);
  }

  @Override
  public String getId() {
    return "UKRAINIAN_WORD_REPEAT_RULE";
  }

  @Override
  public boolean ignore(AnalyzedTokenReadings[] tokens, int position) {
    AnalyzedTokenReadings analyzedTokenReadings = tokens[position];
    String token = analyzedTokenReadings.getToken();

    // від добра добра не шукають
    if( position > 2 
        && token.equals("добра")
        && tokens[position-2].getToken().equalsIgnoreCase("від") )
      return true;

    // Тому що що?
    if( position > 1 
        && token.equals("що")
        && tokens[position-2].getToken().equalsIgnoreCase("тому") )
      return true;

    // ні так, ні ні
    if( position > 3
        && token.equals("ні")
        && tokens[position-2].getToken().equals(",")
        && tokens[position-3].getToken().equalsIgnoreCase("так") )
      return true;

    if( REPEAT_ALLOWED_SET.contains(token.toLowerCase()) )
      return true;

    if( REPEAT_ALLOWED_CAPS_SET.contains(token) )
      return true;
    
    if( PosTagHelper.hasPosTag(analyzedTokenReadings, "date|time|number") )
      return true;
    
{'fraction_non_alphanumeric': 0.12588749317312944, 'fraction_numerical': 0.004915346805024577, 'mean_word_length': 3.4834761321909427, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6351527', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1229, 'n_words': 230}