Menu
Coddy logo textTech

분석 결과 표시하기

Coddy Dart 여정의 로직 & 흐름 섹션에 포함된 레슨 — 65개 중 57번째.

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: 33
- 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 맵에서 가장 높은 빈도수를 가진 단어를 찾아 가장 흔한 단어를 결정해야 합니다. 문자열 보간법(string interpolation)을 사용하여 수집된 모든 데이터를 전문적이고 읽기 쉬운 형식으로 표시하세요. 이 최종 표시는 프로젝트 전반에 걸쳐 완료한 모든 분석 작업을 하나의 종합적인 요약으로 통합합니다.

직접 해보기

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.');
}

로직 & 흐름의 모든 레슨