code: def extract_ngram_filter(pos_seq, regex=SimpleNP, minlen=1, maxlen=8):
      """The "FilterFSA" method in Handler et al. 2016.
      Returns token position spans of valid ngrams."""
      ss = coarse_tag_str(pos_seq)
  
      def gen():
          for s in xrange(len(ss)):
              for n in xrange(minlen, 1 + min(maxlen, len(ss) - s)):
                  e = s + n
                  substr = ss[s:e]
                  if re.match(regex + "$", substr):
                      yield (s, e)
  
      return list(gen())
  
imports: from __future__ import print_function
  import os
  import re
  import sys
  from collections import Counter
label_desc: Use image node_id 4 for calling a global function with example usage: extract_ngram_filter(pos_seq, regex, minlen, maxlen) and returns: list