⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productannotator.java

📁 为了对数据进行处理
💻 JAVA
字号:
package com.backstopmedia.uima.tutorial;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.ibm.uima.analysis_engine.ResultSpecification;
import com.ibm.uima.analysis_engine.annotator.AnnotatorProcessException;
import com.ibm.uima.analysis_engine.annotator.JTextAnnotator_ImplBase;
import com.ibm.uima.jcas.impl.JCas;

public class ProductAnnotator  extends JTextAnnotator_ImplBase {
	  
	  public void process(JCas aJCas, ResultSpecification aResultSpec)
	                     throws AnnotatorProcessException {
	    String txt = aJCas.getDocumentText();

        Pattern UniverseProductNumbers = Pattern.compile("\\b[U][A-Z][A-Z]-\\d\\d\\d\\d\\d\\b");
	    Matcher matcher = UniverseProductNumbers.matcher(txt);
	    int pos = 0;
	    while (matcher.find(pos)) {
	      ProductNumber productNumberAnnotation = new ProductNumber(aJCas);

	      productNumberAnnotation.setProductLine("Universe");
	      productNumberAnnotation.setBegin(matcher.start());
	      productNumberAnnotation.setEnd(matcher.end());

	      productNumberAnnotation.addToIndexes();
	      pos = matcher.end();
	    }

		Pattern BeyondProductNumbers = Pattern.compile("\\b[B][A-Z][A-Z]-\\d\\d\\d\\b");;
	    matcher = BeyondProductNumbers.matcher(txt);
	    pos = 0;
	    while (matcher.find(pos))
	    {
	      ProductNumber productNumberAnnotation = new ProductNumber(aJCas);

	      productNumberAnnotation.setProductLine("Beyond");
	      productNumberAnnotation.setBegin(matcher.start());
	      productNumberAnnotation.setEnd(matcher.end());

	      productNumberAnnotation.addToIndexes();
	      pos = matcher.end();
	    }     
	  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -