Merge branch 'call-graph' into gpt-35

This commit is contained in:
Paul Gauthier 2023-06-04 15:03:46 -07:00
commit 0256b8e260
3 changed files with 33 additions and 11 deletions

View file

@ -29,11 +29,15 @@ def to_tree(tags):
for tag in tags:
tag = list(tag)
for i in range(len(last)):
for i in range(len(last) + 1):
if i == len(last):
break
if last[i] != tag[i]:
break
num_common = i
dump(repr(tag), num_common)
indent = tab * num_common
rest = tag[num_common:]
for item in rest:
@ -288,11 +292,6 @@ class RepoMap:
except ZeroDivisionError:
return []
# top_rank = sorted([(rank, node) for (node, rank) in ranked.items()], reverse=True)
# Print the PageRank of each node
# for rank, node in top_rank:
# print(f"{rank:.03f} {node}")
# distribute the rank from each source node, across all of its out edges
ranked_definitions = defaultdict(float)
for src in G.nodes:
@ -312,6 +311,21 @@ class RepoMap:
continue
ranked_tags += list(definitions.get((fname, ident), []))
rel_other_fnames_without_tags = set(
os.path.relpath(fname, self.root) for fname in other_fnames
)
fnames_already_included = set(rt[0] for rt in ranked_tags)
top_rank = sorted([(rank, node) for (node, rank) in ranked.items()], reverse=True)
for rank, fname in top_rank:
rel_other_fnames_without_tags.remove(fname)
if fname not in fnames_already_included:
ranked_tags.append((fname,))
for fname in rel_other_fnames_without_tags:
ranked_tags.append((fname,))
return ranked_tags
def get_ranked_tags_map(self, chat_fnames, other_fnames=None):