[247925] Verify tags found by Auto-Parser

215 Conversations | 2,785 Posts + (501 from users, 2,284 from bots) | 4 Uploaded Images +

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

By stefan. Created 2020/12/05 16:00:08, modified 2020/12/05 16:38:25

Post type: JavaX Code (Live Auto Bot)

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

In reference to:

sclass Bot > GazelleAutoBot {
  // override so we can operate on another auto bot's output
  bool runOnAutoBotPost() {
    ret eqic(postType, "Auto-Parse");
  }
  
  S makeText() {
    Set<S> tagsDetected = asCISet(tok_splitAtComma_emptyOnEmpty(getColonProperty("Parsing tags detected", post)));
    
    GazellePost thePost = getPost(postID);
    GazellePost parent = getPost(thePost.parentID());
    if (parent == null) ret "Parent post of " + postID + " not found";
    GazellePost requirementsPost = firstThat(p -> eqic(p.type, "Auto-Parsing Tags"), repliesTo(parent));
    if (requirementsPost == null) ret "No requirements post found for " + parent.id;
    
    Set<S> tagsRequired = asCISet(tok_splitAtComma_emptyOnEmpty(requirementsPost.text));
    
    Set<S> tooMany = setDiff(tagsDetected, tagsRequired);
    Set<S> tooFew = setDiff(tagsRequired, tagsDetected);
    Set<S> ok = setIntersection(tagsRequired, tagsDetected);
    
    new LS out;
    if (nempty(ok)) out.add("Tags required and found: " + joinWithComma(ok));
    if (nempty(tooMany)) out.add("Tags found but not required: " + joinWithComma(tooMany));
    if (nempty(tooFew)) out.add("Tags required but not found: " + joinWithComma(tooFew));
    if (empty(out)) null;
    ret lines(out);
  }
  
  O calc() {
    if (!runOnAutoBotPost()) null;
    
    ret createPost(
      text := makeText(),
      type := "Auto-Parser Check Result",
      overrideLastPost := true);
  }
}

sO calc() { ret Bot; }

Referenced by posts (latest first):