100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

COS3711 Assignment 1 (COMPLETE ANSWERS) 2025

Puntuación
-
Vendido
2
Páginas
22
Grado
A+
Subido en
25-03-2025
Escrito en
2024/2025

COS3711 Assignment 1 2025 ;100% TRUSTED workings with detailed Answers for A+ Grade. For assistance call or W.h.a.t.s.a.p.p us on +/ 2/ 5/ 4 /1 /1 /0/0 /3 /4 /3 /9 /9 .

Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
25 de marzo de 2025
Número de páginas
22
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

COS3711
ASSIGNMENT 1 2025

UNIQUE NO.
DUE DATE: 2025

,Answer for Question 1 (COS3711 Assignment 1 - 2025)

Requirements Recap:

1. Command-line Usage:
o count → No arguments: Print usage instructions.
o count file1.txt → Process a single file.
o count file1.txt fileTwo.txt → Process multiple files.
o count –a –b file1.txt fileTwo.txt → Apply specific flags.
o count –ab –c file1.txt → Alternative flag syntax.
2. Flags and Their Functions:
o -a: Count words longer than 4 characters that start with a capital letter.
o -b: Count hyphenated words (not starting or ending with a hyphen).
o -c: Count words that start and end with the same character.
o -d: Count words that do not start with a vowel.
3. Text Processing:
o Remove whitespace at the start and end of the document.
o Remove punctuation (.,?!:; etc.) using regular expressions.
o Assume only one space between words.




Implementation Approach

1. Use Python or C++ (since Qt is mentioned, C++ with Qt might be preferred).
2. Process input files and extract words.
3. Apply regex-based counting for each flag condition.
4. Handle command-line arguments properly.

, Sample Python Implementation

python
import sys
import re

def process_file(filename, flags):
try:
with open(filename, 'r', encoding='utf-8') as file:
text = file.read().strip()

# Remove punctuation
text = re.sub(r'[.,?!:;]', '', text)

words = text.split()

results = {"-a": 0, "-b": 0, "-c": 0, "-d": 0}

for word in words:
# -a: Words longer than 4 chars starting with a capital letter
if "-a" in flags and len(word) > 4 and word[0].isupper():
results["-a"] += 1

# -b: Hyphenated words (not starting/ending with a hyphen)
if "-b" in flags and re.search(r'\b\w+-\w+\b', word):
results["-b"] += 1

# -c: Words that start and end with the same letter
if "-c" in flags and len(word) > 1 and word[0].lower() == word[-
1].lower():
results["-c"] += 1

# -d: Words not starting with a vowel
if "-d" in flags and not re.match(r'^[aeiouAEIOU]', word):
results["-d"] += 1

print(f"\nResults for {filename}:")
for key, value in results.items():
if key in flags:
print(f"{key}: {value}")

except FileNotFoundError:
print(f"Error: File '{filename}' not found.")

def main():
args = sys.argv[1:]

if not args:
print("Usage: count [-a -b -c -d] <file1> <file2> ...")
return

flags = {arg for arg in args if arg.startswith('-')}
files = [arg for arg in args if not arg.startswith('-')]

if not files:
print("Error: No files specified.")
$2.81
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
EduScript Chamberlain College Of Nursing
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
278
Miembro desde
1 año
Número de seguidores
4
Documentos
594
Última venta
1 mes hace
EduScript

On this page, you find all documents, package deals, and flashcards offered by seller EduScript. Get Yourself 100 % TRUSTED workings, Expert Solved, Explanations and Solutions.

3.7

30 reseñas

5
14
4
5
3
3
2
3
1
5

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes