Skip to content

Commit 4117723

Browse files
authored
Update index.md
1 parent f739aa5 commit 4117723

File tree

1 file changed

+20
-27
lines changed
  • website/blog/2025-10-30-ragflow-in-practice-an-intelligent-agent-for-in-depth-research-on-company-research-reports

1 file changed

+20
-27
lines changed

website/blog/2025-10-30-ragflow-in-practice-an-intelligent-agent-for-in-depth-research-on-company-research-reports/index.md

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -157,32 +157,25 @@ Code:
157157
import re
158158
159159
def format_number(value: str) -> str:
160-
"""Convert scientific notation or float to formatted number with commas."""
160+
"""Convert scientific notation or floating-point numbers to comma-separated numbers"""
161161
try:
162162
num = float(value)
163163
if num.is_integer():
164-
return f"{int(num):,}"
164+
return f"{int(num):,}" # If it's an integer, format without decimal places
165165
else:
166-
return f"{num:,.2f}"
166+
return f"{num:,.2f}" # Otherwise, keep two decimal places and add commas
167167
except:
168-
return value # Return as is if not a number (e.g., — or empty)
168+
return value # Return the original value if it's not a number (e.g., — or empty)
169169
170170
def extract_md_table_single_column(input_text: str) -> str:
171-
# Core financial indicators (English only)
171+
# Use English indicators directly
172172
indicators = [
173-
"Total Assets",
174-
"Total Equity",
175-
"Tangible Book Value",
176-
"Total Debt",
177-
"Net Debt",
178-
"Cash And Cash Equivalents",
179-
"Working Capital",
180-
"Long Term Debt",
181-
"Common Stock Equity",
182-
"Ordinary Shares Number"
173+
"Total Assets", "Total Equity", "Tangible Book Value", "Total Debt",
174+
"Net Debt", "Cash And Cash Equivalents", "Working Capital",
175+
"Long Term Debt", "Common Stock Equity", "Ordinary Shares Number"
183176
]
184-
185-
# Units for each indicator
177+
178+
# Core indicators and their corresponding units
186179
unit_map = {
187180
"Total Assets": "USD",
188181
"Total Equity": "USD",
@@ -198,7 +191,7 @@ def extract_md_table_single_column(input_text: str) -> str:
198191
199192
lines = input_text.splitlines()
200193
201-
# Detect header line containing dates
194+
# Automatically detect the date column, keeping only the first one
202195
date_pattern = r"\d{4}-\d{2}-\d{2}"
203196
header_line = ""
204197
for line in lines:
@@ -207,32 +200,32 @@ def extract_md_table_single_column(input_text: str) -> str:
207200
break
208201
209202
if not header_line:
210-
raise ValueError("No header line with date found.")
203+
raise ValueError("Date column header row not found")
211204
212205
dates = re.findall(date_pattern, header_line)
213-
first_date = dates[0] # Use only the first column (latest or leftmost date)
214-
header = f"| Key Indicator | {first_date} |"
215-
divider = "|-------------------------|---------------|"
206+
first_date = dates[0] # Keep only the first date
207+
header = f"| Indicator | {first_date} |"
208+
divider = "|------------------------|------------|"
216209
217210
rows = []
218211
for ind in indicators:
219212
unit = unit_map.get(ind, "")
220-
display_name = f"{ind} ({unit})" if unit else ind
213+
display_ind = f"{ind} ({unit})" if unit else ind
221214
222215
found = False
223216
for line in lines:
224217
if ind in line:
225-
# Match numeric value (float, int, or scientific)
218+
# Match numbers and possible units
226219
pattern = r"(nan|[0-9\.]+(?:[eE][+-]?\d+)?)"
227220
values = re.findall(pattern, line)
228-
# Clean up value
221+
# Replace 'nan' with '—' and format the number
229222
first_value = values[0].strip() if values and values[0].strip().lower() != "nan" else "—"
230223
first_value = format_number(first_value) if first_value != "—" else "—"
231-
rows.append(f"| {display_name} | {first_value} |")
224+
rows.append(f"| {display_ind} | {first_value} |")
232225
found = True
233226
break
234227
if not found:
235-
rows.append(f"| {display_name} | — |")
228+
rows.append(f"| {display_ind} | — |")
236229
237230
md_table = "\n".join([header, divider] + rows)
238231
return md_table

0 commit comments

Comments
 (0)