Try to determine if section numbers come after titles,
 rather than before.

 eg:

   Section title
   1. Section content

 versus

   1. Section title
   Section content
762804
def guess_section_number_after_title(text)
      before = text.scan(/^\w{4,}[^\n]+\n\d+\. /).length
      after  = text.scan(/^\s*\n\d+\. \w{4,}/).length

      before > after * 1.25
    end
1064280
def _read_sections(ifile):
        """"""
        if os.path.exists(ifile):
            return read_sections(ifile, exclude_ungrouped=True, prt=None)
847875
def otherwise(first, second)
      first = first.to_s
      first.empty? ? second : first
    end
462330
def isSubtitle(self):
        
        val=False
        if self.__dict__['codec_type']:
            if str(self.codec_type)=='subtitle':
                val=True
        return val
1236775
def is_equal_strings_ignore_case(first, second):
    """"""
    if first and second:
        return first.upper() == second.upper()
    else:
        return not (first or second)
1264426
def get_section_by_offset(self, offset):
        """"""

        sections = [s for s in self.sections if s.contains_offset(offset)]

        if sections:
            return sections[0]

        return None
1101035
public int compareToPositional(ResidueNumber other) {
		// sequence number
		if (seqNum != null && other.seqNum != null) {
			if (!seqNum.equals(other.seqNum)) return seqNum.compareTo(other.seqNum);
		}
		if (seqNum != null && other.seqNum == null) {
			return 1;
		} else if (seqNum == null && other.seqNum != null) {
			return -1;
		}

		// insertion code
		if (insCode != null && other.insCode != null) {
			if (!insCode.equals(other.insCode)) return insCode.compareTo(other.insCode);
		}
		if (insCode != null && other.insCode == null) {
			return 1;
		} else if (insCode == null && other.insCode != null) {
			return -1;
		}

		return 0;
	}
99916
function findFirstListItem(lineNumber, cm) {
  let nextLineNumber = lineNumber;
  let lineText = cm.getLine(lineNumber);

  while (listRE.test(lineText)) {
    nextLineNumber -= 1;
    lineText = cm.getLine(nextLineNumber);
  }

  if (lineNumber === nextLineNumber) {
    nextLineNumber = -1;
  } else {
    nextLineNumber += 1;
  }

  return nextLineNumber;
}
1184329
def compare(other)
      case
      when self.chrom != other.chrom
        :different_chrom
      when other.chr_end.between?(self.chr_start - @adjacent, self.chr_start - 1)
        :left_adjacent
      when other.chr_start.between?(self.chr_end + 1, self.chr_end + @adjacent)
        :right_adjacent
      when other.chr_end < self.chr_start
        :left_off
      when self.chr_end < other.chr_start
        :right_off
      when (self.chr_start == other.chr_start) &&
          (self.chr_end == other.chr_end)
        :equal
      when (other.chr_start.between?(self.chr_start, self.chr_end)) &&
          (other.chr_end.between?(self.chr_start, self.chr_end))
        :contained_by
      when (self.chr_start.between?(other.chr_start, other.chr_end)) &&
          (self.chr_end.between?(other.chr_start, other.chr_end))
        :contains
      when (other.chr_start < self.chr_start) &&
          (other.chr_end.between?(self.chr_start, self.chr_end))
        :left_overlapped
      when (other.chr_start.between?(self.chr_start, self.chr_end)) &&
          (self.chr_end < other.chr_end)
        :right_overlapped
      else
        raise Exception, "must not happen"
      end
    end
371837
function compareNumericWithNaNs(x, y) {
    if (!isNaN(x) && !isNaN(y))
      return x - y;
    if (isNaN(x))
      return 1;
    if (isNaN(y))
      return -1;
    return 0;
  }
1070603
function countNumMatches(contents, queryExpr) {
    if (!contents) {
        return 0;
    }
    var matches = contents.match(queryExpr);
    return matches ? matches.length : 0;
}
130028
def get_title(desc, default=None):
    """"""
    if not desc:
        return default
    lines = desc.strip('\n').split('\n')
    if not lines:
        return default
    return lines[0].lstrip('# ').rstrip(' ')
537009
def prev_content(self, start, amount=1):
        """"""
        while start > 0 and self.code[start] in (' ', '\t', '\n'):
            start -= 1

        return self.code[(start or amount) - amount: start]
410541
def _prior_headerfooter(self):
        """"""
        preceding_sectPr = self._sectPr.preceding_sectPr
        return (
            None if preceding_sectPr is None
            else _Footer(preceding_sectPr, self._document_part, self._hdrftr_index)
        )
405142
function compareCategories(a, b) {
  return a === b                 ?   0
  :      a === '(Uncategorised)' ?   1
  :      b === '(Uncategorised)' ?  -1
  :      /* otherwise */            compare(a, b);
}
378945
@Override
    public boolean hasNext(int startPosition, int contentLength) {
        //("-------------: " + startPosition + ", " + contentLength + ", " + this.position);
        if (startPosition >= 0 && contentLength >= 0) {
            return (this.position) < (startPosition + contentLength);
        }
        return (this.position + 1) < this.content.length;
    }
1220381
def get_reference_section_beginning(fulltext):
    """"""
    sect_start = {
        'start_line': None,
        'end_line': None,
        'title_string': None,
        'marker_pattern': None,
        'marker': None,
        'how_found_start': None,
    }

    # Find start of refs section:
    sect_start = find_reference_section(fulltext)
    if sect_start is not None:
        sect_start['how_found_start'] = 1
    else:
        # No references found - try with no title option
        sect_start = find_reference_section_no_title_via_brackets(fulltext)
        if sect_start is not None:
            sect_start['how_found_start'] = 2
        # Try weaker set of patterns if needed
        if sect_start is None:
            # No references found - try with no title option (with weaker
            # patterns..)
            sect_start = find_reference_section_no_title_via_dots(fulltext)
            if sect_start is not None:
                sect_start['how_found_start'] = 3
            if sect_start is None:
                # No references found - try with no title option (with even
                # weaker patterns..)
                sect_start = find_reference_section_no_title_via_numbers(
                    fulltext)
                if sect_start is not None:
                    sect_start['how_found_start'] = 4

    if sect_start:
        current_app.logger.debug('* title %r' % sect_start['title_string'])
        current_app.logger.debug('* marker %r' % sect_start['marker'])
        current_app.logger.debug('* title_marker_same_line %s'
                                 % sect_start['title_marker_same_line'])
    else:
        current_app.logger.debug('* could not find references section')
    return sect_start