Highlights consecutive occurrences of identifiers.

@param hashes   list of content identifier hashes to highlight
@param backward if true the first identifier is searched from the end of the expression
329771
public void highlightConsecutiveIdentifiers(List<Integer> hashes, boolean backward) {
        final int startPos = highlightFirstIdentifier(hashes.get(0), backward);
        if (startPos >= 0) {
            highlightRemainingIdentifiers(hashes.subList(1, hashes.size()), startPos);
        }
    }
1367964
function filterHashes( hashes )
{
  const validHashes = crypto.getHashes();

  return hashes.filter( hash => {
    if ( validHashes.includes(hash) ) {
      return true;
    }

    warn(chalk`{blueBright ${hash}} is not a supported hash algorithm`);

    return false;
  });
}
140141
private void highlightEntryParser(HighlightSearchEntry entry) {
		String text;
		int lastPos = 0;
		
		text = this.getText();
		
		Highlighter hilite = this.getHighlighter();
		HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(entry.getColor());
		
		while ( (lastPos = text.indexOf(entry.getToken(), lastPos)) > -1) {
			try {
				hilite.addHighlight(lastPos, lastPos + entry.getToken().length(), painter);
				lastPos += entry.getToken().length();
			} catch (BadLocationException e) {
				log.warn("Could not highlight entry", e);
			}
		}
	}
347587
def on_backward_begin(self, last_loss, last_output, **kwargs):
        ""
        last_loss = last_loss.detach().cpu()
        if self.gen_mode:
            self.smoothenerG.add_value(last_loss)
            self.glosses.append(self.smoothenerG.smooth)
            self.last_gen = last_output.detach().cpu()
        else:
            self.smoothenerC.add_value(last_loss)
            self.closses.append(self.smoothenerC.smooth)
826054
def history_forward(self, count=1):
        
        self._set_history_search()

        # Go forward in history.
        found_something = False

        for i in range(self.working_index + 1, len(self._working_lines)):
            if self._history_matches(i):
                self.working_index = i
                count -= 1
                found_something = True
            if count == 0:
                break

        # If we found an entry, move cursor to the end of the first line.
        if found_something:
            self.cursor_position = 0
            self.cursor_position += self.document.get_end_of_line_position()
263256
private final void appendNumericCEs(int ce32, boolean forward) {
        // Collect digits.
        // TODO: Use some kind of a byte buffer? We only store values 0..9.
        StringBuilder digits = new StringBuilder();
        if(forward) {
            for(;;) {
                char digit = Collation.digitFromCE32(ce32);
                digits.append(digit);
                if(numCpFwd == 0) { break; }
                int c = nextCodePoint();
                if(c < 0) { break; }
                ce32 = data.getCE32(c);
                if(ce32 == Collation.FALLBACK_CE32) {
                    ce32 = data.base.getCE32(c);
                }
                if(!Collation.hasCE32Tag(ce32, Collation.DIGIT_TAG)) {
                    backwardNumCodePoints(1);
                    break;
                }
                if(numCpFwd > 0) { --numCpFwd; }
            }
        } else {
            for(;;) {
                char digit = Collation.digitFromCE32(ce32);
                digits.append(digit);
                int c = previousCodePoint();
                if(c < 0) { break; }
                ce32 = data.getCE32(c);
                if(ce32 == Collation.FALLBACK_CE32) {
                    ce32 = data.base.getCE32(c);
                }
                if(!Collation.hasCE32Tag(ce32, Collation.DIGIT_TAG)) {
                    forwardNumCodePoints(1);
                    break;
                }
            }
            // Reverse the digit string.
            digits.reverse();
        }
        int pos = 0;
        do {
            // Skip leading zeros.
            while(pos < (digits.length() - 1) && digits.charAt(pos) == 0) { ++pos; }
            // Write a sequence of CEs for at most 254 digits at a time.
            int segmentLength = digits.length() - pos;
            if(segmentLength > 254) { segmentLength = 254; }
            appendNumericSegmentCEs(digits.subSequence(pos, pos + segmentLength));
            pos += segmentLength;
        } while(pos < digits.length());
    }
338069
public synchronized void tagNamedEntity(List<CoreLabel> tokens) {
        boolean isPOSTagged = tokens.parallelStream().filter(x -> x.tag() == null).count() == 0;
        if (!isPOSTagged) {
            throw new RuntimeException("Please Run POS Tagger before Named Entity tagger.");
        }
        if (ners != null) {
            try {
                ners.stream().forEach(ner -> ner.classify(tokens));
            } catch (Exception e) {
                /* edu.stanford.nlp.util.RuntimeInterruptedException: java.lang.InterruptedException
                 at edu.stanford.nlp.util.HashIndex.addToIndex(HashIndex.java:173) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher$BranchStates.newBid(SequenceMatcher.java:902) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher$MatchedStates.<init>(SequenceMatcher.java:1288) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher.getStartStates(SequenceMatcher.java:709) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher.findMatchStartBacktracking(SequenceMatcher.java:488) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher.findMatchStart(SequenceMatcher.java:449) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher.find(SequenceMatcher.java:341) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher.findNextNonOverlapping(SequenceMatcher.java:365) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ling.tokensregex.SequenceMatcher.find(SequenceMatcher.java:437) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.NumberNormalizer.findNumbers(NumberNormalizer.java:452) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.NumberNormalizer.findAndMergeNumbers(NumberNormalizer.java:721) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.time.TimeExpressionExtractorImpl.extractTimeExpressions(TimeExpressionExtractorImpl.java:184) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.time.TimeExpressionExtractorImpl.extractTimeExpressions(TimeExpressionExtractorImpl.java:178) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.time.TimeExpressionExtractorImpl.extractTimeExpressionCoreMaps(TimeExpressionExtractorImpl.java:116) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.time.TimeExpressionExtractorImpl.extractTimeExpressionCoreMaps(TimeExpressionExtractorImpl.java:104) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.runSUTime(NumberSequenceClassifier.java:340) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.classifyWithSUTime(NumberSequenceClassifier.java:138) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.classifyWithGlobalInformation(NumberSequenceClassifier.java:101) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.NERClassifierCombiner.recognizeNumberSequences(NERClassifierCombiner.java:267) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.NERClassifierCombiner.classifyWithGlobalInformation(NERClassifierCombiner.java:231) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 at edu.stanford.nlp.ie.NERClassifierCombiner.classify(NERClassifierCombiner.java:218) ~[stanford-corenlp-3.5.2.jar:3.5.2]
                 */
                LOG.warn("NER Classifier err for: " + tokens.stream().map(CoreLabel::word).collect(Collectors.joining(StringUtils.SPACE)));
            }
        }
    }
335604
private static int findNext(boolean reverse, int pos) {
        boolean backwards = IS_BACKWARDS_CHECKBOX.isSelected();
        backwards = backwards ? !reverse : reverse;

        String pattern = (String) FIND_FIELD.getSelectedItem();
        if (pattern != null && pattern.length() > 0) {
            try {
                Document doc = textComponent.getDocument();
                doc.getText(0, doc.getLength(), SEGMENT);
            }
            catch (Exception e) {
                // should NEVER reach here
                e.printStackTrace();
            }

            pos += textComponent.getSelectedText() == null ?
                    (backwards ? -1 : 1) : 0;

            char first = backwards ?
                    pattern.charAt(pattern.length() - 1) : pattern.charAt(0);
            char oppFirst = Character.isUpperCase(first) ?
                    Character.toLowerCase(first) : Character.toUpperCase(first);
            int start = pos;
            boolean wrapped = WRAP_SEARCH_CHECKBOX.isSelected();
            int end = backwards ? 0 : SEGMENT.getEndIndex();
            pos += backwards ? -1 : 1;

            int length = textComponent.getDocument().getLength();
            if (pos > length) {
                pos = wrapped ? 0 : length;
            }

            boolean found = false;
            while (!found && (backwards ? pos > end : pos < end)) {
                found = !MATCH_CASE_CHECKBOX.isSelected() && SEGMENT.array[pos] == oppFirst;
                found = found ? found : SEGMENT.array[pos] == first;

                if (found) {
                    pos += backwards ? -(pattern.length() - 1) : 0;
                    for (int i = 0; found && i < pattern.length(); i++) {
                        char c = pattern.charAt(i);
                        found = SEGMENT.array[pos + i] == c;
                        if (!MATCH_CASE_CHECKBOX.isSelected() && !found) {
                            c = Character.isUpperCase(c) ?
                                    Character.toLowerCase(c) :
                                    Character.toUpperCase(c);
                            found = SEGMENT.array[pos + i] == c;
                        }
                    }
                }

                if (!found) {
                    pos += backwards ? -1 : 1;

                    if (pos == end && wrapped) {
                        pos = backwards ? SEGMENT.getEndIndex() : 0;
                        end = start;
                        wrapped = false;
                    }
                }
            }
            pos = found ? pos : -1;
        }

        return pos;
    }
1188811
private static final int previousSpaceIndex(StringBuffer sb, int seek) {
    seek--;
    while (seek > 0) {
      if (sb.charAt(seek) == ' ') {
        while (seek > 0 && sb.charAt(seek - 1) == ' ')
          seek--;
        return seek;
      }
      seek--;
    }
    return 0;
  }
380337
private function checkLinesBetweenAnnotationsTypes($annotations)
    {
        if (empty($annotations)) {
            return;
        }

        $previousAnnotation = null;

        foreach ($annotations as $annotation) {
            if ($previousAnnotation === null) {
                $previousAnnotation = $annotation;
                continue;
            }

            $lines = $this->countLinesBetweenAnnotations($annotation, $previousAnnotation);
            $currentName = $this->getAnnotationName($annotation);
            $previousName = $this->getAnnotationName($previousAnnotation);

            $currentName === $previousName
                ? $this->checkSameAnnotations($annotation, $lines)
                : $this->checkDifferentAnnotations($annotation, $lines);

            $previousAnnotation = $annotation;
        }
    }
1104764
function nameBlankNodes(unique, duplicates, unnamed) {
    // name unique bnodes in sorted hash order
    var named = false;
    var hashes = Object.keys(unique).sort();
    for(var i = 0; i < hashes.length; ++i) {
      var bnode = unique[hashes[i]];
      namer.getName(bnode);
      named = true;
    }

    // continue to hash bnodes if a bnode was assigned a name
    if(named) {
      hashBlankNodes(unnamed);
    }
    // name the duplicate hash bnodes
    else {
      nameDuplicates(duplicates);
    }
  }
1298069
private void backward(final CLClause c, final int ignore) {
        int minlit = 0;
        int minoccs = Integer.MAX_VALUE;
        int litoccs;
        this.stats.steps++;
        for (int i = 0; i < c.lits().size(); i++) {
            final int lit = c.lits().get(i);
            if (lit == ignore) { continue; }
            if (val(lit) < 0) { continue; }
            litoccs = occs(lit).count();
            if (minlit != 0 && minoccs >= litoccs) { continue; }
            minlit = lit;
            minoccs = litoccs;
        }
        if (minoccs >= this.config.bwocclim) { return; }
        assert minlit != 0;
        for (int i = 0; i < c.lits().size(); i++) { mark(c.lits().get(i)); }
        final CLOccs os = occs(minlit);
        for (final CLClause d : os) {
            if (d == c) { continue; }
            int lit;
            int count = this.seen.size();
            int negated = 0;
            this.stats.steps++;
            for (int p = 0; count != 0 && p < d.lits().size(); p++) {
                lit = d.lits().get(p);
                final int m = marked(lit);
                if (m == 0) { continue; }
                assert count > 0;
                count--;
                if (m > 0) { continue; }
                assert m < 0;
                if (negated != 0) {
                    count = Integer.MAX_VALUE;
                    break;
                }
                negated = lit;
            }
            if (count != 0) { continue; }
            if (negated != 0) {
                this.tostrengthen.push(new Pair<>(d, negated));
                this.stats.backwardStrengthened++;
            } else {
                this.stats.backwardSubsumed++;
                dumpClause(d);
            }
        }
        unmark();
    }
714255
public void setHighlightSections(final boolean HIGHLIGHT) {
        if (null == highlightSections) {
            _highlightSections = HIGHLIGHT;
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            highlightSections.set(HIGHLIGHT);
        }
    }
503379
private void backward(final int lit) {
        assert this.level == 0;
        assert this.dense;
        assert this.tostrengthen.empty();
        final CLOccs os = occs(lit);
        for (final CLClause c : os) {
            assert !c.redundant();
            this.stats.steps++;
            if (c.dumped()) { continue; }
            if (c.size() >= this.config.bwclslim) { continue; }
            if (satisfied(c)) { continue; }
            backward(c, lit);
        }
        while (!this.tostrengthen.empty()) {
            final Pair<CLClause, Integer> cplp = this.tostrengthen.back();
            this.tostrengthen.pop();
            strengthen(cplp.first(), cplp.second());
        }
    }
174667
@Override
    public void backward() {
        Tensor tmp = new Tensor(yAdj); // copy
        tmp.elemMultiply(y);
        modInX.getOutputAdj().elemAdd(tmp);
    }
668030
@Override
    public void backward() {
        Tensor depAdj = depIn.getOutputAdj();
        int n = depAdj.getDims()[1];
        for (int v=0; v<yAdj.varBeliefs.length; v++) {
            if (yAdj.varBeliefs[v] != null) {
                Var var = y.varBeliefs[v].getVars().get(0);
                if (var instanceof LinkVar) {
                    LinkVar link = (LinkVar) var;
                    int p = link.getParent();
                    int c = link.getChild();
                    int pp = EdgeScores.getTensorParent(p, c);
                    assert p < n && c < n;
                    
                    // Add the adjoint of b(e_{p,c} = True).
                    depAdj.add(yAdj.varBeliefs[v].getValue(LinkVar.TRUE), pp, c);
                    // Add the adjoint of b(e_{p,c} = False)
                    depAdj.subtract(yAdj.varBeliefs[v].getValue(LinkVar.FALSE), pp, c);
                }
            }
        }
    }
227294
@Override
    protected String doBackward(final String flat) {
        log.debug("Converting incoming identifier: {}", flat);
        final List<String> hierarchySegments = createHierarchySegments();
        final List<String> flatSegments = asList(flat.split(separator));
        List<String> firstSegments = emptyList();
        List<String> lastSegment = emptyList();
        if (flatSegments.size() == 0) {
            // either empty identifier or separator identifier
            return on(separator).join(hierarchySegments);
        }
        if (flatSegments.size() > 1) {
            lastSegment = singletonList(getLast(flatSegments));
            firstSegments = flatSegments.subList(0, flatSegments.size() - 1);
        } else {
            // just one segment
            lastSegment = singletonList(flatSegments.get(0));
        }
        final Iterable<String> allSegments = concat(firstSegments, hierarchySegments, lastSegment);

        return on(separator).join(allSegments);
    }