Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -1,5 +1,5 @@
Use these sentences:
"hi there, how are you today? I'd like to present to you the washing machine 9001. You have been nominated to win one of these! Just make sure you don't break it."
"hi there, how are you today? I'd like to present to you the washing machine 9001. You have been nominated to win one of these! Just make sure you don't break it
;Task
: Search for the last used punctuation in a sentence, and determine its type according to its punctuation.

View file

@ -0,0 +1,132 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program detertype64.s */
/*******************************************/
/* Constantes */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
.equ BUFFERSIZE, 160
.equ SENTENCESTART, 3
/*******************************************/
/* Macros */
/*******************************************/
//.include "../../ficmacros64.inc" // for developer debugging
/*********************************/
/* Initialized data */
/*********************************/
.data
szMessDebutPgm: .asciz "Program 64 bits start. \n"
szCarriageReturn: .asciz "\n"
szMessFinOK: .asciz "Program normal end. \n"
szMessErreur: .asciz "Error !!!\n"
szSpace1: .asciz " "
szPhrase1: .ascii "hi there, how are you today?"
.ascii "I'd like to present to you the washing machine 9001."
.ascii " You have been nominated to win one of these!"
.asciz " Just make sure you don't break it"
.equ LGPHRASE1, . - szPhrase1 - 1
/*********************************/
/* UnInitialized data */
/*********************************/
.bss
.align 4
/*********************************/
/* code section */
/*********************************/
.text
.global main
main:
ldr x0,qAdrszMessDebutPgm
bl affichageMess // start message
sub sp,sp,#BUFFERSIZE
mov x7,sp
ldr x4,qAdrszPhrase1 // load phrase adress
mov x5,#0
mov x6,#SENTENCESTART
1:
ldrb w1,[x4,x5]
strb w1,[x7,x6]
add x6,x6,#1
cmp x1,#0
beq 10f
cmp x1,#'.'
mov x2,#'S'
beq 2f
cmp x1,#'?'
mov x2,#'Q'
beq 2f
cmp x1,#'!'
mov x2,#'E'
beq 2f
add x5,x5,#1
b 1b
2:
mov x0,x7
mov x1,x6
bl traitResult
mov x6,#SENTENCESTART
add x5,x5,#1
b 1b
10:
cmp x6,#SENTENCESTART
beq 11f
mov x0,x7
mov x2,#'N'
sub x1,x6,#1
bl traitResult
11:
ldr x0,qAdrszMessFinOK
bl affichageMess
b 100f
99:
ldr x0,qAdrszMessErreur // error
bl affichageMess
mov x0, #1 // return code error
b 100f
100:
add sp,sp,#BUFFERSIZE
mov x8,EXIT
svc #0 // system call
qAdrszMessDebutPgm: .quad szMessDebutPgm
qAdrszMessFinOK: .quad szMessFinOK
qAdrszMessErreur: .quad szMessErreur
qAdrszPhrase1: .quad szPhrase1
/***************************************************/
/* display result */
/***************************************************/
/* x0 contains buffer address */
/* x1 contains buffer length */
/* x2 contains characters type */
traitResult:
stp x3,lr,[sp,-16]! // save registers
mov x3,#0x0A // return line
strb w3,[x0,x1]
add x1,x1,#1
mov x3,#0
strb w3,[x0,x1] // final zero
strb w2,[x0] // store character type
mov x3,#':'
strb w3,[x0,#1]
mov x3,#' '
strb w3,[x0,#2]
bl affichageMess
100: // end function
ldp x3,lr,[sp],16 // restaur registers
ret
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeARM64.inc"

View file

@ -0,0 +1,133 @@
/* ARM assembly Raspberry PI */
/* program detertype.s */
/* REMARK 1 : this program use routines in a include file
see task Include a file language arm assembly
for the routine affichageMess conversion10
see at end of this program the instruction include */
/*******************************************/
/* Constantes */
/*******************************************/
.include "../constantes.inc"
.equ BUFFERSIZE, 200
.equ SENTENCESTART, 3
/*******************************************/
/* Macros */
/*******************************************/
//.include "../../ficmacros32.inc" @ for developer debugging
/*********************************/
/* Initialized data */
/*********************************/
.data
szMessDebutPgm: .asciz "Program 32 bits start. \n"
szCarriageReturn: .asciz "\n"
szMessFinOK: .asciz "Program normal end. \n"
szMessErreur: .asciz "Error !!!\n"
szSpace1: .asciz " "
szPhrase1: .ascii "hi there, how are you today?"
.ascii "I'd like to present to you the washing machine 9001."
.ascii " You have been nominated to win one of these!"
.asciz " Just make sure you don't break it"
.equ LGPHRASE1, . - szPhrase1 - 1
/*********************************/
/* UnInitialized data */
/*********************************/
.bss
.align 4
/*********************************/
/* code section */
/*********************************/
.text
.global main
main:
ldr r0,iAdrszMessDebutPgm
bl affichageMess @ start message
sub sp,sp,#BUFFERSIZE
mov r7,sp
ldr r4,iAdrszPhrase1 @ load phrase adress
mov r5,#0
mov r6,#SENTENCESTART
1:
ldrb r1,[r4,r5]
strb r1,[r7,r6]
add r6,r6,#1
cmp r1,#0
beq 10f
cmp r1,#'.'
moveq r2,#'S'
beq 2f
cmp r1,#'?'
moveq r2,#'Q'
beq 2f
cmp r1,#'!'
moveq r2,#'E'
beq 2f
add r5,r5,#1
b 1b
2:
mov r0,r7
mov r1,r6
bl traitResult
mov r6,#SENTENCESTART
add r5,r5,#1
b 1b
10:
cmp r6,#SENTENCESTART
beq 11f
mov r0,r7
mov r2,#'N'
sub r1,r6,#1
bl traitResult
11:
ldr r0,iAdrszMessFinOK
bl affichageMess
b 100f
99:
ldr r0,iAdrszMessErreur @ error
bl affichageMess
mov r0, #1 @ return code error
b 100f
100:
add sp,sp,#BUFFERSIZE
mov r7,#EXIT @ program end
svc #0 @ system call
iAdrszMessDebutPgm: .int szMessDebutPgm
iAdrszMessFinOK: .int szMessFinOK
iAdrszMessErreur: .int szMessErreur
iAdrszPhrase1: .int szPhrase1
/***************************************************/
/* display result */
/***************************************************/
/* r0 contains buffer address */
/* r1 contains buffer length */
/* r2 contains characters type */
traitResult:
push {r3,lr} @ save registers
mov r3,#0x0A @ return line
strb r3,[r0,r1]
add r1,r1,#1
mov r3,#0
strb r3,[r0,r1] @ final zero
strb r2,[r0] @ store character type
mov r3,#':'
strb r3,[r0,#1]
mov r3,#' '
strb r3,[r0,#2]
bl affichageMess
100: @ end function
pop {r3,pc} @ restaur registers
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
.include "../affichage.inc"

View file

@ -0,0 +1,35 @@
-- 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;

View file

@ -0,0 +1,19 @@
string[] spam = {
"hi there, how are you today?",
"I'd like to present to you the washing machine 9001.",
"You have been nominated to win one of these!",
"Just make sure you don't break it"
};
string SentenceType(string s) {
int len = length(s);
string lastChar = substr(s, len-1, len);
if (lastChar == "?") return "Q";
if (lastChar == "!") return "E";
if (lastChar == ".") return "S";
return "N";
}
for (int i = 0; i < spam.length; ++i) {
write(spam[i] + " -> " + SentenceType(spam[i]));
}

View file

@ -0,0 +1,25 @@
arraybase 1
dim spam$(4)
spam$[1] = "hi there, how are you today?"
spam$[2] = "I'd like to present to you the washing machine 9001."
spam$[3] = "You have been nominated to win one of these!"
spam$[4] = "Just make sure you don't break it"
for i = 1 to 4
print spam$[i]; " -> "; SentenceType$(spam$[i])
next i
end
function SentenceType$ (s$)
l$ = right(s$, 1)
begin case
case l$ = "?"
SentenceType$ = "Q"
case l$ = "!"
SentenceType$ = "E"
case l$ = "."
SentenceType$ = "S"
else
SentenceType$ = "N"
end case
end function

View file

@ -0,0 +1,20 @@
100 sub sentencetype$(s$)
110 select case right$(s$,1)
120 case "?"
130 sentencetype$ = "Q"
140 case "!"
150 sentencetype$ = "E"
160 case "."
170 sentencetype$ = "S"
180 case else
190 sentencetype$ = "N"
200 end select
210 end sub
220 dim spam$(3)
230 spam$(0) = "hi there, how are you today?"
240 spam$(1) = "I'd like to present to you the washing machine 9001."
250 spam$(2) = "You have been nominated to win one of these!"
260 spam$(3) = "Just make sure you don't break it"
270 for i = 0 to ubound(spam$)
280 print spam$(i);" -> ";sentencetype$(spam$(i))
290 next i

View file

@ -0,0 +1,20 @@
void main() {
List<String> spam = [
"hi there, how are you today?",
"I'd like to present to you the washing machine 9001.",
"You have been nominated to win one of these!",
"Just make sure you don't break it"
];
for (var s in spam) {
print('$s -> ${sentenceType(s)}');
}
}
String sentenceType(String s) {
String lastChar = s[s.length - 1];
if (lastChar == '?') return 'Q';
if (lastChar == '!') return 'E';
if (lastChar == '.') return 'S';
return 'N';
}

View file

@ -15,7 +15,7 @@
(defun classify-multiple-sentences (str)
"Classify each sentence as Q, S, E, or N."
;; sentence boundary is defined as:
;; a period (full stop), comma, or question mark
;; 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

View file

@ -0,0 +1,15 @@
100 CLS : rem 100 HOME for Applesoft BASIC
110 DIM SPAM$(3)
120 SPAM$(0) = "hi there, how are you today?"
130 SPAM$(1) = "I'd like to present to you the washing machine 9001."
140 SPAM$(2) = "You have been nominated to win one of these!"
150 SPAM$(3) = "Just make sure you don't break it"
160 FOR I = 0 TO 3
170 LASTCHAR$ = RIGHT$(SPAM$(I), 1)
180 IF LASTCHAR$ = "?" THEN TYPE$ = "Q"
190 IF LASTCHAR$ = "!" THEN TYPE$ = "E"
200 IF LASTCHAR$ = "." THEN TYPE$ = "S"
210 IF LASTCHAR$ <> "?" AND LASTCHAR$ <> "!" AND LASTCHAR$ <> "." THEN TYPE$ = "N"
220 PRINT SPAM$(I) + " -> " + TYPE$
230 NEXT I
240 END

View file

@ -0,0 +1,24 @@
Public spam As String[] = ["hi there, how are you today?", "I'd like to present to you the washing machine 9001.", "You have been nominated to win one of these!", "Just make sure you don't break it"]
Public Sub Main()
For i As Integer = 0 To spam.Count - 1
Print spam[i]; " -> "; SentenceType(spam[i])
Next
End
Function SentenceType(ByRef s As String) As String
Select Case Right(s, 1)
Case "?"
Return "Q"
Case "!"
Return "E"
Case "."
Return "S"
Case Else
Return "N"
End Select
End Function

View file

@ -0,0 +1,21 @@
spam([
"hi there, how are you today?",
"I'd like to present to you the washing machine 9001.",
"You have been nominated to win one of these!",
"Just make sure you don't break it"
]).
sentence_type(S, 'Q') :- sub_atom(S, _, 1, 0, '?'), !.
sentence_type(S, 'E') :- sub_atom(S, _, 1, 0, '!'), !.
sentence_type(S, 'S') :- sub_atom(S, _, 1, 0, '.'), !.
sentence_type(_, 'N').
print_sentences([]).
print_sentences([H|T]) :-
sentence_type(H, Type),
format('~w -> ~w~n', [H, Type]),
print_sentences(T).
main :-
spam(Sentences),
print_sentences(Sentences).

View file

@ -0,0 +1,26 @@
Procedure.s SentenceType(s.s)
Select Right(s, 1)
Case "?"
ProcedureReturn "Q"
Case "!"
ProcedureReturn "E"
Case "."
ProcedureReturn "S"
Default
ProcedureReturn "N"
EndSelect
EndProcedure
Dim spam.s(3)
spam(0) = "hi there, how are you today?"
spam(1) = "I'd like to present to you the washing machine 9001."
spam(2) = "You have been nominated to win one of these!"
spam(3) = "Just make sure you don't break it"
OpenConsole()
For i = 0 To 3
PrintN(spam(i) + " -> " + SentenceType(spam(i)))
Next i
PrintN(#CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()

View file

@ -0,0 +1,24 @@
DECLARE FUNCTION SentenceType$ (s AS STRING)
Dim spam(3) As String
spam(0) = "hi there, how are you today?"
spam(1) = "I'd like to present to you the washing machine 9001."
spam(2) = "You have been nominated to win one of these!"
spam(3) = "Just make sure you don't break it"
For i = 0 To UBound(spam)
Print spam(i); " -> "; SentenceType$(spam(i))
Next i
Function SentenceType$ (s As String)
Select Case Right$(s, 1)
Case "?"
SentenceType$ = "Q"
Case "!"
SentenceType$ = "E"
Case "."
SentenceType$ = "S"
Case Else
SentenceType$ = "N"
End Select
End Function

View file

@ -0,0 +1,13 @@
100 ARRAY S$
110 LET S$(1) = "hi there, how are you today?"
120 LET S$(2) = "I'd like to present to you the washing machine 9001."
130 LET S$(3) = "You have been nominated to win one of these!"
140 LET S$(4) = "Just make sure you don't break it"
150 FOR i = 1 TO 4
160 LET L$ = RIGHT(S$(i), 1)
170 IF L$ = "?" THEN LET t$ = "Q"
180 IF L$ = "!" THEN LET t$ = "E"
190 IF L$ = "." THEN LET t$ = "S"
200 IF L$ <> "?" AND L$ <> "!" AND L$ <> "." THEN LET t$ = "N"
210 PRINT S$(i); " -> "; t$
220 NEXT i

View file

@ -0,0 +1,23 @@
dim spam$(3)
spam$(0) = "hi there, how are you today?"
spam$(1) = "I'd like to present to you the washing machine 9001."
spam$(2) = "You have been nominated to win one of these!"
spam$(3) = "Just make sure you don't break it"
for i = 0 to 3
print spam$(i); " -> "; SentenceType$(spam$(i))
next i
end
function SentenceType$(s$)
select case right$(s$, 1)
case "?"
SentenceType$ = "Q"
case "!"
SentenceType$ = "E"
case "."
SentenceType$ = "S"
case else
SentenceType$ = "N"
end select
end function

View file

@ -0,0 +1,23 @@
DIM spam$(4)
LET spam$(1) = "hi there, how are you today?"
LET spam$(2) = "I'd like to present to you the washing machine 9001."
LET spam$(3) = "You have been nominated to win one of these!"
LET spam$(4) = "Just make sure you don't break it"
FUNCTION sentencetype$(s$)
SELECT CASE (spam$(i))[LEN(spam$(i)):LEN(spam$(i))+1-1]
CASE "?"
LET sentencetype$ = "Q"
CASE "!"
LET sentencetype$ = "E"
CASE "."
LET sentencetype$ = "S"
CASE ELSE
LET sentencetype$ = "N"
END SELECT
END FUNCTION
FOR i = 1 TO UBOUND(spam$)
PRINT spam$(i); " -> "; sentencetype$(spam$(i))
NEXT i
END

View file

@ -0,0 +1,27 @@
PROGRAM "Determine sentence type"
VERSION "0.0000"
DECLARE FUNCTION Entry ()
DECLARE FUNCTION SentenceType$ (s$)
FUNCTION Entry ()
DIM spam$[4]
spam$[1] = "hi there, how are you today?"
spam$[2] = "I'd like to present to you the washing machine 9001."
spam$[3] = "You have been nominated to win one of these!"
spam$[4] = "Just make sure you don't break it"
FOR i = 1 TO 4
PRINT spam$[i]; " -> "; SentenceType$(spam$[i])
NEXT i
END FUNCTION
FUNCTION SentenceType$ (s$)
SELECT CASE RIGHT$(s$, 1)
CASE "?": RETURN "Q"
CASE "!": RETURN "E"
CASE ".": RETURN "S"
CASE ELSE: RETURN "N"
END SELECT
END FUNCTION
END PROGRAM

View file

@ -0,0 +1,23 @@
dim spam$(3)
spam$(0) = "hi there, how are you today?"
spam$(1) = "I'd like to present to you the washing machine 9001."
spam$(2) = "You have been nominated to win one of these!"
spam$(3) = "Just make sure you don't break it"
for i = 0 to arraysize(spam$(), 1)
print spam$(i), " -> ", SentenceType$(spam$(i))
next i
end
sub SentenceType$ (s$)
switch right$(s$, 1)
case "?"
return "Q"
case "!"
return "E"
case "."
return "S"
default
return "N"
end switch
end sub