microsoft / FLAML

A fast library for AutoML and tuning. Join our Discord: https://discord.gg/Cppx2vSPVP.
https://microsoft.github.io/FLAML/
MIT License
3.87k stars 504 forks source link

Extract_code can detect single-line code. #1222

Closed BeibinLi closed 1 year ago

BeibinLi commented 1 year ago

A parameter is added. Default to False. When True, it will also detect single-line code.

For instance, data = """

hello, how are you.

You can run python main.py

Or, you can write

1 + 1 == 2
print(3)
Formated stuff here
and there

Otherwise, do source download.sh for it.

I would also want to extract variable x.

Is that ok? """

extract_code(data, detect_single_line_code=True)

We will get

[('UNKNOWN', 'python main.py'),
 ('python', '1 + 1 == 2\nprint(3)'),
 ('UNKNOWN', 'Formated stuff here\nand there'),
 ('UNKNOWN', 'source download.sh'),
 ('UNKNOWN', 'x')]

Why are these changes needed?

Related issue number

Checks

BeibinLi commented 1 year ago

Move to the autogen