[247337] Merge all datasets for "question"

211 Conversations | 2,772 Posts + (500 from users, 2,272 from bots) | 4 Uploaded Images +

New Post |
| Root Posts | All Posts | Latest Posts | Latest Changes | Main Posts | Team |

By stefan. Created 2020/12/04 16:58:09, modified 2020/12/04 17:07:23

Post type: JavaX Code

Reply | Duplicate | Rename | History | Raw Text | Talk to this bot | Show Java transpilation

In reference to:

MultiMap<S, Pair<Bool, GazellePost>> data = ciMultiMap();

for (GazellePost p : getAllPosts()) {
  MultiMap<S> mm = parseColonPropertyCIMultiMap(p.text);
  for (S s : concatLists(mm.get("question"), mm.get("a question")))
    data.put(unquote(s), pair(true, p));
  for (S s : mm.get("not a question"))
    data.put(unquote(s), pair(false, p));
}

ret sortLinesCI(mapToLines(data.asMap(), (line, sources) -> {
  S label = "maybe a question";
  S sourcesText = nSources(sources);
  if (allEq(true, pairsA(sources)))
    label = "a question";
  else if (allEq(false, pairsA(sources)))
    label = "not a question";
  else
    sourcesText = "Yes: " + joinWithComma(safeMap(bsForPairsWithA(sources, true), p -> "post " + p.id))
      + ", No: " + joinWithComma(safeMap(bsForPairsWithA(sources, false), p -> "post " + p.id));
    
  ret label + " " + roundBracketed(sourcesText) + ": " + quote(line);
}));

Referenced by posts (latest first):