MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / tok_candidate

Function tok_candidate

internal/cbm/doc_pdf.c:750–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750static void tok_candidate(const uint32_t *t, int n, int a, int b, uint8_t *taken, candv_t *cv) {
751 int len = b - a;
752 /* "_" in t.strip("_") */
753 int sa = a;
754 int sb = b;
755 while (sa < sb && t[sa] == '_') {
756 sa++;
757 }
758 while (sb > sa && t[sb - 1] == '_') {
759 sb--;
760 }
761 bool inner_us = false;
762 for (int i = sa; i < sb; i++) {
763 inner_us = inner_us || t[i] == '_';
764 }
765 bool dunder = len > 4 && t[a] == '_' && t[a + 1] == '_' && t[b - 1] == '_' && t[b - 2] == '_';
766 mention_kind_t kind;
767 if (inner_us || dunder) {
768 kind = MK_SNAKE;
769 } else if (is_camel(t + a, len)) {
770 kind = MK_CAMEL;
771 } else if (b < n && t[b] == '(' && len >= 2 && !str_isupper(t + a, len)) {
772 kind = MK_CALL;
773 } else {
774 return;
775 }
776 span_take(taken, a, b);
777 cand_t c = {a, b, kind, cv->pool.n, len};
778 for (int i = a; i < b; i++) {
779 u32_push(&cv->pool, t[i]);
780 }
781 cand_push(cv, c);
782}
783
784static int cand_cmp(const void *x, const void *y) {
785 const cand_t *a = (const cand_t *)x;

Callers 1

candidatesFunction · 0.85

Calls 5

is_camelFunction · 0.85
str_isupperFunction · 0.85
span_takeFunction · 0.85
u32_pushFunction · 0.85
cand_pushFunction · 0.85

Tested by

no test coverage detected