+
+let lookup_in_library interactive_user_uri_choice input_or_locate_uri item =
+ let dbd = LibraryDb.instance () in
+ let choices_of_id id =
+ let uris = Whelp.locate ~dbd id in
+ let uris =
+ match uris with
+ | [] ->
+ (match
+ (input_or_locate_uri
+ ~title:("URI matching \"" ^ id ^ "\" unknown.")
+ ?id:(Some id) ())
+ with
+ | None -> []
+ | Some uri -> [uri])
+ | [uri] -> [uri]
+ | _ ->
+ interactive_user_uri_choice ~selection_mode:`MULTIPLE
+ ?ok:(Some "Try selected.")
+ ?enable_button_for_non_vars:(Some true)
+ ~title:"Ambiguous input."
+ ~msg: ("Ambiguous input \"" ^ id ^
+ "\". Please, choose one or more interpretations:")
+ ~id
+ uris
+ in
+ List.map
+ (fun uri ->
+ (UriManager.string_of_uri uri,
+ let term =
+ try
+ CicUtil.term_of_uri uri
+ with exn ->
+ assert false
+ in
+ fun _ _ _ -> term))
+ uris
+ in
+ match item with
+ | DisambiguateTypes.Id id -> choices_of_id id
+ | DisambiguateTypes.Symbol (symb, _) ->
+ (try
+ List.map DisambiguateChoices.mk_choice
+ (TermAcicContent.lookup_interpretations symb)
+ with
+ TermAcicContent.Interpretation_not_found -> [])
+ | DisambiguateTypes.Num instance ->
+ DisambiguateChoices.lookup_num_choices ()
+;;
+