Natural Language Processing
Compare complete subword paths
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.
Context for this challenge
Return the negative logarithm cost for each supplied piece probability.
The same word may have several complete segmentations. We have probabilities for the candidate pieces and want the most probable complete sequence. Turning probabilities into additive costs lets us compare whole routes using the path tools we already know.
Inspect the component calculation
Probabilities to path costs( Probability table: Piece probabilities )
Examples and results
- Piece probabilities
{ "ab": 0.4, "cd": 0.3, "a": 0.1, "bcd": 0.2 }- Required result
{ "ab": 0.9163, "cd": 1.204, "a": 2.3026, "bcd": 1.6094 }
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.
Individually common pieces lose to a complete word
This check uses the pieces from “Turn piece probabilities into additive route costs”.
BOTIE
- Text
sunflower
- Piece probabilities
{ "sun": 0.4, "flower": 0.4, "sunflower": 0.2 }
Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
Why must the logarithm transformation preserve the order of complete path preferences?
A useful score transformation changes numerical computation without changing the declared optimisation objective.
This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out.
Work through the Python challenges →