Enter strings.

        **中文文档**

        从键盘输入字符串, interval是字符间输入时间间隔, 单位是秒。
543452
def type_string(self, text, interval=0, pre_dl=None, post_dl=None):
        
        self.delay(pre_dl)
        self.k.type_string(text, interval)
        self.delay(post_dl)
183760
function getRange(str, size) {
  let index = str ? str.indexOf('=') : -1
  if (index === -1) {
    return -2
  }
  // 把range转换为数组
  let arr = str.slice(index + 1).split(',')
  let ranges = []
  // 记录range的类型
  ranges.AcceptRanges = str.slice(0, index)
  // 获取文件长度
  for (let i = 0; i < arr.length; i++) {
    let range = arr[i].split('-')
    let start = parseInt(range[0], 10)
    let end = parseInt(range[1], 10)
    // start为数字时
    if (isNaN(start)) {
      start = size - end
      end = size - 1
      // end为数字时
    } else if (isNaN(end)) {
      end = size - 1
    }
    // 结束不得大于文件大小
    if (end > size - 1) {
      end = size - 1
    }
    // start与end都为数字,且0<=start<=end
    if (!isNaN(start) && !isNaN(end) && start >= 0 && start <= end) {
      ranges.push({
        ContentRange:
          ranges.AcceptRanges + ' ' + start + '-' + end + '/' + size,
        ContentLength: end - start + 1,
        start: start,
        end: end
      })
    }
  }
  // 没有获取到有效的range值
  if (ranges.length < 1) {
    return -1
  }
  return ranges
}
800557
def mtime_including_imports(file)
      mtimes = [mtime(file)]
      File.readlines(file).each do |line|
        next unless line =~ /^\s*@import ['"]([^'"]+)/

        imported = File.join(File.dirname(file), Regexp.last_match[1])

        # complete path given ?
        mod_time = if imported =~ /\.le?ss$/
                     mtime(imported)
                   else
                     # we need to add .less or .lss
                     [mtime("#{imported}.less"), mtime("#{imported}.lss")].max
                   end
        mtimes << mod_time
      end
      mtimes.max
    end
47383
def get_range_string(self):
    
    return self.chr+":"+str(self.start)+"-"+str(self.end)
637669
def Type_string(self, text, interval = 0, dl = 0):
        
        self.Delay(dl)
        self.keyboard.type_string(text, interval)
243299
def _str(self, indent=""):
        """"""
        if self.ndim <= 1:
            return "[" + ", ".join(str(x) for x in self) + "]"
        elif self.ndim == 2:
            sep = ",\n" + indent
            return "[" + sep.join(x._str(indent + " ") for x in self) + "]"
        else:
            sep = ",\n\n" + indent
            return "[" + sep.join(x._str(indent + " ") for x in self) + "]"
932496
function write(file, data) {
  writeFileSync(file, data);

  console.log(
    `✓ ${relative(__dirname + "/../", file)} (${bytes(statSync(file).size)})`
  );
}
826140
def main():
    

    # make sure we have enough parameters
    if len(sys.argv) < 6:
        print("You must pass five arguments: QUIT_AFTER BACKWARDS TEXT_FILE_PATH AUDIO_FILE_PATH DATA_FILE_PATH")
        return 1

    # read parameters
    c_quit_after = float(sys.argv[1])   # NOTE: cew needs float, not TimeValue
    c_backwards = int(sys.argv[2])
    text_file_path = sys.argv[3]
    audio_file_path = sys.argv[4]
    data_file_path = sys.argv[5]

    # read (voice_code, text) from file
    s_text = []
    with io.open(text_file_path, "r", encoding="utf-8") as text:
        for line in text.readlines():
            # NOTE: not using strip() to avoid removing trailing blank characters
            line = line.replace(u"\n", u"").replace(u"\r", u"")
            idx = line.find(" ")
            if idx > 0:
                f_voice_code = line[:idx]
                f_text = line[(idx + 1):]
                s_text.append((f_voice_code, f_text))

    # convert to bytes/unicode as required by subprocess
    c_text = []
    if gf.PY2:
        for f_voice_code, f_text in s_text:
            c_text.append((gf.safe_bytes(f_voice_code), gf.safe_bytes(f_text)))
    else:
        for f_voice_code, f_text in s_text:
            c_text.append((gf.safe_unicode(f_voice_code), gf.safe_unicode(f_text)))

    try:
        import aeneas.cew.cew
        sr, sf, intervals = aeneas.cew.cew.synthesize_multiple(
            audio_file_path,
            c_quit_after,
            c_backwards,
            c_text
        )
        with io.open(data_file_path, "w", encoding="utf-8") as data:
            data.write(u"%d\n" % (sr))
            data.write(u"%d\n" % (sf))
            data.write(u"\n".join([u"%.3f %.3f" % (i[0], i[1]) for i in intervals]))
    except Exception as exc:
        print(u"Unexpected error: %s" % str(exc))
1056983
def load_inputs(self):
        """"""
        for f in self.args.files:
            if os.path.isfile(f):
                fparts = str(f).split('.')
                if fparts[-1] == 'gz':
                    if self.args.unzip:
                        fullpath = os.path.abspath(str(f))
                        self.input_files.append(fullpath)
                    else:
                        return 0
                elif fparts[-1] == 'bz2' or fparts[-1] == 'zip':
                    return 0
                else:
                    fullpath = os.path.abspath(str(f))
                    self.input_files.append(fullpath)
            else:
                print('File '+ f + ' not found')
                return 1
721262
def main():
    
    args = parser.parse_args()
    filehandle = args.filename
    delim = args.delimiter
    columns = args.columns[0]

    if not columns:
        for line in filehandle:
            print line,
        exit(0)

    cs = list(chain.from_iterable(columns))
    fields = (extract_fields(line, delim, cs) for line in filehandle)

    for line in fields:
        print ' '.join(line)

    args.filename.close()
1293026
def main(pargs):
    
    input_file = sys.argv[1]
    fp = ParseFileLineByLine(input_file)
    for i in fp:
        print(i)
290852
def addinterval(instr, add, interval):
    '''
        
    '''
    if not isinstance(instr, str):
        instr = str(instr)

    return add.join(
        instr[i:i+interval]
        for i in xrange(0,len(instr),interval))
482333
private static void analyzeCorpus(String zipFile, String output, final String separator, final boolean includePhrase) throws IOException{
        File outputFile = new File(output);
        //准备输出目录
        if(!outputFile.getParentFile().exists()){
            outputFile.getParentFile().mkdirs();
        }
        try (FileSystem fs = FileSystems.newFileSystem(Paths.get(zipFile), ExtractText.class.getClassLoader());
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile),"utf-8"));) {
            for(Path path : fs.getRootDirectories()){                
                LOGGER.info("处理目录："+path);
                Files.walkFileTree(path, new SimpleFileVisitor<Path>(){

                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        LOGGER.info("处理文件："+file);
                        // 拷贝到本地文件系统
                        Path temp = Paths.get("target/corpus-"+System.currentTimeMillis()+".txt");
                        Files.copy(file, temp, StandardCopyOption.REPLACE_EXISTING);
                        extractText(temp, writer, separator, includePhrase);
                        return FileVisitResult.CONTINUE;
                    }
                    
                });
            }
        }
    }
698651
def input_file(self):
        
        return path.join(path.dirname(__file__), 'data', 'tgs{:s}.tsv'.format(self.number))
470504
public static void main(String[] args) {
    int N;

    if (args != null && args.length != 0) {
      N = Integer.parseInt(args[0]);
    } else {
      N = 10;
    }

    IntervalST<Integer, Double> st = new IntervalST<>();

    double intervalId = 0d;
    st.put(new Interval1D<>(1, 5), ++intervalId);
    st.put(new Interval1D<>(2, 5), ++intervalId);
    st.put(new Interval1D<>(3, 6), ++intervalId);
    st.put(new Interval1D<>(3, 6), ++intervalId);
    st.put(new Interval1D<>(7, 7), ++intervalId);
    st.put(new Interval1D<>(4, 10), ++intervalId);
    st.put(new Interval1D<>(15, 20), ++intervalId);

    List<Integer> vals = new ArrayList<>();
    vals.add(52);
    vals.add(54);
    vals.add(56);
    vals.add(58);
    st.put(new Interval1D<>(4, 100), ++intervalId);
    st.put(new Interval1D<>(4, 101), ++intervalId);
    st.put(new Interval1D<>(4, 102), ++intervalId);
    st.put(new Interval1D<>(4, 103), ++intervalId);
    st.put(new Interval1D<>(0, 103), ++intervalId);
    st.put(new Interval1D<>(-10, 103), ++intervalId);
    st.put(new Interval1D<>(Integer.MIN_VALUE, -1000), ++intervalId);
    st.put(new Interval1D<>(Integer.MIN_VALUE, -1100), ++intervalId);
    st.put(new Interval1D<>(Integer.MIN_VALUE, -900), ++intervalId);
    st.put(new Interval1D<>(1000, Integer.MAX_VALUE), ++intervalId);
    st.put(new Interval1D<>(900, Integer.MAX_VALUE), ++intervalId);
    st.put(new Interval1D<>(1100, Integer.MAX_VALUE), ++intervalId);
    st.put(new Interval1D<>(Integer.MIN_VALUE, Integer.MAX_VALUE), ++intervalId);

    Node<Integer, Double> removed = st.remove(new Interval1D<>(-10, 103));

    System.err.flush();

    // print out tree statistics
    System.out.println("Tree stats:");
    System.out.println("\theight:          " + st.height());
    System.out.println("\tsize:            " + st.size());
    System.out.println("\tintegrity check: " + st.check());
    System.out.println();
    System.out.flush();

    ArrayList<Interval1D<Integer>> queries = new ArrayList<>();
    queries.add(new Interval1D<>(-1, -1));
    queries.add(new Interval1D<>(0, 0));
    queries.add(new Interval1D<>(1, 1));
    queries.add(new Interval1D<>(2, 2));
    queries.add(new Interval1D<>(3, 3));
    queries.add(new Interval1D<>(4, 4));
    queries.add(new Interval1D<>(5, 5));
    queries.add(new Interval1D<>(6, 6));
    queries.add(new Interval1D<>(7, 7));
    queries.add(new Interval1D<>(10, 10));
    queries.add(new Interval1D<>(11, 11));
    queries.add(new Interval1D<>(12, 16));
    queries.add(new Interval1D<>(100, 100));
    queries.add(new Interval1D<>(200, 400));

    queries.add(new Interval1D<>(Integer.MIN_VALUE, Integer.MIN_VALUE));
    queries.add(new Interval1D<>(Integer.MIN_VALUE, -10000));
    queries.add(new Interval1D<>(Integer.MIN_VALUE, -1101));
    queries.add(new Interval1D<>(Integer.MIN_VALUE, -1100));
    queries.add(new Interval1D<>(Integer.MIN_VALUE, -999));
    queries.add(new Interval1D<>(Integer.MIN_VALUE, -899));
    queries.add(new Interval1D<>(-900, -899));
    queries.add(new Interval1D<>(-899, -800));

    queries.add(new Interval1D<>(Integer.MAX_VALUE, Integer.MAX_VALUE));
    queries.add(new Interval1D<>(10000, Integer.MAX_VALUE));
    queries.add(new Interval1D<>(1101, Integer.MAX_VALUE));
    queries.add(new Interval1D<>(1100, Integer.MAX_VALUE));
    queries.add(new Interval1D<>(1000, Integer.MAX_VALUE));
    queries.add(new Interval1D<>(900, Integer.MAX_VALUE));
    queries.add(new Interval1D<>(899, 900));
    queries.add(new Interval1D<>(898, 899));

    for (Interval1D<Integer> query : queries) {
      System.out.println("Query: " + query.toString());
      Iterable<Node<Integer, Double>> nodes = st.searchAll(query);
      if (!nodes.iterator().hasNext()) {
        System.out.print("No intersections");
      }
      for (Node<Integer, Double> x : nodes) {
        System.out.print("\t" + x.getInterval() + " :: " + x.getValue() + "\n");
      }
      System.out.println();
      System.out.println();
    }

    System.exit(1);

    // generate N random intervals and insert into data structure
    st = new IntervalST<>();
    for (int i = 0; i < N; i++) {
      int low = (int) (java.lang.Math.random() * 1000);
      int high = (int) (java.lang.Math.random() * 50) + low;
      Interval1D<Integer> interval = new Interval1D<>(low, high);
      System.out.println(interval);
      st.put(interval, (double) i);
    }

    // print out tree statistics
    System.out.println("height:          " + st.height());
    System.out.println("size:            " + st.size());
    System.out.println("integrity check: " + st.check());
    System.out.println();

    // generate random intervals and check for overlap
    for (int i = 0; i < N; i++) {
      int low = (int) (java.lang.Math.random() * 100);
      int high = (int) (java.lang.Math.random() * 10) + low;
      Interval1D<Integer> interval = new Interval1D<>(low, high);
      System.out.println(interval + ":  " + st.search(interval));
      System.out.print(interval + ":  ");
      for (Node<Integer, Double> x : st.searchAll(interval)) {
        System.out.print(x + " ");
      }
      System.out.println();
      System.out.println();
    }


  }
871803
def str_from_file(path):
    
    with open(path) as f:
        s = f.read().strip()
    return s
363600
def main():
    
    (options, strings) = parseArgv()
    global _suffixArray, _trace

    #############
    # Verbosity #
    #############
    _trace = options.verbose

    ###################
    # Processing unit #
    ###################
    if options.unit == "byte":
        options.unit = UNIT_BYTE
    elif options.unit == "character":
        options.unit = UNIT_CHARACTER
    elif options.unit == "word":
        options.unit = UNIT_WORD
    else:
        print >> _stderr, "Please specify a valid unit type."
        exit(EXIT_BAD_OPTION)

    ######################
    # Build suffix array #
    ######################
    if not options.SAFile:  # Build the suffix array from INPUT
        if not options.input:  # default is standard input
            options.input = "-"
        try:
            string = _open(options.input, "r").read()
        except IOError:
            print >> _stderr, "File %s does not exist." % options.input
            exit(EXIT_ERROR_FILE)

        SA = SuffixArray(string, options.unit, options.encoding, options.noLCPs)
    ########################
    # Or load suffix array #
    ########################
    elif not options.input and options.SAFile:  # Load suffix array from SA_FILE
        try:
            SA = SuffixArray.fromFile(options.SAFile)
        except IOError:
            print >> _stderr, "SA_FILE %s does not exist." % options.SAFile
            exit(EXIT_ERROR_FILE)
    else:
        print >> _stderr, "Please set only one option amongst --input and --load.\n" + \
        "Type %s --help for more details." % _argv[0]
        exit(EXIT_BAD_OPTION)

    ######################
    # Print suffix array #
    ######################
    if options.printSA:
        # Buffered ouptut
        deltaLength = 1000
        start = 0
        while start < SA.length:
            print >> _stderr, SA.__str__(start, start + deltaLength)
            start += deltaLength

    ####################################
    # Look for every string in strings #
    ####################################
    for string in strings:
        print >> _stderr, ""
        print >> _stderr, "Positions of %s:" % string
        print >> _stderr, "  %s" % list(SA.find(string))

    #########################
    # Save SAFILE if needed #
    #########################
    if options.output:
        SA.toFile(options.output)

    if _trace: print >> _stderr, "Done\r\n"