org.ansj.recognition.impl.EmailRecognition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ansj_seg Show documentation
Show all versions of ansj_seg Show documentation
best java chinese word seg !
package org.ansj.recognition.impl;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.ansj.domain.Result;
import org.ansj.domain.Term;
import org.ansj.recognition.Recognition;
/**
* 电子邮箱抽取
*
* @author ansj
*
*/
public class EmailRecognition implements Recognition{
private static Map FEATURE = new HashMap();
private static final String NOT_HEAD = "NOT";
private static final String NATURE_HEAD = "nature:";
private static final String ALL = "ALL";
static {
FEATURE.put("-", NOT_HEAD);
FEATURE.put("_", NOT_HEAD);
FEATURE.put(".", NOT_HEAD);
FEATURE.put(NATURE_HEAD + "en", ALL);
FEATURE.put(NATURE_HEAD + "m", ALL);
}
public void recognition(Result result) {
List terms = result.getTerms() ;
for (Term term : terms) {
if (!"@".equals(term.getName())) {
continue;
}
}
for (Iterator iterator = terms.iterator(); iterator.hasNext();) {
Term term = (Term) iterator.next();
if (term.getName() == null) {
iterator.remove();
}
}
}
}