Returns the association of the two words on a scale of 0 to 1.

@return the assocation or {@code null} if either {@code word1} or {@code
word2} are not in the semantic space
4808
protected Double computeAssociation(SemanticSpace sspace, 
                                        String word1, String word2) {
        Vector v1 = sspace.getVector(word1);
        Vector v2 = sspace.getVector(word2);
        if (v1 == null || v2 == null)
            return null;
        
        // Find the ranks of each of the two words to each other
        double rank1 = findRank(sspace, word1, word2);
        double rank2 = findRank(sspace, word2, word1);
        return 2d / (rank1 + rank2);
    }
1297039
@Override
    public Collection<String> wordsNearestSum(Collection<String> positive, Collection<String> negative, int top) {
        INDArray words = Nd4j.create(lookupTable.layerSize());
        //    Set<String> union = SetUtils.union(new HashSet<>(positive), new HashSet<>(negative));
        for (String s : positive)
            words.addi(lookupTable.vector(s));


        for (String s : negative)
            words.addi(lookupTable.vector(s).mul(-1));

        return wordsNearestSum(words, top);
    }
1224118
@Override
    public double similarScore(List<Word> words1, List<Word> words2) {
        if(words1 == null || words2 == null){
            //只要有一个文本为null，规定相似度分值为0，表示完全不相等
            return 0.0;
        }
        if(words1.isEmpty() && words2.isEmpty()){
            //如果两个文本都为空，规定相似度分值为1，表示完全相等
            return 1.0;
        }
        if(words1.isEmpty() || words2.isEmpty()){
            //如果一个文本为空，另一个不为空，规定相似度分值为0，表示完全不相等
            return 0.0;
        }
        //输出词列表信息
        if(LOGGER.isDebugEnabled()) {
            LOGGER.debug("词列表1：");
            LOGGER.debug("\t" + words1);
            LOGGER.debug("词列表2：");
            LOGGER.debug("\t" + words2);
        }
        double score = scoreImpl(words1, words2);
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("分值："+score);
        }
        score = (int)(score*1000000+0.5)/(double)1000000;
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("取六位小数，四舍五入，分值："+score);
        }
        return score;
    }
122519
public final int getRelativeY() {
		NativeEvent e = getNativeEvent();
		Element target = getTarget();

		return e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() +
				target.getOwnerDocument().getScrollTop();
	}
52569
@Override
    protected double scoreImpl(List<Word> words1, List<Word> words2) {
        //用词频来标注词的权重
        taggingWeightWithWordFrequency(words1, words2);
        //构造权重快速搜索容器
        Map<String, Float> weights1 = toFastSearchMap(words1);
        Map<String, Float> weights2 = toFastSearchMap(words2);
        //所有的不重复词
        Set<Word> words = new HashSet<>();
        words.addAll(words1);
        words.addAll(words2);
        //向量的维度为words的大小，每一个维度的权重是词频
        //manhattanDistance=|x1-x2|+|y1-y2|
        AtomicFloat manhattanDistance = new AtomicFloat();
        //计算
        words
            .parallelStream()
            .forEach(word -> {
                Float x1 = weights1.get(word.getText());
                Float x2 = weights2.get(word.getText());
                if (x1 == null) {
                    x1 = 0f;
                }
                if (x2 == null) {
                    x2 = 0f;
                }
                //|x1-x2|
                float oneOfTheDimension = Math.abs(x1 - x2);
                //+
                manhattanDistance.addAndGet(oneOfTheDimension);
            });
        double score = 0;
        if(manhattanDistance.get() == 0){
            //距离为0，表示完全相同
            score = 1.0;
        }else {
            //使用BigDecimal保证精确计算浮点数
            //score = 1 / (double)(manhattanDistance.get()+1);
            score = BigDecimal.valueOf(1).divide(BigDecimal.valueOf(manhattanDistance.get()+1), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
        }
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("文本1和文本2的曼哈顿距离："+manhattanDistance.get());
            LOGGER.debug("文本1和文本2的相似度分值：1 / (double)("+manhattanDistance.get()+"+1)="+score);
        }
        return score;
    }
280195
public synchronized long term() {
    Map.Entry<Long, Long> entry = terms.lastEntry();
    return entry != null ? entry.getValue() : 0;
  }
31330
@Nullable
    public String getMnemonicString() {
        return mnemonicCode != null ? Utils.SPACE_JOINER.join(mnemonicCode) : null;
    }
206385
int searchVocab(String word)
    {
        if (word == null) return -1;
        Integer pos = vocabIndexMap.get(word);
        return pos == null ? -1 : pos.intValue();
    }
593830
public java.util.List<AssociationExecution> getAssociationExecutions() {
        if (associationExecutions == null) {
            associationExecutions = new com.amazonaws.internal.SdkInternalList<AssociationExecution>();
        }
        return associationExecutions;
    }
1246259
@Override
    public boolean isSameState(Word<I> input1, S s1, Word<I> input2, S s2) {
        return s1.equals(s2);
    }
1094274
@Override
    public Collection<String> wordsNearestSum(INDArray words, int top) {

        if (lookupTable instanceof InMemoryLookupTable) {
            InMemoryLookupTable l = (InMemoryLookupTable) lookupTable;
            INDArray syn0 = l.getSyn0();
            INDArray weights = syn0.norm2(0).rdivi(1).muli(words);
            INDArray distances = syn0.mulRowVector(weights).sum(1);
            INDArray[] sorted = Nd4j.sortWithIndices(distances, 0, false);
            INDArray sort = sorted[0];
            List<String> ret = new ArrayList<>();

            // FIXME: int cast
            if (top > sort.length())
                top = (int) sort.length();
            //there will be a redundant word
            int end = top;
            for (int i = 0; i < end; i++) {
                String add = vocabCache.wordAtIndex(sort.getInt(i));
                if (add == null || add.equals("UNK") || add.equals("STOP")) {
                    end++;
                    if (end >= sort.length())
                        break;
                    continue;
                }
                ret.add(vocabCache.wordAtIndex(sort.getInt(i)));
            }
            return ret;
        }

        Counter<String> distances = new Counter<>();

        for (String s : vocabCache.words()) {
            INDArray otherVec = lookupTable.vector(s);
            double sim = Transforms.cosineSim(words, otherVec);
            distances.incrementCount(s, (float) sim);
        }

        distances.keepTopNElements(top);
        return distances.keySet();
    }
401802
public boolean isAssociation()
    {
        return persistenceAttribType.equals(PersistentAttributeType.MANY_TO_MANY)
                || persistenceAttribType.equals(PersistentAttributeType.MANY_TO_ONE)
                || persistenceAttribType.equals(PersistentAttributeType.ONE_TO_MANY)
                || persistenceAttribType.equals(PersistentAttributeType.ONE_TO_ONE);
    }
800132
public String cluster() {
    if (d1 == 0) {
      // Application portion is empty
      return null;
    } else {
      return (dN > 0 && dN == asg.length()) ? asg() : substr(asg, 0, dN);
    }
  }
265437
private String ifNull(){

        if(params.length != 2){
            throw new IllegalArgumentException("Wrong number of Parameters for if null expression");
        }

        final String field1 = record.getValueByFieldName(params[0]);
        if (!field1.isEmpty()){
            return field1;
        }
        final String field2 = record.getValueByFieldName(params[1]);
        return field2;
    }
243700
public java.util.List<String> getAssociationIds() {
        if (associationIds == null) {
            associationIds = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return associationIds;
    }
275376
public String getMap(String word){
		if(nameMap==null||!nameMap.containsKey(word))
			return word;
		else
			return nameMap.get(word);
	}
838439
@SafeVarargs
    public static <T> T coalesceNonEmpty( final T ... things )
    {
        if( things == null || things.length == 0 )
        {
            return null;
        }

        for( T    thing : things )
        {
            if( thing instanceof CharSequence )
            {
                if( ! StringUtils.isBlank( (CharSequence) thing ) )
                {
                    return thing;
                }
            }
            else if( thing != null )
            {
                return thing;
            }
        }

        return null;
    }