SOURCE

// 搜索匹配汉字
// let cn_input = "g'd's"
// let dict  = {
//     "g":'广0',
//     "guang":'广1',
//     "g'd's":'广东省0',
//     "guang'd's":'广东省1',
//     "guang'dong's":'广东省2',
//     "guang'dong'sheng":'广东省3',
//     "guan'dao'shi":'关刀石',
//     "g'da's":"高大上",
//     "zhu'hai":'珠海',
//     "zun'hua": "遵化",
// }
// let keyResult = Object.keys(dict).filter((key) => {
//             const keys = key.split("'");
//             const cn_inputList = cn_input.split("'");
//             const isLen = cn_inputList.length === keys.length;
//             if(!isLen) return
//             let result = true
//            for(let i =0;i<keys.length;i++){
//             let isEqualFirstCharacters = keys[i].charAt(0) === cn_inputList[i].charAt(0)
//                 if(!isEqualFirstCharacters){
//                     result = false
//                 }else{
//                      let list = []
//                      let keyItemList = keys[i].split('')
//                      let strList = cn_inputList[i].split('')
//                     for(let j=0;j<strList.length;j++){
//                         if(!strList[j]) break
//                         if(keyItemList[j] != strList[j]){
//                             result = false
//                         }
//                     }
//                 }
//            }
//             if (result) {
//                 return dict[key];
//             }
//         });
//  let strList = [];
//     for (let key of keyResult) {
//         strList.push(dict[key].split(","));
//     }
// strList = strList
//             .flat(2)
//             .sort((a, b) => {
//                 if (b.length>a.length) return -1;
//             })
//             .reverse();
// console.log(strList)

// 查找汉字拼音(key)
const singleDict = {
    "gao'diao'zuo'shi":'高调做事',
    "gao":'高告搞稿膏糕镐皋羔锆杲郜睾诰藁篙缟槁槔'
}
let text = '高'
let cn_input = "g'd'z's"

let itemList = []
for (let key in singleDict) {
   let value = singleDict[key]
        let valueList = value.split('')
        let item = valueList.find(item => item === text)
        if (item) {
            itemList.push(key)
        }
}
let str = ''
const cn_inputList = cn_input.split("'")
for (let i = 0; i < cn_inputList.length; i++) {
    let item = cn_inputList[i]
    for (let key of itemList) {
        let list = key.split('')
        for (let k = 0; k < list.length; k++) {
            if (key.charAt(k) === item.charAt(k)) {
                str = item
            }
        }
    }
}
let result = cn_inputList.filter(item=>item != str).join("'")
console.log('str',str,itemList,cn_inputList,result)
console 命令行工具 X clear

                    
>
console