停止为应该用英文描述的数据编写正则表达式

发布: (2026年2月10日 GMT+8 19:08)
6 分钟阅读
原文: Dev.to

Source: Dev.to

远程友好、高级别、薪资公开的职位筛选

您拥有一份职位发布的电子表格,需要将其筛选为 remote‑friendlysenior‑levelsalary disclosed 的岗位。数据示例如下:

companypost
AirtableAsync‑first 团队,8+ 年经验,$185‑220K 基础工资
VercelLead 我们的 NYC 团队。Competitive comp,DOE
NotionIn‑office SF。Staff eng,$200K + equity
Linear欢迎 Bootcamp 毕业生!$85K,remote‑friendly
DescriptWork from anywhere。Principal architect,$250K

确定性规则(英文说明)

  • Remote‑friendly – 包含 “remote”、 “work from anywhere”、 “async‑first”,或 通过缺少办公室地点暗示
  • Senior‑level – 包含 “8+ yrs”、 “Staff”、 “Principal” 或 “Lead”(注意:“Lead” 有时也可能是初级)。
  • Salary disclosed – 包含实际数字(例如 “$85K”、 “$185‑220K”),而非 “Competitive comp” 或 “DOE”。

使用 everyrow 用自然语言表达逻辑

everyrow 让你可以用简洁的英文定义模糊的、定性的逻辑,并将其应用到数据框的每一行。SDK 负责 LLM 编排、结构化输出以及扩展。

import asyncio
import pandas as pd
from pydantic import BaseModel, Field
from everyrow.ops import screen

jobs = pd.DataFrame([
    {"company": "Airtable", "post": "Async-first team, 8+ yrs exp, $185-220K base"},
    {"company": "Vercel",   "post": "Lead our NYC team. Competitive comp, DOE"},
    {"company": "Notion",   "post": "In-office SF. Staff eng, $200K + equity"},
    {"company": "Linear",   "post": "Bootcamp grads welcome! $85K, remote-friendly"},
    {"company": "Descript", "post": "Work from anywhere. Principal architect, $250K"},
])

class JobScreenResult(BaseModel):
    qualifies: bool = Field(description="True if meets ALL criteria")

async def main():
    result = await screen(
        task="""
        Qualifies if ALL THREE are met:
        1. Remote‑friendly
        2. Senior‑level (5+ yrs exp OR Senior/Staff/Principal in title)
        3. Salary disclosed (specific numbers, not "competitive" or "DOE")
        """,
        input=jobs,
        response_model=JobScreenResult,
    )
    print(result.data)

asyncio.run(main())

结果

companyqualifies
AirtableTrue
VercelFalse
NotionFalse
LinearFalse
DescriptTrue
  • Airtable 符合条件:“async‑first”(远程友好)、“8+ years”(高级)、“$185‑220K”(薪资已披露)。
  • Descript 符合条件:“work from anywhere”(远程)、“principal architect”(高级)、“$250K”(薪资已披露)。

其他行至少在一个标准上不满足(没有明确薪资、在办公室地点或资历不足)。

Sessions: Track Everything in a Dashboard

每个操作都在一个相关操作的分组中运行,该分组会显示在 everyrow.io 的网页 UI 中。会话会自动创建,但对于多步骤流水线,你可能需要显式创建一个会话:

from everyrow import create_session
from everyrow.ops import screen, rank

async with create_session(name="Lead Qualification") as session:
    print(f"View at: {session.get_url()}")

    screened = await screen(
        session=session,
        task="Has a company email domain (not gmail, yahoo, etc.)",
        input=leads,
        response_model=ScreenResult,
    )

    ranked = await rank(
        session=session,
        task="Score by likelihood to convert",
        input=screened.data,
        field_name="conversion_score",
    )

会话 URL 为你提供一个实时仪表板,你可以在脚本运行时监控进度并检查结果。

大型数据集的后台作业

以上所有操作已经是 async/await_async 变体是 fire‑and‑forget:它们将工作提交到服务器后立即返回,以便你的脚本可以继续执行。

from everyrow.ops import screen_async

async with create_session(name="Background Screening") as session:
    task = await screen_async(
        session=session,
        task="Remote‑friendly, senior‑level, salary disclosed",
        input=large_dataframe,
    )
    print(f"Task ID: {task.task_id}")
    # do other work...
    result = await task.await_result()

如果你的脚本崩溃,可以使用任务 ID 稍后恢复结果:

from everyrow import fetch_task_data

df = await fetch_task_data("12345678-1234-1234-1234-123456789abc")

超越筛选:其他操作

OperationWhat it does
筛选根据需要判断的标准过滤行
排序根据定性因素为行打分
去重当模糊字符串匹配不足时进行去重
合并当键不完全匹配时连接表
研究运行网络代理对每行进行研究

每个操作接受自然语言任务描述和一个数据框,并返回结构化结果。模式相同,能力不同。

何时使用(以及何时不使用)

everyrow 在逻辑易于描述但难以编码的场景中表现出色:筛选、排序、去重和丰富任务,这些任务的标准需要判断、常识或模糊匹配。

不是 确定性转换的替代品。如果你能写出可靠的 pandas 过滤,例如 df[df["salary"] > 100_000],就应该使用它。everyrow 适用于包含自然语言、格式不一致或其他模糊值的列。

权衡: 基于 LLM 的操作会带来延迟和成本。请审慎使用它们,仅在管道中真正需要类人推理的部分使用。

扩展说明 – 在上述职位筛选示例中,处理 5 行需要几秒钟,费用不到一分钱。对于 10 000 行,你需要使用异步变体,并且应预期耗时为分钟而非毫秒。The Getting Started docs cover scaling patterns for larger datasets.


入门

pip install everyrow
export EVERYROW_API_KEY=your_key_here

everyrow.io/api-key 获取免费 API 密钥 —— 包含 $20 免费额度

完整文档和更多示例: everyrow.io/docs/getting-started


资源

0 浏览
Back to Blog

相关文章

阅读更多 »

新文章

您确定要隐藏此 comment 吗?它将在您的 post 中被隐藏,但仍可通过 comment 的 permalink 查看。Hide child comments 如我们……

你的文档在欺骗用户

让我直说:你的文档现在可能在对用户撒谎。不是恶意的,也不是有意的,但仍然是在撒谎。那个 endpoint 你 dep...

设置 Ollama、NGROK 和 LangChain

!Breno A.https://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fu...