<commit_before>package twzip.model;

import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 儲存地址的數值資料
 *
 * @author <NAME>
 */
public class Address {

    private static final long serialVersionUID = 5452467653824560048L;
    private int ln = 0;
    private int lane = 0;
    private int addLane = 0;
    private int alley = 0;
    private int addAlley = 0;
    private int number = 0;
    private int addnum = 0;
    private String build = "";
    private int floor = 0;

    private static final Map<Pattern, String> replaces;

    private static final Pattern p71 = Pattern.compile("(\\d+)\\x{4E4B}(\\d+)\\x{4E4B}\\d+\\x{5DF7}");//xx之xx之xx巷
    private static final Pattern p72 = Pattern.compile("(\\d+)\\x{4E4B}(\\d+)\\x{5DF7}");//xx之xx巷
    private static final Pattern p73 = Pattern.compile("(\\d+)\\x{5DF7}");//巷
    private static final Pattern p81 = Pattern.compile("(\\d+)\\x{4E4B}(\\d+)\\x{5F04}");//xx之xx弄
    private static final Pattern p82 = Pattern.compile("(\\d+)\\x{5F04}");//弄
    private static final Pattern p91 = Pattern.compile("(\\d+)[\\x{4E4B}\\x{FF0D}-](\\d+)\\x{865F}[\\x{4E4B}\\x{FF0D}-]\\d+[^\\x{6A13}Ff]");//xx 之 xx 號 之 xx[^樓]
    private static final Pattern p92 = Pattern.compile("(\\d+)\\x{865F}[\\x{4E4B}\\x{FF0D}-](\\d+)[^\\x{6A13}Ff]");//xx 號之 xx[^樓]
    private static final Pattern p93 = Pattern.compile("(\\d+)[\\x{4E4B}\\x{FF0D}-](\\d+)[\\x{4E4B}\\x{FF0D}-]\\d+\\x{865F}");//xx 之 xx 之 xx號
    private static final Pattern p94 = Pattern.compile("(\\d+)[\\x{4E4B}\\x{FF0D}-](\\d+)\\x{865F}");//xx 之 xx號
    private static final Pattern p95 = Pattern.compile("(\\d+)\\x{865F}");//xx 號
    private static final Pattern pF1 = Pattern.compile("(\\p{InCJKUnifiedIdeographs}+)?\\x{5730}\\x{4E0B}(-?\\d+)\\x{6A13}");//樓
    private static final Pattern pF2 = Pattern.compile("(\\p{InCJKUnifiedIdeographs}+[^\\x{6A13}])?[bB](-?\\d+)[fF]?");
    private static final Pattern pF3 = Pattern.compile("(\\p{InCJKUnifiedIdeographs}+)?(-?\\d+)[\\x{6A13}fF]");
    private static final Pattern pNoNum = Pattern.compile("[^\\x{865F}].*\\d+$");//缺少號又以數字結尾

    static {
        replaces = new LinkedHashMap<>();
        //<editor-fold defaultstate="collapsed" desc="replace patterns">
        String one2nine = "[\\x{4E00}\\x{4E8C}\\x{4E09}\\x{56DB}\\x{4E94}\\x{516D}\\x{4E03}\\x{516B}\\x{4E5D}]";
        replaces.put(Pattern.compile("[\\x{3000}\\s]+"), "");
        replaces.put(Pattern.compile("(?<=" + one2nine + ")\\x{5341}(?=" + one2nine + ")"), "");
        replaces.put(Pattern.compile("(?<=" + one2nine + ")\\x{5341}"), "0");
        replaces.put(Pattern.compile("\\x{5341}(?=" + one2nine + ")"), "1");
        replaces.put(Pattern.compile("\\x{5341}"), "10");
        replaces.put(Pattern.compile("\\x{FF10}"), "0");
	replaces.put(Pattern.compile("[\\x{3127}\\x{4E00}\\x{FF11}]"), "1");
        replaces.put(Pattern.compile("[\\x{4E8C}\\x{FF12}]"), "2");
        replaces.put(Pattern.compile("[\\x{4E09}\\x{FF13}]"), "3");
        replaces.put(Pattern.compile("[\\x{56DB}\\x{FF14}]"), "4");
        replaces.put(Pattern.compile("[\\x{4E94}\\x{FF15}]"), "5");
        replaces.put(Pattern.compile("[\\x{516D}\\x{FF16}]"), "6");
        replaces.put(Pattern.compile("[\\x{4E03}\\x{FF17}]"), "7");
        replaces.put(Pattern.compile("[\\x{516B}\\x{FF18}]"), "8");
        replaces.put(Pattern.compile("[\\x{4E5D}\\x{FF19}]"), "9");
        replaces.put(Pattern.compile("\\x{FF08}"), "(");
        replaces.put(Pattern.compile("\\x{FF09}"), ")");
        replaces.put(Pattern.compile("\\x{81FA}"), "台");
        replaces.put(Pattern.compile("\\x{5553}"), "啟");
        replaces.put(Pattern.compile("\\x{5869}"), "鹽");
        replaces.put(Pattern.compile("\\x{62D5}"), "托");
        replaces.put(Pattern.compile("\\x{5ECD}"), "廓");
        replaces.put(Pattern.compile("\\x{78D8}"), "窯");
        replaces.put(Pattern.compile("\\x{7AB0}"), "窯");
        replaces.put(Pattern.compile("\\x{8218}"), "館");
        replaces.put(Pattern.compile("\\x{90A8}"), "村");
        replaces.put(Pattern.compile("\\x{5CEF}"), "峰");
        replaces.put(Pattern.compile("\\x{7AEA}"), "豎");
        replaces.put(Pattern.compile("\\x{7F97}"), "羌");
        replaces.put(Pattern.compile("\\x{7067}"), "灩");
        replaces.put(Pattern.compile("\\x{811A}"), "腳");
        replaces.put(Pattern.compile("\\x{920E}"), "鉤");
        replaces.put(Pattern.compile("\\x{7282}"), "犁");
        replaces.put(Pattern.compile("\\x{5DFF}"), "市");
        replaces.put(Pattern.compile("\\x{8914}"), "福");
        replaces.put(Pattern.compile("\\x{6E76}"), "泉");
        replaces.put(Pattern.compile("\\x{83D3}"), "果");
        replaces.put(Pattern.compile("\\x{5754}"), "湳");
        replaces.put(Pattern.compile("\\x{5742}"), "板");
        replaces.put(Pattern.compile("\\x{5E99}"), "廟");
        replaces.put(Pattern.compile("\\x{6B0D}"), "舊");
        replaces.put(Pattern.compile("\\x{78DC}"), "祭");
        replaces.put(Pattern.compile("\\x{7866}"), "弄");
        replaces.put(Pattern.compile("\\x{7B0B}"), "尹");
        replaces.put(Pattern.compile("\\x{713F}"), "庚");
        replaces.put(Pattern.compile("\\x{8EAD}"), "耽");
        replaces.put(Pattern.compile("\\x{9DC4}"), "雞");
        replaces.put(Pattern.compile("\\x{9B98}"), "代");
        replaces.put(Pattern.compile("\\x{5223}"), "台");
        replaces.put(Pattern.compile("\\x{53A6}"), "夏");
        replaces.put(Pattern.compile("\\x{53CC}"), "雙");
        replaces.put(Pattern.compile("\\x{5D75}"), "時");
        replaces.put(Pattern.compile("\\x{5E92}"), "庄");
        replaces.put(Pattern.compile("\\x{6898}"), "見");
        replaces.put(Pattern.compile("\\x{69FA}"), "康");
        replaces.put(Pattern.compile("\\x{7858}"), "回");
        replaces.put(Pattern.compile("\\x{8471}"), "蔥");
        replaces.put(Pattern.compile("\\x{5C2B}"), "尪");
        replaces.put(Pattern.compile("\\x{8289}"), "竿");
        replaces.put(Pattern.compile("\\x{53A8}"), "廚");
        replaces.put(Pattern.compile("\\x{53F7}"), "號");
        replaces.put(Pattern.compile("\\x{732A}"), "豬");
        replaces.put(Pattern.compile("\\x{58E0}"), "壟");
        replaces.put(Pattern.compile("\\x{7551}"), "煙");
        replaces.put(Pattern.compile("\\x{9424}"), "鼎");
        replaces.put(Pattern.compile("\\x{732B}"), "貓");
        replaces.put(Pattern.compile("\\x{6BBB}"), "殼");
        replaces.put(Pattern.compile("\\x{5CBA}"), "苓");
        replaces.put(Pattern.compile("\\x{8534}"), "麻");
        replaces.put(Pattern.compile("\\x{575F}"), "汶");
        replaces.put(Pattern.compile("\\x{270FD}"), "應");
        replaces.put(Pattern.compile("\\x{26C21}"), "那");
        replaces.put(Pattern.compile("\\x{21D9B}"), "卡");
        replaces.put(Pattern.compile("\\x{2555F}"), "漏");
        //以下為置換常常混淆的詞
        replaces.put(Pattern.compile("\\x{82B1}\\x{9023}"), "花蓮");
        replaces.put(Pattern.compile("\\d+(?=\\x{5C6F})"), "村");
        replaces.put(Pattern.compile("\\x{65B0}\\x{5C6F}"), "新村");
        replaces.put(Pattern.compile("\\x{79D1}\\x{5C6F}"), "科村");<commit_msg>增加一些罕用字的轉換<commit_after>package twzip.model;

import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 儲存地址的數值資料
 *
 * @author <NAME>
 */
public class Address {

    private static final long serialVersionUID = 5452467653824560048L;
    private int ln = 0;
    private int lane = 0;
    private int addLane = 0;
    private int alley = 0;
    private int addAlley = 0;
    private int number = 0;
    private int addnum = 0;
    private String build = "";
    private int floor = 0;

    private static final Map<Pattern, String> replaces;

    private static final Pattern p71 = Pattern.compile("(\\d+)\\x{4E4B}(\\d+)\\x{4E4B}\\d+\\x{5DF7}");//xx之xx之xx巷
    private static final Pattern p72 = Pattern.compile("(\\d+)\\x{4E4B}(\\d+)\\x{5DF7}");//xx之xx巷
    private static final Pattern p73 = Pattern.compile("(\\d+)\\x{5DF7}");//巷
    private static final Pattern p81 = Pattern.compile("(\\d+)\\x{4E4B}(\\d+)\\x{5F04}");//xx之xx弄
    private static final Pattern p82 = Pattern.compile("(\\d+)\\x{5F04}");//弄
    private static final Pattern p91 = Pattern.compile("(\\d+)[\\x{4E4B}\\x{FF0D}-](\\d+)\\x{865F}[\\x{4E4B}\\x{FF0D}-]\\d+[^\\x{6A13}Ff]");//xx 之 xx 號 之 xx[^樓]
    private static final Pattern p92 = Pattern.compile("(\\d+)\\x{865F}[\\x{4E4B}\\x{FF0D}-](\\d+)[^\\x{6A13}Ff]");//xx 號之 xx[^樓]
    private static final Pattern p93 = Pattern.compile("(\\d+)[\\x{4E4B}\\x{FF0D}-](\\d+)[\\x{4E4B}\\x{FF0D}-]\\d+\\x{865F}");//xx 之 xx 之 xx號
    private static final Pattern p94 = Pattern.compile("(\\d+)[\\x{4E4B}\\x{FF0D}-](\\d+)\\x{865F}");//xx 之 xx號
    private static final Pattern p95 = Pattern.compile("(\\d+)\\x{865F}");//xx 號
    private static final Pattern pF1 = Pattern.compile("(\\p{InCJKUnifiedIdeographs}+)?\\x{5730}\\x{4E0B}(-?\\d+)\\x{6A13}");//樓
    private static final Pattern pF2 = Pattern.compile("(\\p{InCJKUnifiedIdeographs}+[^\\x{6A13}])?[bB](-?\\d+)[fF]?");
    private static final Pattern pF3 = Pattern.compile("(\\p{InCJKUnifiedIdeographs}+)?(-?\\d+)[\\x{6A13}fF]");
    private static final Pattern pNoNum = Pattern.compile("[^\\x{865F}].*\\d+$");//缺少號又以數字結尾

    static {
        replaces = new LinkedHashMap<>();
        //<editor-fold defaultstate="collapsed" desc="replace patterns">
        String one2nine = "[\\x{4E00}\\x{4E8C}\\x{4E09}\\x{56DB}\\x{4E94}\\x{516D}\\x{4E03}\\x{516B}\\x{4E5D}]";
        replaces.put(Pattern.compile("[\\x{3000}\\s]+"), "");
        replaces.put(Pattern.compile("(?<=" + one2nine + ")\\x{5341}(?=" + one2nine + ")"), "");
        replaces.put(Pattern.compile("(?<=" + one2nine + ")\\x{5341}"), "0");
        replaces.put(Pattern.compile("\\x{5341}(?=" + one2nine + ")"), "1");
        replaces.put(Pattern.compile("\\x{5341}"), "10");
        replaces.put(Pattern.compile("\\x{FF10}"), "0");
	replaces.put(Pattern.compile("[\\x{3127}\\x{4E00}\\x{FF11}]"), "1");
        replaces.put(Pattern.compile("[\\x{4E8C}\\x{FF12}]"), "2");
        replaces.put(Pattern.compile("[\\x{4E09}\\x{FF13}]"), "3");
        replaces.put(Pattern.compile("[\\x{56DB}\\x{FF14}]"), "4");
        replaces.put(Pattern.compile("[\\x{4E94}\\x{FF15}]"), "5");
        replaces.put(Pattern.compile("[\\x{516D}\\x{FF16}]"), "6");
        replaces.put(Pattern.compile("[\\x{4E03}\\x{FF17}]"), "7");
        replaces.put(Pattern.compile("[\\x{516B}\\x{FF18}]"), "8");
        replaces.put(Pattern.compile("[\\x{4E5D}\\x{FF19}]"), "9");
        replaces.put(Pattern.compile("\\x{FF08}"), "(");
        replaces.put(Pattern.compile("\\x{FF09}"), ")");
        replaces.put(Pattern.compile("\\x{81FA}"), "台");
        replaces.put(Pattern.compile("\\x{5553}"), "啟");
        replaces.put(Pattern.compile("\\x{5869}"), "鹽");
        replaces.put(Pattern.compile("\\x{62D5}"), "托");
        replaces.put(Pattern.compile("\\x{5ECD}"), "廓");
        replaces.put(Pattern.compile("\\x{78D8}"), "窯");
        replaces.put(Pattern.compile("\\x{7AB0}"), "窯");
        replaces.put(Pattern.compile("\\x{8218}"), "館");
        replaces.put(Pattern.compile("\\x{90A8}"), "村");
        replaces.put(Pattern.compile("\\x{5CEF}"), "峰");
        replaces.put(Pattern.compile("\\x{7AEA}"), "豎");
        replaces.put(Pattern.compile("\\x{7F97}"), "羌");
        replaces.put(Pattern.compile("\\x{7067}"), "灩");
        replaces.put(Pattern.compile("\\x{811A}"), "腳");
        replaces.put(Pattern.compile("\\x{920E}"), "鉤");
        replaces.put(Pattern.compile("\\x{7282}"), "犁");
        replaces.put(Pattern.compile("\\x{5DFF}"), "市");
        replaces.put(Pattern.compile("\\x{8914}"), "福");
        replaces.put(Pattern.compile("\\x{6E76}"), "泉");
        replaces.put(Pattern.compile("\\x{83D3}"), "果");
        replaces.put(Pattern.compile("\\x{5754}"), "湳");
        replaces.put(Pattern.compile("\\x{5742}"), "板");
        replaces.put(Pattern.compile("\\x{5E99}"), "廟");
        replaces.put(Pattern.compile("\\x{6B0D}"), "舊");
        replaces.put(Pattern.compile("\\x{78DC}"), "祭");
        replaces.put(Pattern.compile("\\x{7866}"), "弄");
        replaces.put(Pattern.compile("\\x{7B0B}"), "尹");
        replaces.put(Pattern.compile("\\x{713F}"), "庚");
        replaces.put(Pattern.compile("\\x{8EAD}"), "耽");
        replaces.put(Pattern.compile("\\x{9DC4}"), "雞");
        replaces.put(Pattern.compile("\\x{9B98}"), "代");
        replaces.put(Pattern.compile("\\x{5223}"), "台");
        replaces.put(Pattern.compile("\\x{53A6}"), "夏");
        replaces.put(Pattern.compile("\\x{53CC}"), "雙");
        replaces.put(Pattern.compile("\\x{5D75}"), "時");
        replaces.put(Pattern.compile("\\x{5E92}"), "庄");
        replaces.put(Pattern.compile("\\x{6898}"), "見");
        replaces.put(Pattern.compile("\\x{69FA}"), "康");
        replaces.put(Pattern.compile("\\x{7858}"), "回");
        replaces.put(Pattern.compile("\\x{8471}"), "蔥");
        replaces.put(Pattern.compile("\\x{5C2B}"), "尪");
        replaces.put(Pattern.compile("\\x{8289}"), "竿");
        replaces.put(Pattern.compile("\\x{53A8}"), "廚");
        replaces.put(Pattern.compile("\\x{53F7}"), "號");
        replaces.put(Pattern.compile("\\x{732A}"), "豬");
        replaces.put(Pattern.compile("\\x{58E0}"), "壟");
        replaces.put(Pattern.compile("\\x{7551}"), "煙");
        replaces.put(Pattern.compile("\\x{9424}"), "鼎");
        replaces.put(Pattern.compile("\\x{732B}"), "貓");
        replaces.put(Pattern.compile("\\x{6BBB}"), "殼");
        replaces.put(Pattern.compile("\\x{5CBA}"), "苓");
        replaces.put(Pattern.compile("\\x{8534}"), "麻");
        replaces.put(Pattern.compile("\\x{575F}"), "汶");
        replaces.put(Pattern.compile("\\x{270FD}"), "應");
        replaces.put(Pattern.compile("\\x{26C21}"), "那");
        replaces.put(Pattern.compile("\\x{21D9B}"), "卡");
        replaces.put(Pattern.compile("\\x{2555F}"), "漏");
        replaces.put(Pattern.compile("\\x{80C6}"), "膽");
        replaces.put(Pattern.compile("\\x{54CD}"), "響");
        replaces.put(Pattern.compile("\\x{6052}"), "恆");
        replaces.put(Pattern.compile("\\x{2B518}"), "閂");
        replaces.put(Pattern.compile("\\x{7553}"), "沓");
        replaces.put(Pattern.compile("\\x{7B0B}"), "筍");
        replaces.put(Pattern.compile("\\x{68B9}"), "檳");
        replaces.put(Pattern.compile("\\x{25FC4}"), "紙");
        replaces.put(Pattern.compile("\\x{4E80}"), "龜");
        replaces.put(Pattern.compile("\\x{621E}"), "戛");
        replaces.put(Pattern.compile("\\x{920E}"), "勾");
        replaces.put(Pattern.compile("\\x{583A}"), "界");
        replaces.put(Pattern.compile("\\x{8421}"), "箔");
        replaces.put(Pattern.compile("\\x{2137C}"), "塗");
        replaces.put(Pattern.compile("\\x{756c}"), "舍");
        replaces.put(Pattern.compile("\\x{d858}"), "罩");
        replaces.put(Pattern.compile("\\x{5d75}"), "時");
        replaces.put(Pattern.compile("\\x{7aea}"), "豎");
        replaces.put(Pattern.compile("\\x{7347}"), "猐");
        replaces.put(Pattern.compile("\\x{49df}"), "陷");
        replaces.put(Pattern.compile("\\x{69fa}"), "康");
        replaces.put(Pattern.compile("\\x{5ecd}"), "部");
        replaces.put(Pattern.compile("\\x{76b7}"), "鼓");
        replaces.put(Pattern.compile("\\x{d848}"), "廩");
        replaces.put(Pattern.compile("\\x{d863}"), "隙");
        replaces.put(Pattern.compile("\\x{d867}"), "月");
        replaces.put(Pattern.compile("\\x{564d}"), "焦");
        replaces.put(Pattern.compile("\\x{7ab0}"), "窯");
        replaces.put(Pattern.compile("\\x{78d8}"), "嗂");
        replaces.put(Pattern.compile("\\x{95a2}"), "關");
        replaces.put(Pattern.compile("\\x{9b98}"), "代");
        replaces.put(Pattern.compile("\\x{78dc}"), "祭");
        replaces.put(Pattern.compile("\\x{d855}"), "漏");
        replaces.put(Pattern.compile("\\x{d855}"), "槽");
        replaces.put(Pattern.compile("\\x{d845}"), "層");
        replaces.put(Pattern.compile("\\x{85d4}"), "寮");
        replaces.put(Pattern.compile("\\x{58e0}"), "壟");
        replaces.put(Pattern.compile("\\x{d86d}"), "桀");
        replaces.put(Pattern.compile("\\x{d85c}"), "應");
        replaces.put(Pattern.compile("\\x{9dc4}"), "雞");
        replaces.put(Pattern.compile("\\x{6b0d}"), "舊");
        replaces.put(Pattern.compile("\\x{d867}"), "逮");
        replaces.put(Pattern.compile("\\x{945b}"), "礦");
        replaces.put(Pattern.compile("\\x{7067}"), "艷");
        replaces.put(Pattern.compile("\\x{d84d}"), "舊");
        replaces.put(Pattern.compile("\\x{52b9}"), "效");
        replaces.put(Pattern.compile("\\x{6e29}"), "溫");
        replaces.put(Pattern.compile("\\x{654d}"), "敘");
        replaces.put(Pattern.compile("\\x{d855}"), "塔");
        replaces.put(Pattern.compile("\\x{5367}"), "臥");
        replaces.put(Pattern.compile("\\x{51c9}"), "涼");
        //以下為置換常常混淆的詞
        replaces.put(Pattern.compile("\\x{82B1}\\x{9023}"), "花蓮");
        replaces.put(Pattern.compile("\\d+(?=\\x{5C6F})"), "村");
        replaces.put(Pattern.compile("\\x{65B0}\\x{5C6F}"), "新村");
        replaces.put(Pattern.compile("\\x{79D1}\\x{5C6F}"), "科村");
{'fraction_non_alphanumeric': 0.2729444671056465, 'fraction_numerical': 0.058388205815511914, 'mean_word_length': 3.1848329675688856, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '1067958', 'n_tokens_mistral': 7401, 'n_tokens_neox': 6961, 'n_words': 767}