Skip to content

Commit

Permalink
VISUAL-TEXT-108 Add MakeCountConPad
Browse files Browse the repository at this point in the history
Signed-off-by: David de Hilster <[email protected]>
  • Loading branch information
ddehilster committed Aug 24, 2024
1 parent 99a1b1c commit 712c756
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions spec/KBFuncs.nlp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ LastChild(L("parent")) {
}

MakeCountCon(L("con"),L("count name")) {
L("count name") = CountName(L("con"),L("count name"));
L("count name") = CountName(L("con"),L("count name"),0);
return makeconcept(L("con"),L("count name"));
}

MakeCountConPad(L("con"),L("count name"),L("pad")) {
L("count name") = CountName(L("con"),L("count name"),L("pad"));
return makeconcept(L("con"),L("count name"));
}

Expand All @@ -167,9 +172,14 @@ IncrementCount(L("con"),L("countname")) {
return L("count");
}

CountName(L("con"),L("root")) {
CountName(L("con"),L("root"),L("pad")) {
L("count") = IncrementCount(L("con"),L("root"));
return L("root") + str(L("count"));
if (L("pad")) {
L("pad") = RepeatStr(L("pad")-strlength(str(L("count"))),"0");
} else {
L("pad") = SpacesStr(" ");
}
return L("root") + L("pad") + str(L("count"));
}

StripEndDigits(L("name")) {
Expand Down Expand Up @@ -357,10 +367,14 @@ QuoteIfNeeded(L("str")) {
# Because NLP++ doesn't allow for empty strings,
# this function can only be called with "num" >= 1
SpacesStr(L("num")) {
return RepeatStr(L("num")," ");
}

RepeatStr(L("num"),L("str")) {
L("n") = 1;
L("spaces") = " ";
L("spaces") = L("str");
while (L("n") < L("num")) {
L("spaces") = L("spaces") + " ";
L("spaces") = L("spaces") + L("str");
L("n")++;
}
return L("spaces");
Expand Down

0 comments on commit 712c756

Please sign in to comment.