Skip to content

feat: support ordinal queries (first/second/last) - #30

Closed
Djain912 wants to merge 1 commit into
mainfrom
feat/issue-25-ordinal-queries
Closed

feat: support ordinal queries (first/second/last)#30
Djain912 wants to merge 1 commit into
mainfrom
feat/issue-25-ordinal-queries

Conversation

@Djain912

Copy link
Copy Markdown
Collaborator

Summary

Implements issue #25 by supporting ordinal queries to select an element by position among matching candidates.

What changed

  • Added ordinal query parsing for first, second, third, numeric ordinals (1st, 2nd, 3rd, ...), and last.
  • Added guard logic to avoid false positives for semantic phrases (for example, first name).
  • Added deterministic tie-breaking in combined matcher.
  • Added ordinal selection in document order after matching.
  • Added parser and integration tests for normal, edge, and out-of-range ordinal cases.
  • Added docs/examples in README and CLI reference.

Example queries now supported

  • second button
  • third menu item
  • last input field

Validation

  • go test ./internal/engine -run "TestParseOrdinalConstraint_BasicPatterns|TestCombinedMatcher_OrdinalQuery_SecondButton|TestCombinedMatcher_OrdinalQuery_LastInputField|TestCombinedMatcher_OrdinalQuery_OutOfRangeReturnsNoMatch|TestCombinedMatcher_OrdinalGuard_DoesNotTreatFirstNameAsOrdinal" -count=1
  • go test -count=1 ./...
  • go vet ./...
  • go build ./...
  • go build -o semantic.exe ./cmd/semantic
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0 run
  • Manual CLI checks with duplicated controls:
    • second button -> second result by order
    • last input field -> last result by order
    • fifth button (out-of-range) -> no result

Environment note

  • Local Windows race run (go test -race ./...) is blocked by local 64-bit cgo toolchain availability (cc1.exe ... 64-bit mode not compiled in).
  • CI runs on Ubuntu and will execute race tests there.

Closes #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ordinal queries (first, second, last)

2 participants