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

Function qual_candidate

internal/cbm/doc_pdf.c:695–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695static void qual_candidate(const uint32_t *t, int a, int b, candv_t *cv) {
696 int ce = b;
697 if (b - a >= 2 && t[b - 2] == '(' && t[b - 1] == ')') {
698 ce = b - 2;
699 }
700 bool colons = false;
701 bool arrow = false;
702 int ns = cv->pool.n;
703 for (int i = a; i < ce; i++) {
704 if (i + 1 < ce && t[i] == ':' && t[i + 1] == ':') {
705 colons = true;
706 u32_push(&cv->pool, '.');
707 i++;
708 } else if (i + 1 < ce && t[i] == '-' && t[i + 1] == '>') {
709 arrow = true;
710 u32_push(&cv->pool, '.');
711 i++;
712 } else if (t[i] == '#') {
713 u32_push(&cv->pool, '.');
714 } else {
715 u32_push(&cv->pool, t[i]);
716 }
717 }
718 if (cv->pool.fail) {
719 cv->fail = true;
720 return;
721 }
722 const uint32_t *norm = cv->pool.v + ns;
723 int nl = cv->pool.n - ns;
724 bool short_segs = true;
725 bool has_us = false;
726 int seg_s = 0;
727 int last_s = 0;
728 for (int i = 0; i <= nl; i++) {
729 if (i == nl || norm[i] == '.') {
730 if (i - seg_s > 2) {
731 short_segs = false;
732 }
733 last_s = seg_s;
734 seg_s = i + 1;
735 } else if (norm[i] == '_') {
736 has_us = true;
737 }
738 }
739 bool lower = str_islower(norm, nl);
740 if ((short_segs && lower) ||
741 (in_list_lower(norm + last_s, nl - last_s, TLDS) && lower && !has_us)) {
742 cv->pool.n = ns; /* abbreviation or domain: taken, no candidate */
743 return;
744 }
745 bool file = in_list_lower(norm + last_s, nl - last_s, CODE_EXT) && !colons && !arrow;
746 cand_t c = {a, b, file ? MK_FILE : MK_QUAL, ns, nl};
747 cand_push(cv, c);
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;

Callers 1

candidatesFunction · 0.85

Calls 4

u32_pushFunction · 0.85
str_islowerFunction · 0.85
in_list_lowerFunction · 0.85
cand_pushFunction · 0.85

Tested by

no test coverage detected