@Test public void test1() throws Exception { TableSchema schema = new TableSchema(new String[] {"sentence"}, new TypeInformation <?>[] {Types.STRING()}); Params params = new Params() .set(SegmentParams.SELECTED_COL, "sentence"); SegmentMapper mapper = new SegmentMapper(schema, params); mapper.open(); assertEquals(mapper.map(Row.of("我们辅助用户简单快速低成本低风险的实现系统权限安全管理")).getField(0), "我们 辅助 用户 简单 快速 低成本 低 风险 的 实现 系统 权限 安全 管理"); assertEquals(mapper.getOutputSchema(), schema); }
@Override public void open(){ segmentor = new JiebaSegmenter(); String[] userDefinedDict = this.params.get(SegmentParams.USER_DEFINED_DICT); if (null != userDefinedDict) { for(String word : userDefinedDict){ segmentor.addUserWord2Dict(word); } } }
SegmentMapper extends SISOMapper { @Override public void open(){ segmentor = new JiebaSegmenter(); String[] userDefinedDict = this.params.get(SegmentParams.USER_DEFINED_DICT); if (null != userDefinedDict) { for(String word : userDefinedDict){ segmentor.addUserWord2Dict(word); } } } }
SegmentMapper extends SISOMapper { @Override public void open(){ segmentor = new JiebaSegmenter(); String[] userDefinedDict = this.params.get(SegmentParams.USER_DEFINED_DICT); if (null != userDefinedDict) { for(String word : userDefinedDict){ segmentor.addUserWord2Dict(word); } } } SegmentMapper(TableSchema dataSchema, Params params); }
SegmentMapper extends SISOMapper { @Override public void open(){ segmentor = new JiebaSegmenter(); String[] userDefinedDict = this.params.get(SegmentParams.USER_DEFINED_DICT); if (null != userDefinedDict) { for(String word : userDefinedDict){ segmentor.addUserWord2Dict(word); } } } SegmentMapper(TableSchema dataSchema, Params params); @Override void open(); }
SegmentMapper extends SISOMapper { @Override public void open(){ segmentor = new JiebaSegmenter(); String[] userDefinedDict = this.params.get(SegmentParams.USER_DEFINED_DICT); if (null != userDefinedDict) { for(String word : userDefinedDict){ segmentor.addUserWord2Dict(word); } } } SegmentMapper(TableSchema dataSchema, Params params); @Override void open();  }