Search in sources :

Example 1 with PersonAttrLibrary

use of org.ansj.library.name.PersonAttrLibrary 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

Entry (java.util.Map.Entry)1 AnsjItem (org.ansj.domain.AnsjItem)1 PersonNatureAttr (org.ansj.domain.PersonNatureAttr)1 TermNatures (org.ansj.domain.TermNatures)1 PersonAttrLibrary (org.ansj.library.name.PersonAttrLibrary)1