Search in sources :

Example 6 with TermNatures

use of org.ansj.domain.TermNatures in project ansj_seg by NLPchina.

the class UserDefineRecognition method makeNewTerm.

private void makeNewTerm() {
    StringBuilder sb = new StringBuilder();
    for (int j = offe; j <= endOffe; j++) {
        if (terms[j] == null) {
            continue;
        } else {
            sb.append(terms[j].getName());
        }
    }
    TermNatures termNatures = new TermNatures(new TermNature(tempNature, tempFreq));
    Term term = new Term(sb.toString(), offe, termNatures);
    term.selfScore(-1 * tempFreq);
    TermUtil.insertTerm(terms, term, type);
}
Also used : TermNatures(org.ansj.domain.TermNatures) Term(org.ansj.domain.Term) TermNature(org.ansj.domain.TermNature)

Example 7 with TermNatures

use of org.ansj.domain.TermNatures in project ansj_seg by NLPchina.

the class DATDictionary method personNameFull.

private static void personNameFull(DoubleArrayTire dat) throws NumberFormatException, IOException {
    HashMap<String, PersonNatureAttr> personMap = new PersonAttrLibrary().getPersonMap();
    AnsjItem ansjItem = null;
    // 人名词性补录
    Set<Entry<String, PersonNatureAttr>> entrySet = personMap.entrySet();
    char c = 0;
    String temp = null;
    for (Entry<String, PersonNatureAttr> entry : entrySet) {
        temp = entry.getKey();
        if (temp.length() == 1 && (ansjItem = (AnsjItem) dat.getDAT()[temp.charAt(0)]) == null) {
            ansjItem = new AnsjItem();
            ansjItem.setBase(c);
            ansjItem.setCheck(-1);
            ansjItem.setStatus((byte) 3);
            ansjItem.setName(temp);
            dat.getDAT()[temp.charAt(0)] = ansjItem;
        } else {
            ansjItem = dat.getItem(temp);
        }
        if (ansjItem == null) {
            continue;
        }
        if ((ansjItem.termNatures) == null) {
            if (temp.length() == 1 && temp.charAt(0) < 256) {
                ansjItem.termNatures = TermNatures.NULL;
            } else {
                ansjItem.termNatures = new TermNatures(TermNature.NR);
            }
        }
        ansjItem.termNatures.setPersonNatureAttr(entry.getValue());
    }
}
Also used : Entry(java.util.Map.Entry) TermNatures(org.ansj.domain.TermNatures) PersonNatureAttr(org.ansj.domain.PersonNatureAttr) AnsjItem(org.ansj.domain.AnsjItem) PersonAttrLibrary(org.ansj.library.name.PersonAttrLibrary)

Aggregations

TermNatures (org.ansj.domain.TermNatures)7 Term (org.ansj.domain.Term)5 TermNature (org.ansj.domain.TermNature)3 ArrayList (java.util.ArrayList)2 AnsjItem (org.ansj.domain.AnsjItem)2 Entry (java.util.Map.Entry)1 LearnTool (org.ansj.dic.LearnTool)1 NewWord (org.ansj.domain.NewWord)1 PersonNatureAttr (org.ansj.domain.PersonNatureAttr)1 Result (org.ansj.domain.Result)1 PersonAttrLibrary (org.ansj.library.name.PersonAttrLibrary)1 AsianPersonRecognition (org.ansj.recognition.arrimpl.AsianPersonRecognition)1 ForeignPersonRecognition (org.ansj.recognition.arrimpl.ForeignPersonRecognition)1 NewWordRecognition (org.ansj.recognition.arrimpl.NewWordRecognition)1 NumRecognition (org.ansj.recognition.arrimpl.NumRecognition)1 UserDefineRecognition (org.ansj.recognition.arrimpl.UserDefineRecognition)1 NatureRecognition (org.ansj.recognition.impl.NatureRecognition)1 Graph (org.ansj.util.Graph)1 GetWord (org.nlpcn.commons.lang.tire.GetWord)1 MapCount (org.nlpcn.commons.lang.util.MapCount)1