- # # -*- coding:utf-8 -*-
- # Author:wancong
- # Date: 2018-04-30
-
- # 在import pyhanlp之前编译自己的Java class,并放入pyhanlp/static中
- import os
-
- from pyhanlp.static import STATIC_ROOT, HANLP_JAR_PATH
-
- java_code_path = os.path.join(STATIC_ROOT, 'MyFilter.java')
- with open(java_code_path, 'w') as out:
- java_code = """
- import com.hankcs.hanlp.dictionary.stopword.CoreStopWordDictionary;
- import com.hankcs.hanlp.dictionary.stopword.Filter;
- import com.hankcs.hanlp.seg.common.Term;
-
- public class MyFilter implements Filter
- {
- public boolean shouldInclude(Term term)
- {