<commit_before>package configgen.genlua;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

class FullToBrief {
    private final Map<String, String> usedFullNameToBriefNames = new HashMap<>();
    private final Set<String> forbidBriefNames = new HashSet<>();
    private final Set<String> usedBriefNames = new HashSet<>();

    FullToBrief(String pkg) {
        forbidBriefNames.add(pkg);
        forbidBriefNames.add("Beans");
        forbidBriefNames.add("this");
        forbidBriefNames.add("mk");
    }

    void clear() {
        usedBriefNames.clear();
        usedFullNameToBriefNames.clear();
    }

    Map<String, String> getAll() {
        return usedFullNameToBriefNames;
    }

    String toBrief(String fullName) {
        String brief = usedFullNameToBriefNames.get(fullName);
        if (brief != null) {
            return brief;
        }

        String[] seps = fullName.split("\\.");
        String tryName = null;
        for (int i = seps.length - 1; i >= 0; i--) {
            if (tryName == null) {
                tryName = seps[i];
            } else {
                tryName = seps[i] + "_" + tryName;
            }

            if (forbidBriefNames.contains(tryName)) {
                continue;
            }

            if (usedBriefNames.contains(tryName)) {
                continue;
            }

            usedBriefNames.add(tryName);
            usedFullNameToBriefNames.put(fullName, tryName);
            return tryName;
        }

        throw new RuntimeException("竟然找不到个不重复的名字，我选择死亡");
    }
}
<commit_msg>lua 生成引用顺序确定化<commit_after>package configgen.genlua;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

class FullToBrief {
    private final Map<String, String> usedFullNameToBriefNames = new TreeMap<>(); //用TreeMap使得生成代码确定
    private final Set<String> forbidBriefNames = new HashSet<>();
    private final Set<String> usedBriefNames = new HashSet<>();

    FullToBrief(String pkg) {
        forbidBriefNames.add(pkg);
        forbidBriefNames.add("Beans");
        forbidBriefNames.add("this");
        forbidBriefNames.add("mk");
    }

    void clear() {
        usedBriefNames.clear();
        usedFullNameToBriefNames.clear();
    }

    Map<String, String> getAll() {
        return usedFullNameToBriefNames;
    }

    String toBrief(String fullName) {
        String brief = usedFullNameToBriefNames.get(fullName);
        if (brief != null) {
            return brief;
        }

        String[] seps = fullName.split("\\.");
        String tryName = null;
        for (int i = seps.length - 1; i >= 0; i--) {
            if (tryName == null) {
                tryName = seps[i];
            } else {
                tryName = seps[i] + "_" + tryName;
            }

            if (forbidBriefNames.contains(tryName)) {
                continue;
            }

            if (usedBriefNames.contains(tryName)) {
                continue;
            }

            usedBriefNames.add(tryName);
            usedFullNameToBriefNames.put(fullName, tryName);
            return tryName;
        }

        throw new RuntimeException("竟然找不到个不重复的名字，我选择死亡");
    }
}

{'fraction_non_alphanumeric': 0.11542041576171269, 'fraction_numerical': 0.0012410797393732546, 'mean_word_length': 2.021555763823805, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '233997', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1006, 'n_words': 190}