package com.taover.ai.init; import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.Resource; import org.springframework.stereotype.Component; import com.hankcs.hanlp.HanLP; import com.hankcs.hanlp.dictionary.CustomDictionary; import com.hankcs.hanlp.seg.Segment; import com.taover.ai.repository.RegionPcdsEntity; import com.taover.ai.repository.RegionPcdsRepo; @Component public class AddressSegment{ @Resource private RegionPcdsRepo regionPcdsRepo; private static Segment addressSegment; public static Segment getAddressSegment(){ if(addressSegment == null){ return HanLP.newSegment().enablePlaceRecognize(true).enableOffset(true).enableCustomDictionaryForcing(true); } return addressSegment; } @PostConstruct public void loadSegmentDict(){ //添加地址表地址库 List regionList = this.regionPcdsRepo.findListBySql("1=1"); for(int i=0; i