# cache-map **Repository Path**: shanhais/cache-map ## Basic Information - **Project Name**: cache-map - **Description**: 利用倒排索引(简易实现)实现关联名称映射 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-11-08 - **Last Updated**: 2024-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README **成功率**:约94.2% **主要思路**:分词 + 倒排索引 + 打分 # 一、代码构成 ## 主要类 | 类 | 说明 | | --- | --- | | ReverseIndexMap | 实现倒排索引映射 | | CarBrand | 进行一次分类后的车品牌列表 | | CarBrandPool | 提供映射及给车品牌进行一次分类的方法 | ### ReverseIndexMap #### 属性 | 属性 | 说明 | | --- | --- | | Map> reverseIndexMap | 存储倒排索引 | #### 方法: | 方法 | 说明 | | --- | --- | | void setReverseIndexMap(List list) | 为list创建倒排索引 | ### CarBrand #### 属性 | 属性 | 说明 | | --- | --- | | List list | 按车品牌进行一次分类后的车列表,比如说一个CarBrand是大众的,另一个是宝马的 | | ReverseIndexMap reverseIndexMap | list对应的倒排索引 | #### 方法 | 方法 | 说明 | | --- | --- | | void setReverseIndexMap() | 为list创建倒排索引 | ### CarBrandPool #### 属性 | 属性 | 说明 | | --- | --- | | Map carBrandPoolMap | 存储车品牌对应的CarBrand | | Map carBrandNoMap | 存储车型匹配后剩余的CarBrand,用于再次匹配 | #### 方法 | 方法 | 说明 | | --- | --- | | void setCarBrandPoolMap(List list) | 将原始list进行一次分类,存入carBrandPoolMap | | void dealMap(Map map, CarBrandPool carBrandPool2) | 和carBrandPool2匹配,将匹配结果存入map中 | | void dealAgain(Map map, CarBrandPool carBrandPool2) | 检查是否是要再次进行匹配 | | static void dealMap(Map map, List list1, List list2) | 对外提供的方法,用于处理list1和list2的匹配关系,并将匹配结果存入map中 | ## Utils工具包 | 包 | 说明 | | --- | --- | | excel | 解析Excel文件 | | participle | 分词工具类:包含Jieba分词器、及定制分词器 | ## 使用示例 1. 解析Excel获得list1和list2 2. 选择分词器:可另外自定义分词器,如果不设置,默认就是DivParticiple() 3. 处理映射关系 ```java public static final String FILE_PATH = "D:\\Gitee\\cache-map\\file\\车型名称映射.xlsx"; public static void main(String[] args) throws IOException { // 1. 解析Excel文件 List> mapList = ExcelUtils.getMapList(FILE_PATH); // 2. 选择分词器:可另外自定义分词器,如果不设置,默认就是DivParticiple() ParticipleFactory.setParticiple(new DivParticiple()); // 3. 处理映射 CarBrandPool.dealMap(map, mapList.get(0), mapList.get(1)); } ``` ## 二、部署项目到Linux ![image.png](https://cdn.nlark.com/yuque/0/2023/png/34874991/1699752689282-e89ea4c0-5872-486c-b59e-2095751c7f32.png#averageHue=%23a7e5b1&clientId=udae07cbe-99a9-4&from=paste&height=864&id=ubfc4b61c&originHeight=1080&originWidth=1909&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=1206010&status=done&style=none&taskId=u1e72792c-51c7-450d-bffe-8abcfb7efea&title=&width=1527.2) # 三、远程debug ![image.png](https://cdn.nlark.com/yuque/0/2023/png/34874991/1699752506898-07a46c7e-20e1-4bbc-9bac-36c6cac77d6e.png#averageHue=%2333373c&clientId=udae07cbe-99a9-4&from=paste&height=864&id=uef375290&originHeight=1080&originWidth=1920&originalType=binary&ratio=1.25&rotation=0&showTitle=false&size=389675&status=done&style=none&taskId=u6b0932fb-a26f-405f-8cd8-8ddc8bfe77c&title=&width=1536)