Skip to content

Commit

Permalink
Improve recognition with better context and text
Browse files Browse the repository at this point in the history
  • Loading branch information
artfuldev committed Oct 8, 2024
1 parent da68b87 commit 340752f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/analyzer_engine/csv_analyzer_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,23 @@ def analyze(
line_text = ", ".join(row) + "\n"
for idx, value in enumerate(row):
header = headers[idx]
prefix = "the " + header + " is: "
suffix = ""
analysis_result = self.analyzer_engine.analyze(
value, language, context=header
prefix + value + suffix,
language,
context="this is the value in the "
+ header
+ " column in a csv file with the following columns: "
+ ",".join(headers),
)
for result in analysis_result:
if result.end <= len(prefix):
continue
line_offset = text.index(value, line_start_index) - current_index
adjusted_start = current_index + line_offset + result.start
adjusted_start = (
current_index + line_offset + result.start - len(prefix)
)
adjusted_end = adjusted_start + (result.end - result.start)
results.append(
RecognizerResult(
Expand Down

0 comments on commit 340752f

Please sign in to comment.