Yes, this works! This meets my requirements.


Thank you Wolfgang.


This is similar to my first effort, which never fires. Can you explain the
difference between the two rules.


My first effort


(defrule find-lines-per-block-ssn

           ?word1 <- (word (page ?page) (rowNumber ?rowNumber1) (type ssn)
(text ?text1)  )

            ?word2 <- (word (page ?page) (rowNumber ?rowNumber2&:(<>
?rowNumber1 ?rowNumber2)) (type ssn) (text ?text2) )


        (word (page ?page) (rowNumber ?rowNumberVar&:(< (abs (-
?rowNumberVar ?rowNumber1) ) (abs (- ?rowNumber2 ?rowNumber1) ) ) ) )



    ; do something



Thanks to everyone who responded. This was my first message to the forum.
Thanks for all the quick and helpful responses.




From: [] On
Behalf Of Wolfgang Laun
Sent: Wednesday, August 24, 2011 10:27 AM
Subject: Re: JESS: Find the minimum


Not sure whether this meets all the possibly undisclosed requirements, not
sure about the relation of row numbers and words, but this is firing one,
even when there is words from more than one page:

(defrule find-lines-per-block-ssn
  ?w1 <- (word (page ?page)
               (rowNumber ?rowNumber1)
               (type ssn)
               (text ?text1))
  ?w2 <- (word (page ?page)
               (rowNumber ?rowNumber2 &:(< ?rowNumber1 ?rowNumber2))
               (type ssn)
               (text ?text2))
  (not (and (word (page ?px)
                  (rowNumber ?rn1)
                  (type ssn))
            (word (page ?px)
                  (rowNumber ?rn2 &:(< ?rn1 ?rn2))
                  (type ssn))
            (test (< (- ?rn2 ?rn1) (- ?rowNumber2 ?rowNumber1)))))
  (printout t (fact-slot-value ?w1 text) " - " (fact-slot-value ?w2 text)


Reply via email to