Sha256: 89f8735731976d87bb0c140161ab3ce5826834e8f4f1ba2d8a9e598e18e8c03c

Contents?: true

Size: 1.92 KB

Versions: 50

Compression:

Stored size: 1.92 KB

Contents

import core.memory;
import std.string;

// import std.regex;

import std.stdio;
import std.file;
import std.process;

int main(string args[]) {
  int gc = 0;
  //	executeShell("rm -rf word_files; mkdir word_files");
  //    executeShell("find -type f -size -5000 qoe

  executeShell("sudo sysctl vm.swappiness=100; mkdir word_files; find . -type "
               "f word_files -exec awk -v x=650 'NR==x{exit 1}' {} \\; -exec "
               "echo rm -f {} \\;");
  //	writefln("Hello world!");

  auto wl = readText(args[1]).toLower.split;

  string[][string] words;

  foreach (i; wl) { words[i] = []; }

  File file = File("/home/a/Downloads/wikipedia", "r");
  while (!file.eof()) {
    string line = strip(file.readln).toLower;
    foreach (a; line.split) {
      string i = "";
      for (int q = 0; q < a.length; ++q) {
        if ((a[q] >= 'a' && a[q] <= 'z') ||
            (a[q] == '-' || a[q] == '|' || a[q] == '(' || a[q] == '@' ||
             a[q] == '$' || a[q] == '*' || a[q] == '/' || a[q] == '!' ||
             a[q] == '.' || a[q] == ';' || a[q] == ')')) {
          i ~= a[q];
        }
      }

      if (i in words) {
        string filename = "word_files/" ~i;
        if (words[i].length < 650) {
          if (filename.exists) {
            words.remove(i);
          } else {
            words[i] ~= [line];
          }
        } else {
          //			string filename = "word_files" ~ i;

          if (!filename.exists) {
            File word_file = File(filename, "w");
            word_file.writeln(words[i].join("\n"));
            word_file.close;
          }
          words.remove(i);
          if (++gc == 1 && words.length > 1000) {
            gc = 0;
            GC.collect;
          }
          if (words.length == 0) {
            File("finished_with" ~i, "w").close;
            goto end;
          }
          /*
                                          writefln(line);*/
        }
      }
    }
  }

end:
  return 0;
}

Version data entries

50 entries across 49 versions & 6 rubygems

Version Path
aliens-1.0.72 ./other/semantic_metadata/hash.d
freespeech-1.0.72 ./other/semantic_metadata/hash.d
freespeech-1.0.71 ./other/semantic_metadata/hash.d
elonmusk-1.0.71 ./other/semantic_metadata/hash.d
ufos-1.0.71 ./other/semantic_metadata/hash.d
aliens-1.0.71 ./other/semantic_metadata/hash.d
elonmusk-1.0.56 ./de/other/github_project/hash.d
elonmusk-1.0.56 ./other/github_project/hash.d
elonmusk-1.0.53 ./other/github_project/hash.d
elonmusk-1.0.43 ./other/github_project/hash.d