进行term合并,能合并空白字符

@param term
@param maxNature
188359
public Term merageWithBlank(Term to) {
        this.name = this.name + to.getName();
        this.realName = this.realName + to.getRealName();
        this.setTo(to.to);
        return this;
    }
625480
public void setDelete(Term term) {
    this.op = Op.DELETE;
    this.doc = null;
    this.term = term;
  }
1286964
public void setMaxScaled(double maxFeature)
    {
        if(Double.isNaN(maxFeature))
            throw new ArithmeticException("NaN is not a valid feature value");
        else if(maxFeature > 1)
            throw new ArithmeticException("Maximum possible feature value is 1, can not use " + maxFeature);
        else if(maxFeature <= minScaled)
            throw new ArithmeticException("Maximum feature value must be learger than the minimum");
        this.maxScaled = maxFeature;
    }
1177122
public boolean filter(Term term) {

		if (stop.size() > 0 && (stop.contains(term.getName()))) {
			return true;
		}

		if (natureStop.size() > 0 && (natureStop.contains(term.natrue().natureStr))) {
			return true;
		}

		if (regexList.size() > 0) {
			for (Pattern stopWordPattern : regexList) {
				if (stopWordPattern.matcher(term.getName()).matches()) {
					return true;
				}
			}
		}

		return false;
	}
289875
private boolean isMinuteTerm(final int currentTermIdx, final List<Term<Calendar>> terms) {
        
        final int termSize = terms.size();
        
        // 直前の項のチェック
        if(currentTermIdx -1 > 0) {
            DateTerm beforeTerm = null;
            for(int i=currentTermIdx-1; i >= 0; i--) {
                final Term<Calendar> term = terms.get(i);
                if(term instanceof DateTerm) {
                    beforeTerm = (DateTerm) term;
                    break;
                }
                
            }
            
            if(beforeTerm != null) {
                if(beforeTerm instanceof DateTerm.HourTerm || beforeTerm instanceof DateTerm.ElapsedHourTerm) {
                    return true;
                }
            }
            
        }
        
        // 直後の項のチェック
        if(currentTermIdx +1 < termSize) {
            DateTerm afterTerm = null;
            for(int i=currentTermIdx+1; i < termSize; i++) {
                final Term<Calendar> term = terms.get(i);
                if(term instanceof DateTerm) {
                    afterTerm = (DateTerm) term;
                    break;
                }
            }
            
            if(afterTerm != null) {
                if(afterTerm instanceof DateTerm.SecondTerm || afterTerm instanceof DateTerm.ElapsedSecondTerm) {
                    return true;
                }
            }
        }
        
        return false;
    }
272705
static <INN extends CoreMap & HasWord> void mergeTwoDocumentsByLongestSequence(
			List<INN> mainDocument, 
			List<INN> auxDocument, 
			Set<String> auxLabels, 
			String background ) {
		
		class Sequence {
			String type;
			int start;
			int len;
			Sequence (String type, int start, int len) {
				this.type = type;
				this.start = start;
				this.len = len;
			}
			public String toString() {
				return String.format("%s:%d:%d", type, start, len);
			}
		}
		
		List<Sequence> mainSeq = new ArrayList<>();
		List<Sequence> auxSeq = new ArrayList<>();
		
		String prevAnswer = "O";
		int len = 0;
		int id = -1;
		for (INN l : mainDocument) {
			id++;
			String answer = l.get(AnswerAnnotation.class);
			if (!answer.equals(prevAnswer)) {
				if (!prevAnswer.equals(background)) {
					mainSeq.add(new Sequence(prevAnswer, id-len, len));
				}
				if (!answer.equals(background)) {
					len = 1;
				}
				prevAnswer = answer;
			} else {
				len++;
			}			
		}
		if (!prevAnswer.equals(background)) mainSeq.add(new Sequence(prevAnswer, id-len+1, len));
		
		prevAnswer = "O";
		len = 0;
		id = -1;
		for (INN l : auxDocument) {
			id++;
			String answer = l.get(AnswerAnnotation.class);
			if (!answer.equals(prevAnswer)) {
				if (!prevAnswer.equals(background)) {
					auxSeq.add(new Sequence(prevAnswer, id-len, len));
				}
				if (!answer.equals(background)) {
					len = 1;
				}
				prevAnswer = answer;
			} else {
				len++;
			}			
		}
		if (!prevAnswer.equals(background)) auxSeq.add(new Sequence(prevAnswer, id-len+1, len));
		
		List<Sequence> resSeq = new ArrayList<>();
		Iterator<Sequence> mainSeqIt = mainSeq.iterator();
		Iterator<Sequence> auxSeqIt = auxSeq.iterator();
		Sequence main = null, aux = null, s = null;
		id = -1;
		if (mainSeqIt.hasNext()) main = mainSeqIt.next();
		if (auxSeqIt.hasNext()) aux = auxSeqIt.next();
		while(main != null || aux != null) {
			while (main != null && main.start < id) {
				if (mainSeqIt.hasNext()) main = mainSeqIt.next();
				else main = null;
			}
			
			while (aux != null && aux.start < id) {
				if (auxSeqIt.hasNext()) aux = auxSeqIt.next();
				else aux = null;
			}
			
			s = main;
			if (s == null 
					|| aux != null && (aux.start + aux.len - 1 < s.start
							|| s.len < aux.len
							&& (aux.start >= s.start && aux.start < s.start + s.len || s.start >= aux.start && s.start < aux.start + aux.len))) {
				s = aux;
			}
			if (s != null) {
				resSeq.add(s);
				id = s.start + s.len;
			}
		}
		
//		for (Sequence seq: mainSeq) System.err.print(seq + " ");
//		System.err.println();
//		for (Sequence seq: auxSeq) System.err.print(seq + " ");
//		System.err.println();
//		for (Sequence seq: resSeq) System.err.print(seq + " ");
//		System.err.println();
//		for (Sequence seq: resSeq) {
//			for (int i = seq.start; i < seq.start + seq.len; i++) {
//				System.err.printf("%s[%s/%s] ", mainDocument.get(i).word(), mainDocument.get(i).get(AnswerAnnotation.class), auxDocument.get(i).get(AnswerAnnotation.class));
//			}
//		}		
		for (INN l : mainDocument) l.set(AnswerAnnotation.class, background);
		for (Sequence seq : resSeq) {
			for (int i = seq.start; i < seq.start + seq.len; i++) {
				mainDocument.get(i).set(AnswerAnnotation.class, seq.type);
			}
		}
	}
583006
public static boolean setAttribute(String word, String natureWithFrequency)
    {
        CoreDictionary.Attribute attribute = CoreDictionary.Attribute.create(natureWithFrequency);
        return setAttribute(word, attribute);
    }
386738
public static void parsePattern(List<NS> nsList, List<Vertex> vertexList, final WordNet wordNetOptimum, final WordNet wordNetAll)
    {
//        ListIterator<Vertex> listIterator = vertexList.listIterator();
        StringBuilder sbPattern = new StringBuilder(nsList.size());
        for (NS ns : nsList)
        {
            sbPattern.append(ns.toString());
        }
        String pattern = sbPattern.toString();
        final Vertex[] wordArray = vertexList.toArray(new Vertex[0]);
        trie.parseText(pattern, new AhoCorasickDoubleArrayTrie.IHit<String>()
        {
            @Override
            public void hit(int begin, int end, String value)
            {
                StringBuilder sbName = new StringBuilder();
                for (int i = begin; i < end; ++i)
                {
                    sbName.append(wordArray[i].realWord);
                }
                String name = sbName.toString();
                // 对一些bad case做出调整
                if (isBadCase(name)) return;

                // 正式算它是一个名字
                if (HanLP.Config.DEBUG)
                {
                    System.out.printf("识别出地名：%s %s\n", name, value);
                }
                int offset = 0;
                for (int i = 0; i < begin; ++i)
                {
                    offset += wordArray[i].realWord.length();
                }
                wordNetOptimum.insert(offset, new Vertex(Predefine.TAG_PLACE, name, ATTRIBUTE, WORD_ID), wordNetAll);
            }
        });
    }
1333446
static String wildcardTypeToString(DocEnv env,
                                       Type.WildcardType wildThing, boolean full) {
        if (env.legacyDoclet) {
            return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
        }
        StringBuilder s = new StringBuilder("?");
        List<Type> bounds = getExtendsBounds(wildThing);
        if (bounds.nonEmpty()) {
            s.append(" extends ");
        } else {
            bounds = getSuperBounds(wildThing);
            if (bounds.nonEmpty()) {
                s.append(" super ");
            }
        }
        boolean first = true;   // currently only one bound is allowed
        for (Type b : bounds) {
            if (!first) {
                s.append(" & ");
            }
            s.append(TypeMaker.getTypeString(env, b, full));
            first = false;
        }
        return s.toString();
    }
1154232
private List<WComponent> getComponentsForTerm(final String term) {
		List<WComponent> childList = content.getComponentModel().getChildren();
		List<WComponent> result = new ArrayList<>();

		if (childList != null) {
			for (int i = 0; i < childList.size(); i++) {
				WComponent child = childList.get(i);

				if (term.equals(child.getTag())) {
					result.add(child);
				}
			}
		}

		return result;
	}
954716
def on_term(term_node)
      if defined? @separate_by_comma
        remove_instance_variable(:@separate_by_comma)
      end
      process(term_node.function)
      bel_string << '('
      term_node.arguments.each { |arg| process(arg) }
      bel_string << ')'
    end
394805
public void buildEnumConstantsSummary(XMLNode node, Content memberSummaryTree) {
        MemberSummaryWriter writer =
                memberSummaryWriters.get(VisibleMemberMap.Kind.ENUM_CONSTANTS);
        VisibleMemberMap visibleMemberMap =
                getVisibleMemberMap(VisibleMemberMap.Kind.ENUM_CONSTANTS);
        addSummary(writer, visibleMemberMap, false, memberSummaryTree);
    }
908122
public TermNatures getTermNatures(String word) {
        String[] params = null;
        // 获得词性 ， 先从系统辞典。在从用户自定义辞典
        AnsjItem ansjItem = DATDictionary.getItem(word);
        TermNatures tn = null;

        if (ansjItem != AnsjItem.NULL) {
            tn = ansjItem.termNatures;
        } else if ((params = getParams(word)) != null) {
            tn = new TermNatures(new TermNature(params[0], 1));
        } else if (WordAlert.isEnglish(word)) {
            tn = TermNatures.EN;
        } else if (WordAlert.isNumber(word)) {
            tn = TermNatures.M;
        } else {
            tn = TermNatures.NULL;
        }
        return tn;
    }
633114
private void foreign(Term[] terms) {
        List<Term> list = new ArrayList<>();

        Term term = null;
        Term temp = null;

        boolean mid = false;

        for (int i = 0; i < terms.length; i++) {
            term = terms[i];
            if (term == null) {
                continue;
            }

            if (DATDictionary.foreign(term)) {
                mid = "·".equals(term.getName());

                if (mid && list.size() == 0) { // mid 不能出现在名字首位
                    mid = false;
                    continue;
                }

                list.add(term);
                continue;
            }

            if (mid) {
                list = list.subList(0, list.size() - 1);
                mid = false;
            }

            if (list.size() == 0) {
                continue;
            }

            if (list.size() == 1) { //只有一个就别识别了
                list.clear();
                continue;
            }

            TermUtil.insertTerm(terms, list, TermNatures.NRF);

            list.clear();

        }

    }
566589
@Override
	public boolean addAll(Collection<? extends BooleanTerm> terms) {
		boolean modified = false;
		// a null booleanTerms means that the expression is
		// already true, so no need to modify it
		if (terms == null) {
			modified = booleanTerms != null;
			booleanTerms = null;
		} else if (booleanTerms != null) {
			for (BooleanTerm term : terms) {
				modified |= add(term);
			}
		}
		return modified;
	}
895790
public static void parseNature(Term term) {
        if (!Nature.NW.equals(term.natrue())) {
            return;
        }

        String name = term.getName();

        if (name.length() <= 3) {
            return;
        }

        // 是否是外国人名
        if (ForeignPersonRecognition.isFName(name)) {
            term.setNature(NatureLibrary.getNature("nrf"));
            return;
        }

        List<Term> subTerm = term.getSubTerm();

        // 判断是否是机构名
        term.setSubTerm(subTerm);
        Term first = subTerm.get(0);
        Term last = subTerm.get(subTerm.size() - 1);
        int[] is = companyMap.get(first.getName());
        int all = 0;

        is = companyMap.get(last.getName());
        if (is != null) {
            all += is[1];
        }

        if (all > 1000) {
            term.setNature(NatureLibrary.getNature("nt"));
            return;
        }
    }
1212165
public function wrapWords( $maxLineLength = 76 )
	{
		$this->content	= chunk_split( $this->content, $maxLineLength, Net_Mail::$delimiter );
	}