#lang rosette/safe (require rosette/lib/synthax) (current-bitwidth #f) ; Scenario: We've segmented a bunch of PDFs into individual text elements. ; A user is trying to turn the PDFs into structured data, and one of their ; tasks is to identify which text elements represent titles. ; They've labeled a few elements as titles or not tiles. Text elements ; are also labeled with their font size and the number of words inside. ; The goal of this assignment is to learn a program to apply to the ; remaining texts in the user's corpus to categorize them as titles or ; not titles. ; ; This is a sample (below), but feel free to play around with more realistic ; scenarios. :) (define texts [list (list 20 450 #f) (list 30 1200 #f) (list 70 4 #t)]) (define (get-font-size t) (list-ref t 0)) (define (get-num-words t) (list-ref t 1)) (define (get-is-title t) (list-ref t 2)) (get-font-size (list-ref texts 0)) (get-num-words (list-ref texts 0)) (get-is-title (list-ref texts 0)) ; Now write a synthesizer that can learn a program for labeling texts as titles ; or not titles based on the examples in our texts list. ; Hint: if you end up using the #:forall (list i) approach in your solution, ; remember that i can be less than 0 and greater than the length of the texts ; list.