diff --git a/src/opennlp/span.clj b/src/opennlp/span.clj index c311f12..f7d9ce0 100644 --- a/src/opennlp/span.clj +++ b/src/opennlp/span.clj @@ -33,7 +33,8 @@ (defn merge-spans "Given two overlapping spans where the first comes before the second, return a merged span with the type of the first." - [A B] (assoc A :end (:end B))) + [A B] + (assoc A :end (:end B))) (defn span-disjoint? "Return true of A does not overlap B." @@ -42,13 +43,14 @@ (defn span-overlaps? "Return true if A overlaps B." - [A B] (not (span-disjoint? A B))) + [A B] + (not (span-disjoint? A B))) (defn intersection-span - "Return the intersection of two spans as a span." + "Return the intersection of two spans as a span. Type of new span is :intersection." [A B] {:pre [(not (span-disjoint? A B))]} - (make-span (max (:start A) (:start B)) (min (:end A) (:end B)) nil)) + (->Span (max (:start A) (:start B)) (min (:end A) (:end B)) :intersection)) (defn span-length "Return the length of the span." @@ -63,11 +65,10 @@ (defn shift-span "Shift a span by i positions." [span i] - (make-span (+ (:start span) i) (+ (:end span) i) (:type span))) + (->Span (+ (:start span) i) (+ (:end span) i) (:type span))) (defn between-span - "Return a span of the area between two spans A and B. Precondition: (:end A) - < (:start B)." + "Return a span of the area between two spans A and B. Type of new span is :between." [a b] - {:pre [(< (:end a) (:start b))]} - (make-span (:end a) (:start b) :between)) + {:pre [(<= (:end a) (:start b))]} + (->Span (:end a) (:start b) :between))