Skip to content

Commit

Permalink
Add increment IncrConstr for inserting constraints into query
Browse files Browse the repository at this point in the history
  • Loading branch information
sebferre committed Jun 1, 2022
1 parent 6550161 commit f9c0669
Show file tree
Hide file tree
Showing 5 changed files with 4,518 additions and 4,471 deletions.
1 change: 1 addition & 0 deletions doc/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 481,7 @@ This is the datatype of individual suggestions, whatever their category (terms,
- `{ type: "IncrType", uri: string }`
- `{ type: "IncrRel, uri: string, orientation: ("Fwd" | "Bwd") }`
- `{ type: "IncrLatLong", latlong: sparklis-latlong }`
- `{ type: "IncrConstr", constr: sparklis-constr, filterType: ("OnlyIRIs" | "OnlyLiterals" | "Mixed" ) }`
- `{ type: "IncrHierarchy", transitiveRelInCtx: bool }`
- `{ type: "IncrSim", pred: sparklis-pred, argS: sparklis-arg, argO: sparklis-arg }`
- `{ type: "IncrOrder", order: sparklis-order }`
Expand Down
1 change: 1 addition & 0 deletions html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 645,7 @@ let freq_text_html_increment_frequency ~(filter : Lisql.increment -> bool) focus
| IncrId _ -> 2, None
| IncrInput _ -> 3, None
| IncrTerm _ -> 4, None
| IncrConstr _ -> 5, None (* not expected to appear in increment list *)
(* modifier increments *)
| IncrName _ -> 1, Some grammar#tooltip_input_name
| IncrOrder (Highest _) -> 2, Some grammar#tooltip_highest
Expand Down
3 changes: 3 additions & 0 deletions lisql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 1494,7 @@ type increment =
| IncrType of Rdf.uri
| IncrRel of Rdf.uri * modif_p2
| IncrLatLong of latlong
| IncrConstr of constr * filter_type
| IncrTriplify
| IncrHierarchy of bool (* trans_rel *)
(* trans_rel: to indicate that relation in context can be made transitive *)
Expand Down Expand Up @@ -1555,6 1556,7 @@ let js_increment_map : increment Jsutils.js_map =
"IncrRel", [| "uri", `String;
"orientation", js_custom_spec js_orientation_map |];
"IncrLatLong", [| "latlong", js_custom_spec js_latlong_map |];
"IncrConstr", [| "constr", js_custom_spec js_constr_map; "filterType", js_custom_spec js_filter_type_map |];
"IncrHierarchy", [| "transitiveRelInCtx", `Bool |];
(* trans_rel: to indicate that relation in context can be made transitive *)
"IncrSim", [| "pred", js_custom_spec js_pred_map;
Expand Down Expand Up @@ -2473,6 2475,7 @@ let insert_increment (incr : increment) (focus : focus) : (focus * delta) option
| IncrType c -> insert_type c focus
| IncrRel (p,m) -> insert_rel p m focus
| IncrLatLong ll -> insert_latlong ll focus
| IncrConstr (constr,ft) -> insert_constr constr ft focus
| IncrTriple arg -> insert_triple arg focus
| IncrTriplify -> insert_triplify focus
| IncrHierarchy trans_rel -> toggle_hierarchy trans_rel focus
Expand Down
26 changes: 23 additions & 3 deletions lisql2nl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 296,24 @@ let word_of_selection_op grammar = function
| AndSel | NAndSel -> `Op grammar#and_
| OrSel | NOrSel -> `Op grammar#or_
| AggregSel -> `Op ""

let word_of_incr grammar = function

let word_of_constr grammar = function
| True -> `Op grammar#all
| MatchesAll _ | MatchesAny _ -> `Op grammar#matches
| IsExactly _ -> `Op grammar#is_exactly
| StartsWith _ -> `Op grammar#starts_with
| EndsWith _ -> `Op grammar#ends_with
| After _ -> `Op grammar#after
| Before _ -> `Op grammar#before
| FromTo _ -> `Op grammar#interval_from
| HigherThan _ -> `Op grammar#higher_or_equal_to
| LowerThan _ -> `Op grammar#lower_or_equal_to
| Between _ -> `Op grammar#interval_between
| HasLang _ -> `Op grammar#language
| HasDatatype _ -> `Op grammar#datatype
| ExternalSearch _ -> `Op grammar#matches

let word_of_incr grammar = function (* to serve in filtering increments by kwd *)
| IncrSelection (selop,_) -> word_of_selection_op grammar selop
| IncrInput (s,dt) -> `Op (string_of_input_type grammar dt)
| IncrTerm t -> word_of_term t
Expand All @@ -307,6 323,7 @@ let word_of_incr grammar = function
| IncrType c -> word_of_class c
| IncrRel (p,_) -> fst (word_syntagm_of_property grammar p)
| IncrLatLong _ -> `Op grammar#geolocation
| IncrConstr (constr,ft) -> word_of_constr grammar constr
| IncrTriple _ -> `Relation
| IncrTriplify -> `Relation
| IncrHierarchy trans_rel -> `Op grammar#in_
Expand Down Expand Up @@ -1603,7 1620,10 @@ let xml_of_incr grammar ~id_labelling (focus : focus) (incr : increment) : xml =
| `TransAdj -> xml_ellipsis @ Kwd grammar#is :: Word word :: []))
| IncrLatLong _ll ->
xml_incr_coordinate grammar focus
(Kwd grammar#relative_that :: Kwd grammar#has :: xml_a_an grammar [Word (`Op grammar#geolocation)])
(Kwd grammar#relative_that :: Kwd grammar#has :: xml_a_an grammar [Word (`Op grammar#geolocation)])
| IncrConstr (constr,ft) ->
xml_incr_coordinate grammar focus
(Kwd grammar#relative_that :: xml_of_constr grammar ~id_labelling constr)
| IncrTriple (S | O as arg) ->
xml_incr_coordinate grammar focus
(Kwd grammar#relative_that :: Kwd grammar#has :: xml_a_an grammar [Word `Relation] @ (if arg = S then Kwd grammar#rel_to :: xml_ellipsis else Kwd grammar#rel_from :: xml_ellipsis))
Expand Down
Loading

0 comments on commit f9c0669

Please sign in to comment.