Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,35 +0,0 @@
|
|||
-- Rosetta Code Task written in Ada
|
||||
-- Determine sentence type
|
||||
-- https://rosettacode.org/wiki/Determine_sentence_type
|
||||
-- July 2024, R. B. E.
|
||||
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
|
||||
|
||||
procedure Determine_Sentence_Type is
|
||||
S1 : String := "hi there, how are you today?";
|
||||
S2 : String := "I'd like to present to you the washing machine 9001.";
|
||||
S3 : String := "You have been nominated to win one of these!";
|
||||
S4 : String := "Just make sure you don't break it";
|
||||
|
||||
procedure Just_Do_It (S: String) is
|
||||
begin
|
||||
if (S'Last = 0) then
|
||||
Put_Line ("Error: The provided sentence was empty.");
|
||||
else
|
||||
case S (S'Last) is
|
||||
when '?' => Put ("Q: ");
|
||||
when '.' => Put ("S: ");
|
||||
when '!' => Put ("E: ");
|
||||
when others => Put ("N: ");
|
||||
end case;
|
||||
Put_Line (S);
|
||||
end if;
|
||||
end Just_Do_It;
|
||||
|
||||
begin
|
||||
Just_Do_It (S1);
|
||||
Just_Do_It (S2);
|
||||
Just_Do_It (S3);
|
||||
Just_Do_It (S4);
|
||||
end Determine_Sentence_Type;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
(defun get-last-character (str)
|
||||
"Return the last character of STR."
|
||||
(let ((str-length))
|
||||
(setq str-length (length str))
|
||||
(substring str (- str-length 1) str-length)))
|
||||
|
||||
(defun classify-sentence (str)
|
||||
"Classify the type of sentence based on final punctuation."
|
||||
(let ((last-character (get-last-character str)))
|
||||
(cond ((string= last-character ".") (format "S - %s" str))
|
||||
((string= last-character "!") (format "E - %s" str))
|
||||
((string= last-character "?") (format "Q - %s" str))
|
||||
(t (format "N - %s" str)))))
|
||||
|
||||
(defun classify-multiple-sentences (str)
|
||||
"Classify each sentence as Q, S, E, or N."
|
||||
;; sentence boundary is defined as:
|
||||
;; a period (full stop), exclamation point/mark, or question mark
|
||||
;; followed by one space
|
||||
;; followed by a capital letter
|
||||
;; while the above will work for this exercise, it won't
|
||||
;; work in other situations. See the Perl code in this section
|
||||
;; for cases that the above will not cover.
|
||||
(let ((regex-sentence-boundary "\\([.?!]\\) \\([[:upper:]]\\)"))
|
||||
;; split the text into list of individual sentences
|
||||
(dolist (one-sentence (split-string (replace-regexp-in-string regex-sentence-boundary "\\1\n\\2" str) "\n"))
|
||||
;; classify each sentence
|
||||
(insert (format "\n%s" (classify-sentence one-sentence))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue