Skip to content

Commit

Permalink
Add --target-class option to web_extract command (#470)
Browse files Browse the repository at this point in the history
This mirrors the behavior of the same option in the `extract` command.

Fixes #468.
  • Loading branch information
caufieldjh authored Nov 5, 2024
2 parents 16b40e2 + 639c366 commit 1eea78d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ontogpt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ def search_and_extract(

@main.command()
@template_option
@target_class_option
@model_option
@recurse_option
@output_option_wb
Expand All @@ -989,6 +990,7 @@ def search_and_extract(
def web_extract(
model,
template,
target_class,
url,
output,
output_format,
Expand Down Expand Up @@ -1026,8 +1028,14 @@ def web_extract(
web_client = SoupClient()
text = web_client.text(url)

if target_class:
schemaview = template_details[3]
target_class_def = schemaview.get_class(target_class)
else:
target_class_def = None

logging.debug(f"Input text: {text}")
results = ke.extract_from_text(text=text, show_prompt=show_prompt)
results = ke.extract_from_text(text=text, cls=target_class_def, show_prompt=show_prompt)
write_extraction(results, output, output_format, ke, template, cut_input_text)


Expand Down

0 comments on commit 1eea78d

Please sign in to comment.