如何将分数识别为实体?自定义实体是否需覆盖所有分数变体?
Hey there! Let's work through your questions clearly and practically:
1. 是否需要自定义实体?
Definitely yes. Most off-the-shelf entity recognition tools are built to spot standalone numbers, but they don’t natively recognize fractional expressions—whether written in word form like "1 third" or symbol form like "2/5"—as distinct, meaningful entities.
Since your system already catches the trailing numbers (like 9 or twenty), adding a custom fraction entity will let you map these expressions to their actual numerical values (e.g., "1 third" → 1/3, "2/5" → 0.4) and properly handle the "X of Y" calculation logic you’re targeting.
2. 是否需要写出所有需支持的分数变体?
You don’t need to list every possible variant upfront, but you should cover the most common categories first, then expand based on real-world usage. Start with these core types:
- Word-based fractions:
- Simple fractions: "1 third", "two fifths", "a quarter", "half"
- Mixed fractions: "one and a half", "3 and two thirds"
- Symbol/number-based fractions:
- Regular fractions: "2/5", "3/4"
- Mixed fractions with symbols: "1½", "2¾"
- Hyphenated word fractions: "three-quarters", "one-half"
Once you’ve implemented these, test with your target queries (like your examples: "What is 1 third of 9" and "what is 2/5 of twenty") and add edge cases as they come up (e.g., "five-eighths" or decimal equivalents like "0.5" if you need them).
内容的提问来源于stack exchange,提问作者Somk

