开发者
You're truncating bios with `.slice()`. `Intl.Segmenter` knows where the emoji actually end.
A 30-character bio limit that cuts off mid-emoji isn't a rendering bug — it's .length counting UTF-16 code units instead of what's on screen. Intl.Segmenter counts graphemes, words, and sentences the way a reader actually sees them, and every major browser supports it now.
AI 资讯
Build a caption QA harness in Python: WER, missed entities, timing and reading rate
TL;DR We're building a caption evaluation harness that scores a WebVTT file on four axes instead of one: word error rate under a fixed normalizer, missed entity rate on domain terms, median cue timing offset, and reading rate in characters per second. Python 3.12, jiwer , whisper_normalizer , webvtt-py . Run it on every model or vendor change. A caption file can score 96% accurate and still be unusable. WER counts substitutions, insertions and deletions and weighs each one the same, so "fifteen milligrams" becoming "fifty milligrams" costs exactly as much as "the" becoming "a". It also throws away every timestamp before it starts, which means synchronization and readability are invisible to it. Let's measure the other three things. 0. Setup 🛠️ python3 -m venv .venv && source .venv/bin/activate pip install jiwer whisper_normalizer webvtt-py $ pip list | grep -Ei 'jiwer|whisper|webvtt' jiwer <your version> webvtt-py <your version> whisper-normalizer <your version> Pin whatever you install, and pin it in CI. The APIs below move between majors, which is exactly why the next tip exists. 💡 Tip: jiwer.compute_measures() is gone in recent versions. It is jiwer.process_words() now, and it returns a WordOutput dataclass. Most blog posts you will find still use the old name. 1. Parse the VTT into text plus timings # captions.py from dataclasses import dataclass import webvtt @dataclass class Cue : start : float end : float text : str @property def duration ( self ) -> float : return self . end - self . start @property def lines ( self ) -> list [ str ]: return self . text . split ( " \n " ) @property def flat ( self ) -> str : return " " . join ( l . strip () for l in self . lines ) @property def chars_per_second ( self ) -> float : return len ( self . flat ) / self . duration if self . duration > 0 else float ( " inf " ) def _to_seconds ( ts : str ) -> float : h , m , s = ts . split ( " : " ) return int ( h ) * 3600 + int ( m ) * 60 + float ( s ) def load_vtt ( path : str ) -
AI 资讯
Frame-accurate FFmpeg trimming without re-encoding the whole file
TL;DR -c copy can only cut on keyframes, so your 12.4s trim starts wherever the last keyframe was. We'll build a smart-trim script that probes keyframe positions with ffprobe , re-encodes only the head and tail fragments, stream copies everything between them, and concatenates the three. Frame accurate output, encoding cost proportional to two GOPs instead of the whole file. Tested with FFmpeg 9.0 "Lei" (released 2026-08-04) and Node 22.x. The JS is ESM, so put "type": "module" in your package.json before running any of it. Everything here also works on FFmpeg 7.x and 8.x; nothing we use is new. The problem, in two commands 🎬 # fast, and wrong ffmpeg -ss 12.4 -i input.mp4 -t 20 -c copy fast.mp4 ffprobe -v error -show_entries format = start_time,duration -of default = nw = 1 fast.mp4 # start_time=0.000000 # duration=20.388000 <- we asked for 20, starting at 12.4 The clip is long by the distance from our requested start back to the previous keyframe, and every frame in it is shifted earlier than the user asked for. Stream copy moves compressed packets without decoding them. Most frames in a compressed stream only describe the difference from their neighbors, so the only place you can start is a keyframe. FFmpeg snaps back to the nearest preceding one, and your clip starts early. # accurate, and slow on a long source ffmpeg -ss 12.4 -i input.mp4 -t 20 -c :v libx264 -crf 20 -c :a aac slow.mp4 We want the accuracy of the second and roughly the cost of the first. 1. Look at your keyframes first Before writing any code, find out how bad the problem is for your content: ffprobe -v error -select_streams v:0 \ -show_entries packet = pts_time,flags \ -of csv = print_section = 0 input.mp4 | grep 'K' | head -20 0.000000,K__ 2.002000,K__ 4.004000,K__ 6.006000,K__ Two second GOPs here, so worst-case error is about two seconds. Screen recorders and some camera output emit keyframes on scene change only, and there the gaps can be 30 seconds or more. That distribution is the real spe
AI 资讯
15 NLP Techniques Every Backend Developer Should Know in 2026 (With Code Examples)
NLP stopped being a data science specialty about two years ago. It's backend infrastructure now. If you're building APIs that process user input, handle search, manage support tickets, parse documents, or power any feature where humans communicate with your system in natural language, you're doing NLP whether you call it that or not. The difference between a backend developer who understands NLP techniques and one who doesn't is the difference between building a search endpoint that actually finds what users want and building one that matches keywords and returns garbage for anything slightly ambiguous. This is the reference guide we wish we'd had when we started integrating NLP into production backend services. Fifteen techniques, each with a runnable code snippet, ordered from the most immediately useful to the most architecturally advanced. Every example runs in Python. Install the dependencies as needed, we'll note them for each technique. 1. Text tokenization The atomic operation. Everything else depends on splitting text into meaningful units. import spacy nlp = spacy . load ( " en_core_web_sm " ) text = " Dr. Smith ' s appointment at 3:30pm was rescheduled. " doc = nlp ( text ) tokens = [ token . text for token in doc ] # ['Dr.', 'Smith', "'s", 'appointment', 'at', '3:30pm', 'was', 'rescheduled', '.'] SpaCy handles the edge cases that naive split-on-whitespace misses, abbreviations, contractions, timestamps. If your backend processes any user-generated text, tokenization is step zero. 2. Named entity recognition (NER) Extracting structured data from unstructured text. Names, dates, amounts, locations, the things your database actually needs. doc = nlp ( " Send $5,000 to Acme Corp in Singapore by March 15th " ) for ent in doc . ents : print ( f " { ent . text : 20 } { ent . label_ } " ) # $5,000 MONEY # Acme Corp ORG # Singapore GPE # March 15th DATE We use NER on every inbound support ticket to auto-tag customer, product, and amount entities before the ticket
AI 资讯
The UK Power Grid Has a Phantom Data Center Problem
The UK’s energy regulator is using a variety of tricks to keep speculative data center projects from plugging into the power grid. The country’s AI ambitions hang in the balance.
AI 资讯
A Practical Pattern for Giving AI Agents Access to External APIs with MCP
Connecting an AI agent to one API is straightforward. Connecting it to many changing APIs—without filling the model context with hundreds of tool definitions—is a different problem. Disclosure: This article was prepared for QVeris and uses QVeris as the implementation example. This tutorial presents a practical pattern for developers building agents that need current external data: discover → inspect → probe → call . Instead of exposing every possible operation up front, the agent discovers the capabilities relevant to the current task, verifies the selected tool, validates its inputs, and only then executes it. TL;DR: Keep the agent's initial tool surface small. Let it discover a capability by intent, inspect the exact schema, probe the request without execution, and make a real call only after the parameters and expected cost are understood. Contents Why a large static tool list becomes difficult The four-step capability workflow Connecting a hosted MCP server A concrete example Production checklist Why a large static tool list becomes difficult An agent connected directly to several providers may need to understand different authentication schemes, parameter conventions, response formats, and error behaviors. Loading every operation into context can also make tool selection less reliable. Model Context Protocol (MCP) provides a standard way for clients to connect to tools and data sources. The protocol solves the connection boundary, but developers still need a strategy for controlling how many capabilities the model sees and when execution is allowed. A compact routing layer is useful when: the agent needs data from multiple API providers; the appropriate provider depends on the user's request; schemas or available operations may change; calls can consume credits or trigger rate limits; you want to validate inputs before executing a paid operation. The four-step capability workflow 1. Discover The agent starts with a natural-language description of the capabilit
科技前沿
Amazon just tripled its order of Nvidia chips over ‘surging demand’
Amazon is adding another 2 million Nvidia GPU chips to its data centers over the next two years. But this extended partnerships stretches beyond buying more chips.
开发者
Meta’s $18B child-safety deal hinges on age-verification tech that doesn’t work well
The historic settlement reignites ongoing concern around how age-verification technology puts privacy at risk.
AI 资讯
Nvidia is about to be a hundred-billion-dollar-a-quarter company
Nvidia's predicting it will pull in $108 billion in revenue within just a few months. It wouldn't be the first company to rake in over $100 billion in quarterly revenue - Amazon, Apple, and Alphabet have repeatedly reached the milestone. Nvidia said in its latest earnings report that it brought in a record $96.2 billion […]
AI 资讯
Building Local-First Web Apps: Parsing HTML and PDFs to Markdown in the Browser
Local-first and privacy-focused web utilities are having a massive comeback. With browser engines becoming faster and WebAssembly/Web Workers maturing, there is rarely a reason to push sensitive user documents to an external backend for simple conversions. While building MD-Convert (a zero-upload document to Markdown converter), I explored how to parse real-world documents into clean Markdown entirely on the client side. Here is a breakdown of the core architecture and libraries that make purely in-browser document processing possible. 1. Converting Web Articles with Readability + Turndown Converting messy web markup into clean Markdown involves two distinct steps: Content Extraction: Stripping ads, navbars, sidebars, and trackers. HTML-to-Markdown Transformation: Translating semantic DOM nodes into markdown tokens. Mozilla’s @mozilla/readability paired with turndown is an incredible combination for this: import { Readability } from ' @mozilla/readability ' ; import TurndownService from ' turndown ' ; function htmlToCleanMarkdown ( rawHtmlDocument , sourceUrl ) { // 1. Extract pure article content const reader = new Readability ( rawHtmlDocument ); const article = reader . parse (); if ( ! article || ! article . content ) { throw new Error ( ' Unable to extract main content ' ); } // 2. Initialize Turndown const turndownService = new TurndownService ({ headingStyle : ' atx ' , codeBlockStyle : ' fenced ' }); // Ensure image URLs remain absolute turndownService . addRule ( ' absoluteImages ' , { filter : ' img ' , replacement : ( content , node ) => { const src = node . getAttribute ( ' src ' ); const alt = node . getAttribute ( ' alt ' ) || '' ; if ( ! src ) return '' ; try { const absoluteUrl = new URL ( src , sourceUrl ). href ; return `\n\n` ; } catch { return `\n\n` ; } } }); return turndownService . turndown ( article . content ); } Offloading Heavy PDF Parsing to Web Workers Parsing large PDFs using pdf
开发者
Anthropic continues compute-gobbling streak in $45 billion deal with Nscale
The new deal with the infrastructure provider is the latest example of Anthropic's white-hot compute-gobbling streak.
科技前沿
The Meta Settlement Will Put Limits on Instagram for Teens. They’re Still Vulnerable
Child safety groups and former Meta employees welcome proposed changes to how the company’s platforms will work for teens. They also think states should have demanded more.
AI 资讯
Google announces Gemini 3.5 Transcribe for AI-powered speech-to-text
The AI that powers Gboard's Rambler is coming to more Google products, including Chrome.
AI 资讯
What We Still Don’t Know About OpenAI’s Hugging Face Hack
The AI giant acknowledges that it could have done far more to prevent its AI agents from going rogue. But it still fails to explain why it didn't see this fiasco coming.
AI 资讯
The inside story on why OpenAI agents hacked Hugging Face
The models responsible for last month’s agent hack of Hugging Face had been inadvertently trained to cheat and to communicate with each other, according to an OpenAI technical report released today. The hack, which a group of agents undertook to find solutions for a cybersecurity test that they were stuck on, has confirmed some experts’…
产品设计
Flipboard acquires Graze, the feed builder working to monetize the open social web
Flipboard is acquiring Bluesky feed-building startup Graze, bringing its privacy-friendly ad technology and creator monetization tools into Flipboard’s growing open social web ecosystem.
AI 资讯
The Humanoids at China’s Robot Games Were Faster Than Usain Bolt—but I’m More Impressed by Their Tweezer Mastery
Beijing’s endlessly delightful Robot Games featured tons of impressive stunts. But the most mind-blowing tricks challenged the humanoid’s brain, not its brawn.
AI 资讯
Candidates Are Signing a Pact Promising Action on Data Centers and AI Safety
More than 15 politicians from across the country have signed on to the AI Pact, vowing to regulate data centers and AI. “We’ve got to get this right,” says Senate candidate Dan Osborn of Nebraska.
AI 资讯
Meta agrees to sweeping changes to restrict kids’ access to its apps as part of settlement with states
One of the most notable changes is that Meta plans to implement a daily two-hour time limit for teens that can only be disabled with parental permission.
AI 资讯
What Changes When Converting SVG to React Components (JSX & TSX)
TL;DR SVG attributes like stroke-width become strokeWidth in JSX. class → className . Numeric values become {expressions} . Inline styles become objects. xmlns and XML comments are removed. The converter outputs either JSX or TSX with SVGProps . Use automation (SVGR or SVGCode) for large icon sets. Import only what you need to keep bundle sizes small. Converting an SVG file into a React component is more than just pasting markup into a .jsx or .tsx file. React uses JSX, which is stricter than HTML/XML and requires specific changes to ensure your SVG renders correctly and remains maintainable. In this post, we’ll explore every transformation that takes place—from attribute casing to TypeScript typing—so you understand exactly what our free SVG to React converter does under the hood. What Actually Changes? Kebab‑case Attributes Become camelCase SVG uses attributes like stroke-width , fill-rule , and clip-path . JSX requires property names that are valid JavaScript identifiers, so these become: SVG Attribute React JSX stroke-width strokeWidth stroke-linecap strokeLinecap stroke-linejoin strokeLinejoin fill-rule fillRule clip-path clipPath font-size fontSize stroke-dasharray strokeDasharray class Becomes className In SVG you write class="icon" , but in JSX you must use className="icon" because class is a reserved word in JavaScript. Numeric Attributes Are Converted to Expressions React treats string values differently from numbers. For numeric SVG attributes like width , height , x , y , cx , r , etc., the converter outputs {value} instead of "value" . <circle cx="12" cy="12" r="10" /> becomes: < circle cx = { 12 } cy = { 12 } r = { 10 } /> Inline Styles Become Objects If your SVG uses style="fill: red; stroke: blue;" , it must be converted to a JavaScript object: style = {{ fill : ' red ' , stroke : ' blue ' }} xmlns and Namespace Declarations Are Removed React automatically uses the correct SVG namespace, so xmlns and other XML namespace declarations are unnecessary a