; _____ _ _____ ; | ___|__ _ __ ___(_) __ _ _ __ |_ _| _ _ __ ___ ___ ; | |_ / _ \| '__/ _ \ |/ _` | '_ \ | || | | | '_ \ / _ \/ __| ; | _| (_) | | | __/ | (_| | | | | | || |_| | |_) | __/\__ \ ; |_| \___/|_| \___|_|\__, |_| |_| |_| \__, | .__/ \___||___/ ; |___/ |___/|_| (define-foreign-type parse-options (c-pointer (struct "Parse_Options_s"))) (define-foreign-type cmd-options (c-pointer (struct "Command_Options_s"))) (define-foreign-type cost-model (c-pointer (struct "Cost_Model_s"))) (define-foreign-type resources (c-pointer (struct "Resources_s"))) (define-foreign-type dictionary (c-pointer (struct "Dictionary_s"))) (define-foreign-type linkage (c-pointer (struct "Linkage_s"))) (define-foreign-type sub-linkage (c-pointer (struct "Sublinkage_s"))) (define-foreign-type sentence (c-pointer (struct "Sentence_s"))) @(heading "Example Usage") @(source (use (prefix link-grammar lg:)) (define (display-linkage sentence opts index) (let* ([links-found (lg:linkages-found sentence)] [linkage (lg:create-linkage index sentence opts)]) (when linkage (let ([constituents (lg:get-constituents linkage lg:display-multi-line)] [diagram (lg:get-diagram linkage #t 80)]) (print constituents) (print diagram) (lg:delete-linkage! linkage))) (when (<= index links-found) (display-linkage sentence opts (+ index 1))))) (define (parse text dictionary opts) (let* ([sentence (lg:create-sentence text dictionary)] [num-linkages (lg:parse-sentence sentence opts)]) (when (= num-linkages 0) (lg:set-min-null-count! opts 1) (lg:set-max-null-count! opts (lg:sentence-length sentence)) (set! num-linkages (lg:parse-sentence sentence opts))) (display-linkage sentence opts 0) (lg:delete-sentence! sentence))) ; Main Entry (define dictionary (lg:create-default-dictionary)) (define opts (lg:init-opts)) (lg:set-linkage-limit! opts 1000) (lg:set-short-length! opts 10) (lg:set-verbosity! opts 1) (lg:set-max-parse-time! opts 30) (lg:set-linkage-limit! opts 1000) (lg:set-min-null-count! opts 0) (lg:set-max-null-count! opts 0) (lg:set-short-length! opts 16) (lg:set-islands-ok! opts #f) (parse "The black fox ran from the hunters" dictionary opts) (lg:delete-parse-options! opts) (lg:delete-dictionary! dictionary)) @(noop) @(text " (S (NP the black.a fox.n) (VP ran.v-d (PP from (NP the hunters.n))))") @(text " +------------------------Xp------------------------+ +----------->WV----------->+ | +---------Wd--------+ | | | +----Ds**x---+ | +----Jp----+ | | | +---A--+--Ss--+--MVp-+ +--Dmc-+ +--RW--+ | | | | | | | | | | LEFT-WALL the black.a fox.n ran.v-d from the hunters.n . RIGHT-WALL (S (NP the black.a fox.n) (VP ran.v-d (PP from (NP the hunters.n))))") @(text " +------------------------Xp------------------------+ +---------Wd--------+ | | +----Ds**x---+ +----Jp----+ | | | +---A--+--Ss--+--MVp-+ +--Dmc-+ +--RW--+ | | | | | | | | | | LEFT-WALL the black.a fox.n ran.v-d from the hunters.n . RIGHT-WALL") ; ____ _ _ _ ____ ___ ; / ___|(_)_ __ ___ _ __ | | ___ / \ | _ \_ _| ; \___ \| | '_ ` _ \| '_ \| |/ _ \ / _ \ | |_) | | ; ___) | | | | | | | |_) | | __/ / ___ \| __/| | ; |____/|_|_| |_| |_| .__/|_|\___| /_/ \_\_| |___| ; |_| @(heading "Simple Use") @(text "Parse a text using default values for the dictionary and parser") @(noop) (define (parse-with-default text) @("Parse text using default values" (@no-source) (text "string to parse") (@to "(values words links diagrams postscript)")) ;(@example "Example parsing text" (parse-default "The black fox ran from the hunters"))) ; Doesn't show very well) (when (not *DEFAULT-DICTIONARY*) (set! *DEFAULT-DICTIONARY* (create-default-dictionary))) (when (not *DEFAULT-OPTS*) (set! *DEFAULT-OPTS* (create-default-opts))) (let* ((sentence (create-sentence text *DEFAULT-DICTIONARY*)) (num-linkages (parse-sentence sentence *DEFAULT-OPTS*))) (when (= num-linkages 0) (begin (set-min-null-count! *DEFAULT-OPTS* 1) (set-max-null-count! *DEFAULT-OPTS* (sentence-length sentence)) (set! num-linkages (parse-sentence sentence *DEFAULT-OPTS*)))) (let loop ((words (list)) (links (list)) (diagrams (list)) (postscripts (list)) (index 0)) (let-values (((w l d p) (find-linkage sentence *DEFAULT-OPTS* index))) (if (>= (+ index 1) num-linkages) (begin (delete-sentence! sentence) (values (append words w) (append links l) (append diagrams d) (append postscripts p))) (loop (append words w) (append links l) (append diagrams d) (append postscripts p) (+ index 1))))))) (define *DEFAULT-DICTIONARY* #f) (define *DEFAULT-OPTS* #f) (define (delete-default-dictionary!) (delete-dictionary! *DEFAULT-DICTIONARY*)) (define (delete-default-opts!) (delete-parse-options! *DEFAULT-OPTS*)) (define (split-word-tags str) (let* ((val (s-split "." str)) (len (length val))) (if (> len 1) (cons (car val) (cadr val)) (cons (car val) "-")))) (define (linkage->sexp linkage index) (let* ((left-index (get-lword linkage index)) (right-index (get-rword linkage index)) (left (get-word linkage left-index)) (right (get-word linkage right-index)) (num-words (num-words linkage)) (words (get-words linkage)) (label (link-label linkage index)) (opt (list->string (filter char-upper-case? (string->list label)))) (args (list->string (filter char-lower-case? (string->list label)))) (left-word (split-word-tags left)) (right-word (split-word-tags right)) (result `((,opt . ,args) (,left-index . ,(cdr left-word )) (,right-index . ,(cdr right-word))))) (list result))) (define (find-linkage sentence *DEFAULT-OPTS* index) (let* ((links-found (linkages-found sentence)) (linkage (create-linkage index sentence *DEFAULT-OPTS*))) (if linkage (let* ((links (list)) (constituents (get-constituents linkage display-single-line)) (diagram (get-diagram linkage #t 100)) (len (num-links linkage)) (cnt 0) (words (get-words linkage))) (do-while (< cnt len) (set! links (append links (linkage->sexp linkage cnt))) (set! cnt (+ cnt 1))) (values (list words) (list links) (list diagram) (list (get-postscript linkage #t #t)))) (values (list) (list) (list) (list))))) (define (create-default-opts) (let ((opts (init-opts))) (set-linkage-limit! opts 1000) (set-short-length! opts 10) (set-verbosity! opts 1) (set-max-parse-time! opts 30) (set-linkage-limit! opts 1000) (set-min-null-count! opts 0) (set-max-null-count! opts 0) (set-short-length! opts 16) (set-islands-ok! opts #f) opts)) ; ____ _ ; / ___| ___ _ __ | |_ ___ _ __ ___ ___ ___ ; \___ \ / _ \ '_ \| __/ _ \ '_ \ / __/ _ \/ __| ; ___) | __/ | | | || __/ | | | (_| __/\__ \ ; |____/ \___|_| |_|\__\___|_| |_|\___\___||___/ @(heading "Sentences") @(text "A sentence is the API's representation of an input string, tokenized and interpreted according to a specific Dictionary. After a Sentence is created and parsed, various attributes of the resulting set of linkages can be obtained.") (define create-sentence @("creates a sentence object from the input string, using the Dictionary that was created earlier to tokenize and define words" (input "Input string (string)") (dictionary "dictionary to use") (@no-source) (@to "sentence")) (foreign-lambda sentence "sentence_create" c-string dictionary)) (define delete-sentence! @("Deletes the specificed sentence" (sentence "Sentence to be deleted (sentence)") (@no-source)) (foreign-lambda void "sentence_delete" sentence)) (define split-sentence @("Splits (tokenizes) the sentence up into its component words and punctuation. This includes splitting up certain run-on expressions, such as '12ft.' which is split into '12' and 'ft.'. If spell- guessing is enabled in the opts, the tokenizer will also separate most run-on words, i.e. pairs of words without an intervening space. This routine returns zero if successful; else a non-zero value if an error occurred." (@no-source) (sentence "Sentence to split (sentence)") (parse-options "") (@to "number")) (foreign-lambda int "sentence_split" sentence parse-options)) (define parse-sentence @("This routine represents the heart of the program. There are several things that are done when a sentence is parsed: 1. Word expressions are extracted from the dictionary and pruned. 2. Disjuncts are built. 3. A series of pruning operations is carried out. 4. The linkages having the minimal number of null links are counted. 5. A 'parse set' of linkages is built. 6. The linkages are post-processed. The 'parse set' is attached to the sentence, and this is one of the key reasons that the API is flexible and modular. All of the necessary information for building linkages is stored in the parse set. This means that other sentences can be parsed, possibly using different dictionaries and other parameters, without disturbing the information obtained from a call to sentence_parse. If another call to parse-sentence is made on the same sentence, the parsing information for the previous call is deleted. Like almost all of the other routines, this call is thread-safe: that is, sentences can be parsed concurrently in multiple threads." (@no-source) (sentence "") (parse-options "") (@to "number")) (foreign-lambda int "sentence_parse" sentence parse-options)) (define sentence-length @("Returns the length of the sentence" (@to "number") (sentence "") (@no-source)) (foreign-lambda int "sentence_length" sentence)) (define sentence-null-count @("Returns the number of words that failed to be linked into the rest of the sentence during parsing. This number is greater then zero whenever a word doesn't seem to fit anywhere in the parse, either due to poor grammar, or due to a shortcoming of the dictionary." (@no-source) (@to "number")) (foreign-lambda int "sentence_null_count" sentence)) (define linkages-found @("Returns the number of linkages that the search found" (@no-source) (@to "number")) (foreign-lambda int "sentence_num_linkages_found" sentence)) (define valid-linkages @("Returns the number of linkages that had no post-processing violations" (@no-source) (@to "number")) (foreign-lambda int "sentence_num_valid_linkages" sentence)) (define linkages-post-processed @("Returns the number of linkages that were actually post-processed" (@no-source) (@to "number")) (foreign-lambda int "sentence_num_linkages_post_processed" sentence)) (define linkages-violated @("Returns the number of post-processing violations that the i-th linkage had" "during the last call to sentence_parse." (@no-source) (@to "number")) (foreign-lambda int "sentence_num_violations" sentence int)) (define sentence-disjunct-cost @("Returns the sum total of all of the costs of all of the disjuncts used in the i-th linkage of the sentence. The higher the cost, the less likely that the parse is correct. Very roughly, this can be interpreted as if it was (minus) the log-liklihood of a parse being correct." (@no-source) (sentence "") (index "") (@to "number")) (foreign-lambda int "sentence_disjunct_cost" sentence int)) (define sentence-link-cost @("Returns the sum of the length of the links in the i-th parse. The ratio of this length, to the total length of the sentence, gives a rough measure of the complexity of the sentence. That is, long-range links between distant words indicates that the sentence may be hard to understand; alternately, it may indicate that the parse is not very accurate." (@no-source) (sentence "") (index "") (@to "number")) (foreign-lambda int "sentence_link_cost" sentence int)) ; ____ _ _ _ ; | _ \(_) ___| |_(_) ___ _ __ __ _ _ __ _ _ ; | | | | |/ __| __| |/ _ \| '_ \ / _` | '__| | | | ; | |_| | | (__| |_| | (_) | | | | (_| | | | |_| | ; |____/|_|\___|\__|_|\___/|_| |_|\__,_|_| \__, | ; |___/ @(heading "Dictionary") @(text "A Dictionary is the programmer's handle on the set of word definitions that defines the grammar. A user creates a Dictionary from a grammar file and post-process knowledge file, and then passes it to the various parsing routines.") (define create-dictionary-with-language @("Creates a dictionary with the specified language" (@no-source) (@to "dictionary") (language "Language to use (string)")) (foreign-lambda dictionary "dictionary_create_lang" c-string)) (define create-default-dictionary @("Looks for a dictionary in the same language as the current environment, and if one is found, creates a dictionary object." (@to "dictionary") (@no-source)) (foreign-lambda dictionary "dictionary_create_default_lang")) (define get-dictionary-language @("Returns the language of the specified dictionary" (@no-source) (dictionary "specified dictionary (dictionary)") (@to "string")) (foreign-lambda c-string "dictionary_get_lang" dictionary)) (define delete-dictionary! @("Deletes the specified dictionary" (@to "unspecified") (dictionary "specified dictionary (dictionary)") (@no-source)) (foreign-lambda void "dictionary_delete" dictionary)) (define set-dictionary-data-dir! @("Specify the file path to the dictionaries to use; to be effective, this routine must be called before the dictionaries are opened." (@to "unspecified") (path "Filename with path") (@no-source)) (foreign-lambda void "dictionary_set_data_dir" (const c-string))) (define get-dictionary-data-dir @("Returns the file path to the dictionaries" (@to "string") (@no-source)) (foreign-lambda c-string "dictionary_get_data_dir")) ; _ _ _ ; | | (_)_ __ | | ____ _ __ _ ___ ___ ; | | | | '_ \| |/ / _` |/ _` |/ _ \/ __|a ; | |___| | | | | < (_| | (_| | __/\__ \ ; |_____|_|_| |_|_|\_\__,_|\__, |\___||___/ ; |___/ @(heading "Linkages") (define create-linkage @("This function creates the index-th linkage from the (parsed) sentence sent. Several operations can be carried out on the resulting linkage; for example it can be printed, post-processed with a different post- processor, or information on individual links can be extracted. If the parse has a conjunction, then the linkage will be made up of two or more sublinkages." (@no-source) (@to "linkage")) (foreign-lambda linkage "linkage_create" size_t sentence parse-options)) (define delete-linkage! @("Delete the given linkage" (@to "unspecified") (@no-source) (linakge "")) (foreign-lambda void "linkage_delete" linkage)) (define num-words @("The number of words in the sentence for which this is a linkage." (@no-source) (linkage "") (@to "number")) (foreign-lambda size_t "linkage_get_num_words" linkage)) (define num-links @("The number of links used in the linkage." (@no-source) (linkage "") (@to "number")) (foreign-lambda size_t "linkage_get_num_links" linkage)) (define link-length @("The value returned by num-links procedure is the number of words spanned by the index-th link of the linkage." (@no-source) (linkage "") (index "(number)") (@to "number")) (foreign-lambda int "linkage_get_link_length" linkage size_t)) (define get-lword @("The value returned is the number of the word on the left end of the index-th link of the current sublinkage." (@no-source) (@to "number")) (foreign-lambda size_t "linkage_get_link_lword" linkage size_t)) (define get-rword @("The value returned is the number of the word on the right end of the index-th link of the current sublinkage." (@no-source) (@to "number")) (foreign-lambda size_t "linkage_get_link_rword" linkage size_t)) (define link-label @("The label on a link in a diagram is constructed by taking the 'intersection' of the left and right connectors that comprise the link. For example, 'I.p eat, therefore I.p think.v' has a Sp*i label on the link between the words I.p and eat is constructed from the Sp*i connector on the its left word, and the Sp connector on its right word. So, for this example, both link-label and link-llabel return 'Sp*i' while link-rlabel returns 'Sp' for this link." (@no-source) (linkage "") (index "") (@to "string")) (foreign-lambda c-string "linkage_get_link_label" linkage size_t)) (define link-llabel @("See link-label" (@to "string") (@no-source) (linkage "") (index "")) (foreign-lambda c-string "linkage_get_link_llabel" linkage size_t)) (define link-rlabel @("See link-label" (@to "string") (@no-source) (linkage "") (index "")) (foreign-lambda c-string "linkage_get_link_rlabel" linkage size_t)) (define num-domains @("num-domains, link-domain-names allow access to most of the domain structure extracted during post-processing. The index parameter in the first two calls specify which link in the linkage to extract the information for. In the 'I eat therefore I think' example above, the link between the words therefore and I.p belongs to two 'm' domains. If the linkage violated any post-processing rules, the name of the violated rule in the post-process knowledge file can be determined by a call to get-violation-name." (@no-source) (linkage "") (index "") (@to "number")) (foreign-lambda int "linkage_get_link_num_domains" linkage size_t)) (define link-domain-names @("Gets domain structure extracted during the post-processing" (@to "list") (@no-source) (linkage "") (word-index "Specifies which link in the linkage to extract the information for.")) (foreign-safe-lambda* scheme-object ((linkage links) (int index)) "const char** words = linkage_get_link_domain_names(links, index);" "C_word lst = C_SCHEME_END_OF_LIST, len, str, *a;" "int num_words = linkage_get_link_num_domains(links, index);" "int i;" "for (i = num_words - 1; i >= 0; i--) {" "len = strlen(words[i]);" "a = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(len));" "str = C_string(&a, len, words[i]);" "lst = C_a_pair(&a, str, lst);" "}" "C_return(lst);\n")) (define get-words @("Returns the array of word spellings or individual word spelling for the linkage. These are the subscripted spellings, such as 'dog.n'. The original spellings can be obtained by calls to sentence-get-word." (@no-source) (linkage "") (@to "list")) (foreign-safe-lambda* scheme-object ((linkage links)) "const char** words = linkage_get_words(links);" "C_word lst = C_SCHEME_END_OF_LIST, len, str, *a;" "int num_words = linkage_get_num_words(links);" "int i;" "for (i = num_words - 1; i >= 0; i--) {" "len = strlen(words[i]);" "a = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(len));" "str = C_string(&a, len, words[i]);" "lst = C_a_pair(&a, str, lst);" "}" "C_return(lst);\n")) (define get-word @("Returns the word spelling of an individual word" (@no-source) (@to "string") (linkage "") (word-number "The specific word")) (foreign-lambda c-string "linkage_get_word" linkage size_t)) (define disjunct-str @("Return a string showing the disjuncts that were actually used in association with the specified word in the current linkage. The string shows the disjuncts in proper order; that is, left-to-right, in the order in which they link to other words. The returned string can be thought of as a very precise part-of-speech-like label for the word, indicating how it was used in the given sentence; this can be useful for corpus statistics." (linkage "The specific linkage") (@no-source) (linkage "") (word-number "The specific word") (@to "string")) (foreign-lambda c-string "linkage_get_disjunct_str" linkage size_t)) (define disjunct-cost @("Return the cost of a word as used in a particular linkage, based on the dictionary." (@no-source) (@to "number")) (foreign-lambda number "linkage_get_disjunct_cost" linkage size_t)) (define disjunct-corpus-score @("Returns the cost based on the corpus-statistics database." (@no-source) (@to "number")) (foreign-lambda number "linkage_get_disjunct_corpus_score" linkage size_t)) (define get-constituents @("Returns the constituents for a particular linkage" (@no-source) (@to "string") (linkage "") (display-style "(number")) (foreign-lambda c-string "linkage_print_constituent_tree" linkage int)) (define get-diagram @("Returns the linkage diagram" (@no-source) (@to "string") (linkage "") (display-walls? "A boolean that indicates whether or not the wall-words, and the connectors to them, should be printed") (screen-width "The screen-width is an integer, indicating the number of columns that should be used during printing; long sentences that are wider than the number of columns will be automatically wrapped so that they always fit.")) (foreign-lambda c-string "linkage_print_diagram" linkage bool size_t)) (define get-postscript @("Returns the macros needed to print out the linkage in a postscript file." (@no-source) (@to "string") (linkage "") (display-walls? "A boolean that indicates whether or not the wall-words, and the connectors to them, should be printed") (print-ps-header? "A boolean that indicates whether or not postscript header boilerplate should be included.")) (foreign-lambda c-string "linkage_print_postscript" linkage bool bool)) (define get-disjuncts @("Returns the returns a string that shows all of the disjuncts, and their costs, that were used to create the linkage." (@no-source) (@to "string") (linkage "")) (foreign-lambda c-string "linkage_print_disjuncts" linkage)) (define get-links-domains @("Returns a string that lists all of the links and domain names for the linkage." (@no-source) (@to "string") (linkage "")) (foreign-lambda c-string "linkage_print_links_and_domains" linkage)) ; Not found in API docs ----------------------------------------------------- ;(define get-pp-msgs ; (foreign-lambda c-string "linkage_print_pp_msgs" linkage)) ; ;(define get-senses ; (foreign-lambda c-string "linkage_print_senses" linkage)) ; --------------------------------------------------------------------------- (define unused-word-cost @("Should return the same value as sentence-null-count." (@no-source) (@to "number") (linkage "")) (foreign-lambda int "linkage_unused_word_cost" linkage)) (define disjunct-cost @("Should return the same value as sentence-disjunct-cost." (@no-source) (@to "number") (linkage "")) (foreign-lambda number "linkage_disjunct_cost" linkage)) (define link-cost @("Should return the same value as sentence-link-cost." (@no-source) (@to "number") (linkage "")) (foreign-lambda int "linkage_link_cost" linkage)) (define corpus-cost @("Returns the total cost of this particular linkage, based on the cost of disjuncts stored in the corpus-statistics database." (@no-source) (@to "number") (linkage "")) (foreign-lambda number "linkage_corpus_cost" linkage)) (define get-violation-name (foreign-lambda c-string "linkage_get_violation_name" linkage)) (define (linkage->eps-file filename postscript) @("Saves a linkage to a postscript file" (path "filename") (postscript "Postscript string") (@to "unspecified") (@no-source)) (with-output-to-file filename (lambda () (format #t "~A~%" postscript)))) ; ____ _ ; / ___| _ _ ___| |_ ___ _ __ ___ ; \___ \| | | / __| __/ _ \ '_ ` _ \ ; ___) | |_| \__ \ || __/ | | | | | ; |____/ \__, |___/\__\___|_| |_| |_| ; |___/ ; ___ _ _ _ _ _ _ _ ; |_ _|_ __ (_) |_(_) __ _| (_)______ _| |_(_) ___ _ __ ; | || '_ \| | __| |/ _` | | |_ / _` | __| |/ _ \| '_ \ ; | || | | | | |_| | (_| | | |/ / (_| | |_| | (_) | | | | ; |___|_| |_|_|\__|_|\__,_|_|_/___\__,_|\__|_|\___/|_| |_| (define get-version @("Gets link-grammar version" (@no-source) (@to "string")) (foreign-lambda c-string "linkgrammar_get_version")) (define get-dictionary-version @("Gets dictionary version" (@no-source) (dictionary "Dictionary") (@to "string")) (foreign-lambda c-string "linkgrammar_get_dict_version" dictionary)) (define get-dictionary-locale @("Gets dictionary locale" (@no-source) (@to "string")) (foreign-lambda c-string "linkgrammar_get_dict_locale" dictionary)) ; ____ _ _ ____ _ _ ; | _ \(_)___ _ __ | | __ _ _ _ | _ \ ___ ___ _ _| | |_ ___ ; | | | | / __| '_ \| |/ _` | | | | | |_) / _ \/ __| | | | | __/ __| ; | |_| | \__ \ |_) | | (_| | |_| | | _ < __/\__ \ |_| | | |_\__ \ ; |____/|_|___/ .__/|_|\__,_|\__, | |_| \_\___||___/\__,_|_|\__|___/ ; |_| |___/ (define display-off @("Turn off display" (@no-source)) 0) (define display-multi-line @("Print diagram across multiple lines" (@no-source)) 1) (define display-bracket-tree @("Use brackets when printing diagram" (@no-source)) 2) (define display-single-line @("Print diagram on single line" (@no-source)) 3) (define display-max-styles @("Print diagram on single line" (@no-source)) 3) (define set-display-morphology! @("Sets display morphology in parse-options" (@no-source) (parse-options "") (value "(number)")) (foreign-lambda void "parse_options_set_display_morphology" parse-options int)) (define get-display-morphology @("Gets display morphology value" (@no-source) (parse-options "") (@to "number")) (foreign-lambda int "parse_options_get_display_morphology" parse-options)) ; ____ ___ _ _ ; | _ \ __ _ _ __ ___ ___ / _ \ _ __ | |_(_) ___ _ __ ___ ; | |_) / _` | '__/ __|/ _ \ | | | | '_ \| __| |/ _ \| '_ \/ __| ; | __/ (_| | | \__ \ __/ | |_| | |_) | |_| | (_) | | | \__ \ ; |_| \__,_|_| |___/\___| \___/| .__/ \__|_|\___/|_| |_|___/ ; |_| @(heading "Parse Options") @(text "Parse-options specify the different parameters that are used to parse sentences. Examples of the kinds of things that are controlled by parse-options include maximum parsing time and memory, whether to use null-links, and whether or not to use 'panic' mode. This data structure is passed in to the various parsing and printing routines along with the sentence.") @(text "Default value for parse-option members are:" "verbosity → 0" "linkage-limit → 10000" "min-null-count → 0" "max-null-count → 0" "null-block → 1" "islands-ok → #f" "short-length → 6" "all-short → #f" "display-short → #t" "display-word-subscripts → #t" "display-link-subscripts → #t" "display-walls → #f" "allow-null → #t" "echo-on → #f" "batch-mode → #f" "panic-mode → #f" "screen-width → 79" "display-on → #t" "display-postscript → #f" "display-bad → #f" "display-links → #f") (define init-opts @("Initilise parse-options to default values" (@no-source) (@to "parse-options")) (foreign-lambda parse-options "parse_options_create")) (define set-max-parse-time! @("Set maximum parse time" (@to "unspecified") (parse-options "") (value "(number)") (@no-source)) (foreign-lambda void "parse_options_set_max_parse_time" parse-options int)) (define set-linkage-limit! @("Set linkage limit" (@to "unspecified") (parse-options "") (linkage-limit "(number)") (@no-source)) (foreign-lambda void "parse_options_set_linkage_limit" parse-options int)) (define set-short-length! @("The short_length parameter determines how long the links are allowed to be. The intended use of this is to speed up parsing by not considering very long links for most connectors, since they are very rarely used in a correct parse. An entry for UNLIMITED-CONNECTORS in the dictionary will specify which connectors are exempt from the length limit." (@to "unspecified") (parse-options "") (short-length "(number)") (@no-source)) (foreign-lambda void "parse_options_set_short_length" parse-options int)) (define set-disjunct-cost! @("Determines the maximum disjunct cost used during parsing, where the cost of a disjunct is equal to the maximum cost of all of its connectors. The default is that only disjuncts up to a cost of 2.9 are considered." (@to "unspecified") (parse-options "") (disjunt-cost "") (@no-source)) (foreign-lambda void "parse_options_set_disjunct_cost" parse-options int)) (define set-min-null-count! @("When parsing a sentence, the parser will find all solutions having the minimum number of null links. It carries out its search in the range of null link counts between min_null_count and max_null_count. By default, the minimum and maximum number of null links is 0, so null links are not used." (@to "unspecified") (parse-options "") (null-count "") (@no-source)) (foreign-lambda void "parse_options_set_min_null_count" parse-options int)) (define set-max-null-count! @("When parsing a sentence, the parser will find all solutions having the minimum number of null links. It carries out its search in the range of null link counts between min-null-count and max-null-count. By default, the minimum and maximum number of null links is 0, so null links are not used." (@to "unspecified") (parse-options "") (null-count "") (@no-source)) (foreign-lambda void "parse_options_set_max_null_count" parse-options int)) (define reset-resources! @("Reset acquired resources" (@no-source) (parse-options "")) (foreign-lambda void "parse_options_reset_resources" parse-options)) (define resources-exhausted? @("Resources_exhausted means memory-exhausted? OR timer-expired?" (@no-source) (parse-options "") (@to "boolean")) (foreign-lambda int "parse_options_resources_exhausted" parse-options)) (define memory-exhausted? @("Checks whether the memory was exhausted during parsing" (@no-source) (parse-options "") (@to "number")) (foreign-lambda int "parse_options_memory_exhausted" parse-options)) (define timer-expired? @("Checks whether the timer was exceeded during parsing." (@no-source) (parse-options "") (@to "number")) (foreign-lambda int "parse_options_timer_expired" parse-options)) (define set-islands-ok! ;For example, the following linkage has an island: ;+------Wd-----+" ;| +--Dsu--+---Ss--+-Paf-+ +--Dsu--+---Ss--+--Pa-+ ;| | | | | | | | | ;///// this sentence.n is.v false.a this sentence.n is.v true.a) @("This option determines whether or not 'islands' of links are allowed." (@to "unspecified") (parse-options "") (islands-ok? "A boolean to indicate whether islands are allowed") (@no-source)) (foreign-lambda void "parse_options_set_islands_ok" parse-options bool)) (define set-verbosity! @("Sets/gets the level of description printed to stderr/stdout about the parsing process." (@no-source) (parse-options "") (verbosity-level "") (@to "unspecified")) (foreign-lambda void "parse_options_set_verbosity" parse-options int)) (define get-verbosity @("Get the verbosity level" (@no-source) (parse-options "") (@to "number")) (foreign-lambda int "parse_options_get_verbosity" parse-options)) (define delete-parse-options! @("Delete a parse-option object" (@no-source) (parse-options "") (@to "number")) (foreign-lambda int "parse_options_delete" parse-options )) @(heading "License") @(text "This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA")