Menu
Coddy logo textTech

הצגת הניתוח

חלק מהיחידה לוגיקה וזרימת התוכנית במסלול ה-Dart של Coddy. שיעור 57 מתוך 65.

challenge icon

אתגר

קל

בשיעור האחרון הזה בפרויקט מנתח הטקסט, תיצרו תצוגה מקיפה של כל תוצאות הניתוח שאספתם לאורך הפרויקט. בשלב הזה תעצבו ותציגו את כל הנתונים הסטטיסטיים בסיכום ברור ומקצועי, שמציג את ניתוח הטקסט המלא.

  1. השתמשו בכל המשתנים מהשלבים הקודמים בפרויקט:
    • textToAnalyze מההגדרה הראשונית של הפרויקט
    • totalCharacters משלב ספירת התווים
    • wordList משלב פיצול המילים
    • totalWords משלב ספירת המילים
    • uniqueWordsSet משלב ספירת המילים הייחודיות
    • uniqueWordCount משלב ספירת המילים הייחודיות
    • wordFrequency משלב ספירת תדירות המילים
  2. צרו דוח סופי מקיף המציג את כל תוצאות הניתוח
  3. עצבו את הפלט כך שיציג סיכום מלא של ניתוח הטקסט
  4. כללו את כל הנתונים הסטטיסטיים עם תוויות ברורות ועיצוב מתאים
  5. הציגו את התוצאות בדיוק בפורמט שמוצג בהמשך

לדוגמה, אם מנתח הטקסט הוגדר עם "hello world hello", התוכנית שלכם אמורה להפיק:

=======================================
    TEXT ANALYSIS COMPLETE REPORT    
=======================================
Original Text: "hello world hello"
=======================================
ANALYSIS SUMMARY:
- Total Characters: 17
- Total Words: 3
- Unique Words: 2
- Most Common Word: hello (appears 2 times)
=======================================
DETAILED BREAKDOWN:
Word List: [hello, world, hello]
Unique Words Set: {hello, world}
Word Frequency Map: {hello: 2, world: 1}
=======================================
Analysis completed successfully!
Text contains 2 unique words out of 3 total words.
=======================================

אם מנתח הטקסט הוגדר עם "the cat and the dog and the bird", התוכנית שלכם אמורה להפיק:

=======================================
    TEXT ANALYSIS COMPLETE REPORT    
=======================================
Original Text: "the cat and the dog and the bird"
=======================================
ANALYSIS SUMMARY:
- Total Characters: 32
- Total Words: 8
- Unique Words: 5
- Most Common Word: the (appears 3 times)
=======================================
DETAILED BREAKDOWN:
Word List: [the, cat, and, the, dog, and, the, bird]
Unique Words Set: {the, cat, and, dog, bird}
Word Frequency Map: {the: 3, cat: 1, and: 2, dog: 1, bird: 1}
=======================================
Analysis completed successfully!
Text contains 5 unique words out of 8 total words.
=======================================

אם מנתח הטקסט הוגדר עם "apple banana apple cherry banana apple", התוכנית שלכם אמורה להפיק:

=======================================
    TEXT ANALYSIS COMPLETE REPORT    
=======================================
Original Text: "apple banana apple cherry banana apple"
=======================================
ANALYSIS SUMMARY:
- Total Characters: 38
- Total Words: 6
- Unique Words: 3
- Most Common Word: apple (appears 3 times)
=======================================
DETAILED BREAKDOWN:
Word List: [apple, banana, apple, cherry, banana, apple]
Unique Words Set: {apple, banana, cherry}
Word Frequency Map: {apple: 3, banana: 2, cherry: 1}
=======================================
Analysis completed successfully!
Text contains 3 unique words out of 6 total words.
=======================================

התוכנית שלכם אמורה לקבוע מהי המילה הנפוצה ביותר על ידי מציאת המילה עם ספירת התדירות הגבוהה ביותר במפה wordFrequency. השתמשו באינטרפולציה של מחרוזות כדי להציג את כל הנתונים שנאספו בפורמט מקצועי וקל לקריאה. תצוגה סופית זו מאגדת לסיכום מקיף אחד את כל עבודת הניתוח שביצעתם לאורך הפרויקט.

נסו בעצמכם

import 'dart:io';

void main() {
  String? textToAnalyze = stdin.readLineSync();
  
  int totalCharacters = textToAnalyze!.length;
  
  List<String> wordList = textToAnalyze.split(' ');
  
  int totalWords = wordList.length;
  
  Set<String> uniqueWordsSet = wordList.toSet();
  
  int uniqueWordCount = uniqueWordsSet.length;
  
  Map<String, int> wordFrequency = {};
  
  for (String word in wordList) {
    if (wordFrequency.containsKey(word)) {
      wordFrequency[word] = wordFrequency[word]! + 1;
    } else {
      wordFrequency[word] = 1;
    }
  }
  
  print('Text Analysis Tool - Word Frequency');
  print('====================================');
  print('Analyzing text: "$textToAnalyze"');
  print('Total characters: $totalCharacters');
  print('Words found: $wordList');
  print('Total words: $totalWords');
  print('Unique words: $uniqueWordsSet');
  print('Unique word count: $uniqueWordCount');
  print('====================================');
  print('Word Frequency Analysis Results:');
  print('Word frequencies: $wordFrequency');
  print('====================================');
  print('Word frequency analysis completed successfully.');
}

כל השיעורים ביחידה לוגיקה וזרימת התוכנית

תרגלו בעצמכם: קומפיילר Dart אונליין