| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| package com.chahuadev.emoji.cleaner.test;
|
|
|
| import java.util.*;
|
| import java.util.concurrent.*;
|
| import java.util.stream.*;
|
| import java.util.function.*;
|
| import java.time.*;
|
| import java.time.format.*;
|
| import java.nio.file.*;
|
| import java.io.*;
|
| import java.net.*;
|
| import java.util.regex.*;
|
| import java.lang.annotation.*;
|
| import java.lang.reflect.*;
|
| import javax.annotation.processing.*;
|
|
|
| |
| |
| |
|
|
| @Retention(RetentionPolicy.RUNTIME)
|
| @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
|
| @interface EmojiTest {
|
| String value() default "🧪 Default test";
|
| String category() default "🏷️ General";
|
| int priority() default 1;
|
| String[] tags() default {};
|
| }
|
|
|
| |
| |
| |
|
|
| @FunctionalInterface
|
| interface EmojiProcessor<T, R> {
|
| |
| |
| |
| |
|
|
| R processEmojis(T input);
|
|
|
| |
| |
| |
| |
|
|
| default <V> EmojiProcessor<T, V> andThen(EmojiProcessor<? super R, ? extends V> after) {
|
| Objects.requireNonNull(after, "🚫 After processor cannot be null");
|
| return (T input) -> after.processEmojis(processEmojis(input));
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| abstract class AbstractEmojiHandler {
|
| protected final String handlerName;
|
| protected final Map<String, Object> configuration;
|
| protected final List<String> supportedCategories;
|
|
|
| |
| |
| |
| |
|
|
| protected AbstractEmojiHandler(String name, Map<String, Object> config) {
|
| this.handlerName = "🔧 " + Objects.requireNonNull(name, "🚫 Name required");
|
| this.configuration = new HashMap<>(config);
|
| this.supportedCategories = Arrays.asList(
|
| "😀 Faces", "❤️ Hearts", "🚀 Objects", "🌸 Nature",
|
| "🎯 Symbols", "🎨 Activities", "🍎 Food", "🏠 Places"
|
| );
|
|
|
|
|
| logMessage("✅ Handler initialized successfully");
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public abstract ProcessingResult processContent(String content);
|
|
|
| |
| |
| |
| |
|
|
| protected boolean isCategorySupported(String category) {
|
| return supportedCategories.stream()
|
| .anyMatch(supported -> supported.contains(category.replace("🎯 ", "")));
|
| }
|
|
|
| |
| |
| |
|
|
| protected void logMessage(String message) {
|
| String timestamp = LocalDateTime.now()
|
| .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
| System.out.println(String.format("[%s] 🕒 %s: %s",
|
| timestamp, handlerName, message));
|
| }
|
|
|
| |
| |
| |
|
|
| public Map<String, Object> getStatistics() {
|
| Map<String, Object> stats = new HashMap<>();
|
| stats.put("🏷️ handlerName", handlerName);
|
| stats.put("📊 supportedCategories", supportedCategories.size());
|
| stats.put("⚙️ configurationSize", configuration.size());
|
| stats.put("🕒 lastAccessed", LocalDateTime.now());
|
| return stats;
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| record ProcessingResult(
|
| String originalContent, // 📝 Original text
|
| String cleanedContent, // 🧹 Processed text
|
| List<String> foundEmojis, // 🔍 Detected emojis
|
| Map<String, Integer> categoryStats, // 📊 Category breakdown
|
| Duration processingTime, // ⏱️ Time taken
|
| boolean success, // ✅ Success status
|
| String processorName // 🏷️ Processor identifier
|
| ) {
|
| |
| |
|
|
| public ProcessingResult {
|
| Objects.requireNonNull(originalContent, "🚫 Original content required");
|
| Objects.requireNonNull(cleanedContent, "🚫 Cleaned content required");
|
| Objects.requireNonNull(foundEmojis, "🚫 Found emojis list required");
|
| Objects.requireNonNull(categoryStats, "🚫 Category stats required");
|
| Objects.requireNonNull(processingTime, "🚫 Processing time required");
|
| Objects.requireNonNull(processorName, "🚫 Processor name required");
|
| }
|
|
|
| |
| |
| |
|
|
| public double getEfficiency() {
|
| if (originalContent.length() == 0) return 100.0;
|
| double reduction = (double) foundEmojis.size() / originalContent.length();
|
| return Math.min(100.0, reduction * 100.0);
|
| }
|
|
|
| |
| |
| |
|
|
| public String generateReport() {
|
| StringBuilder report = new StringBuilder();
|
| report.append("📊 PROCESSING REPORT\n");
|
| report.append("==================\n\n");
|
| report.append(String.format("🏷️ Processor: %s\n", processorName));
|
| report.append(String.format("📝 Original length: %d characters\n", originalContent.length()));
|
| report.append(String.format("🧹 Cleaned length: %d characters\n", cleanedContent.length()));
|
| report.append(String.format("🔍 Emojis found: %d\n", foundEmojis.size()));
|
| report.append(String.format("⏱️ Processing time: %d ms\n", processingTime.toMillis()));
|
| report.append(String.format("📈 Efficiency: %.2f%%\n", getEfficiency()));
|
| report.append(String.format("✅ Success: %s\n\n", success ? "Yes" : "No"));
|
|
|
| if (!categoryStats.isEmpty()) {
|
| report.append("🏷️ CATEGORY BREAKDOWN:\n");
|
| categoryStats.forEach((category, count) ->
|
| report.append(String.format(" %s: %d emojis\n", category, count)));
|
| }
|
|
|
| return report.toString();
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| @EmojiTest(value = "🧪 Advanced processor test", category = "🔧 Core", priority = 1)
|
| public class AdvancedEmojiCleanerProcessor extends AbstractEmojiHandler {
|
|
|
|
|
| private static final Map<String, Pattern> EMOJI_PATTERNS = Map.of(
|
| "😀 Faces", Pattern.compile("[\\u{1F600}-\\u{1F64F}]", Pattern.UNICODE_CHARACTER_CLASS),
|
| "❤️ Hearts", Pattern.compile("[\\u{1F495}-\\u{1F49F}]|❤️|🧡|💛|💚|💙|💜", Pattern.UNICODE_CHARACTER_CLASS),
|
| "🚀 Objects", Pattern.compile("[\\u{1F680}-\\u{1F6FF}]", Pattern.UNICODE_CHARACTER_CLASS),
|
| "🌸 Nature", Pattern.compile("[\\u{1F300}-\\u{1F5FF}]", Pattern.UNICODE_CHARACTER_CLASS),
|
| "🎯 Symbols", Pattern.compile("[\\u{2600}-\\u{26FF}]", Pattern.UNICODE_CHARACTER_CLASS)
|
| );
|
|
|
|
|
| private final ConcurrentHashMap<String, List<String>> emojiCache = new ConcurrentHashMap<>();
|
|
|
|
|
| private final AtomicLong totalProcessed = new AtomicLong(0);
|
| private final AtomicLong totalEmojisRemoved = new AtomicLong(0);
|
|
|
|
|
| private final ExecutorService executorService;
|
|
|
| |
| |
| |
|
|
| public AdvancedEmojiCleanerProcessor(Map<String, Object> config) {
|
| super("🧹 Advanced Emoji Cleaner", config);
|
|
|
|
|
| int threadCount = (Integer) config.getOrDefault("🧵 threadCount",
|
| Runtime.getRuntime().availableProcessors());
|
| this.executorService = Executors.newFixedThreadPool(threadCount);
|
|
|
| logMessage(String.format("🧵 Thread pool initialized with %d threads", threadCount));
|
| }
|
|
|
| |
| |
| |
| |
|
|
| @Override
|
| @EmojiTest(value = "🔧 Core processing test", category = "⚡ Performance")
|
| public ProcessingResult processContent(String content) {
|
| Objects.requireNonNull(content, "🚫 Content cannot be null");
|
|
|
| Instant startTime = Instant.now();
|
| logMessage(String.format("🔄 Processing content (%d characters)", content.length()));
|
|
|
| try {
|
|
|
| List<String> foundEmojis = detectEmojisParallel(content);
|
|
|
|
|
| Map<String, Integer> categoryStats = generateCategoryStatistics(foundEmojis);
|
|
|
|
|
| String cleanedContent = removeEmojis(content, foundEmojis);
|
|
|
|
|
| Duration processingTime = Duration.between(startTime, Instant.now());
|
|
|
|
|
| totalProcessed.incrementAndGet();
|
| totalEmojisRemoved.addAndGet(foundEmojis.size());
|
|
|
|
|
| ProcessingResult result = new ProcessingResult(
|
| content,
|
| cleanedContent,
|
| foundEmojis,
|
| categoryStats,
|
| processingTime,
|
| true,
|
| handlerName
|
| );
|
|
|
| logMessage(String.format("✅ Processing completed: %d emojis removed in %d ms",
|
| foundEmojis.size(), processingTime.toMillis()));
|
|
|
| return result;
|
|
|
| } catch (Exception e) {
|
|
|
| Duration processingTime = Duration.between(startTime, Instant.now());
|
| logMessage(String.format("❌ Processing failed: %s", e.getMessage()));
|
|
|
| return new ProcessingResult(
|
| content,
|
| content,
|
| Collections.emptyList(),
|
| Collections.emptyMap(),
|
| processingTime,
|
| false,
|
| handlerName
|
| );
|
| }
|
| }
|
|
|
| |
| |
| |
| |
|
|
| private List<String> detectEmojisParallel(String content) {
|
|
|
| String cacheKey = Integer.toString(content.hashCode());
|
| if (emojiCache.containsKey(cacheKey)) {
|
| logMessage("📊 Cache hit for emoji detection");
|
| return new ArrayList<>(emojiCache.get(cacheKey));
|
| }
|
|
|
|
|
| List<String> allEmojis = EMOJI_PATTERNS.entrySet()
|
| .parallelStream()
|
| .flatMap(entry -> {
|
| Pattern pattern = entry.getValue();
|
| return pattern.matcher(content)
|
| .results()
|
| .map(MatchResult::group);
|
| })
|
| .distinct()
|
| .sorted()
|
| .collect(Collectors.toList());
|
|
|
|
|
| emojiCache.put(cacheKey, new ArrayList<>(allEmojis));
|
|
|
| return allEmojis;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| private Map<String, Integer> generateCategoryStatistics(List<String> emojis) {
|
| Map<String, Integer> stats = new HashMap<>();
|
|
|
|
|
| for (Map.Entry<String, Pattern> entry : EMOJI_PATTERNS.entrySet()) {
|
| String category = entry.getKey();
|
| Pattern pattern = entry.getValue();
|
|
|
| long count = emojis.stream()
|
| .filter(emoji -> pattern.matcher(emoji).matches())
|
| .count();
|
|
|
| if (count > 0) {
|
| stats.put(category, (int) count);
|
| }
|
| }
|
|
|
| return stats;
|
| }
|
|
|
| |
| |
| |
| |
| |
|
|
| private String removeEmojis(String content, List<String> emojis) {
|
| String result = content;
|
|
|
|
|
| for (String emoji : emojis) {
|
| result = result.replace(emoji, "");
|
| }
|
|
|
|
|
| result = result.replaceAll("\\s+", " ").trim();
|
|
|
| return result;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| @EmojiTest(value = "📦 Batch processing test", category = "⚡ Performance", priority = 2)
|
| public CompletableFuture<List<ProcessingResult>> processBatch(List<String> contentList) {
|
| logMessage(String.format("📦 Starting batch processing for %d items", contentList.size()));
|
|
|
|
|
| List<CompletableFuture<ProcessingResult>> futures = contentList.stream()
|
| .map(content -> CompletableFuture.supplyAsync(
|
| () -> processContent(content), executorService))
|
| .collect(Collectors.toList());
|
|
|
|
|
| return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
| .thenApply(v -> futures.stream()
|
| .map(CompletableFuture::join)
|
| .collect(Collectors.toList()));
|
| }
|
|
|
| |
| |
| |
|
|
| @Override
|
| public Map<String, Object> getStatistics() {
|
| Map<String, Object> stats = super.getStatistics();
|
| stats.put("📊 totalProcessed", totalProcessed.get());
|
| stats.put("🧹 totalEmojisRemoved", totalEmojisRemoved.get());
|
| stats.put("💾 cacheSize", emojiCache.size());
|
| stats.put("🧵 activeThreads", ((ThreadPoolExecutor) executorService).getActiveCount());
|
| stats.put("⏱️ averageProcessingTime", calculateAverageProcessingTime());
|
|
|
| return stats;
|
| }
|
|
|
| |
| |
| |
|
|
| private double calculateAverageProcessingTime() {
|
|
|
| return totalProcessed.get() > 0 ?
|
| (double) totalEmojisRemoved.get() / totalProcessed.get() : 0.0;
|
| }
|
|
|
| |
| |
|
|
| public void shutdown() {
|
| logMessage("🔄 Shutting down emoji processor");
|
| executorService.shutdown();
|
| try {
|
| if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) {
|
| executorService.shutdownNow();
|
| logMessage("⚡ Force shutdown completed");
|
| }
|
| } catch (InterruptedException e) {
|
| executorService.shutdownNow();
|
| Thread.currentThread().interrupt();
|
| }
|
|
|
| emojiCache.clear();
|
| logMessage("✅ Shutdown completed successfully");
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| final class EmojiUtils {
|
|
|
|
|
| private EmojiUtils() {
|
| throw new AssertionError("🚫 Utility class cannot be instantiated");
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public static Map<String, Long> countEmojiFrequency(String text) {
|
| return text.codePoints()
|
| .filter(Character::isSupplementaryCodePoint)
|
| .mapToObj(cp -> new String(Character.toChars(cp)))
|
| .collect(Collectors.groupingBy(
|
| Function.identity(),
|
| Collectors.counting()
|
| ));
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public static List<String> extractEmojis(String text) {
|
| List<String> emojis = new ArrayList<>();
|
|
|
| text.codePoints()
|
| .filter(cp -> cp >= 0x1F600 && cp <= 0x1F64F ||
|
| cp >= 0x1F300 && cp <= 0x1F5FF ||
|
| cp >= 0x1F680 && cp <= 0x1F6FF ||
|
| cp >= 0x2600 && cp <= 0x26FF)
|
| .mapToObj(cp -> new String(Character.toChars(cp)))
|
| .forEach(emojis::add);
|
|
|
| return emojis;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public static boolean containsEmojis(String text) {
|
| return text.codePoints()
|
| .anyMatch(cp -> cp >= 0x1F600 && cp <= 0x1F64F ||
|
| cp >= 0x1F300 && cp <= 0x1F5FF ||
|
| cp >= 0x1F680 && cp <= 0x1F6FF);
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public static int lengthWithoutEmojis(String text) {
|
| return (int) text.codePoints()
|
| .filter(cp -> !(cp >= 0x1F600 && cp <= 0x1F64F ||
|
| cp >= 0x1F300 && cp <= 0x1F5FF ||
|
| cp >= 0x1F680 && cp <= 0x1F6FF))
|
| .count();
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public static String generateEmojiReport(String text) {
|
| StringBuilder report = new StringBuilder();
|
| report.append("🎯 EMOJI ANALYSIS REPORT\n");
|
| report.append("========================\n\n");
|
|
|
| List<String> emojis = extractEmojis(text);
|
| Map<String, Long> frequency = countEmojiFrequency(text);
|
|
|
| report.append(String.format("📝 Total characters: %d\n", text.length()));
|
| report.append(String.format("🔍 Emojis found: %d\n", emojis.size()));
|
| report.append(String.format("🎯 Unique emojis: %d\n", frequency.size()));
|
| report.append(String.format("📏 Length without emojis: %d\n", lengthWithoutEmojis(text)));
|
| report.append(String.format("📊 Emoji density: %.2f%%\n\n",
|
| (double) emojis.size() / text.length() * 100));
|
|
|
| if (!frequency.isEmpty()) {
|
| report.append("🏆 MOST FREQUENT EMOJIS:\n");
|
| frequency.entrySet().stream()
|
| .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
| .limit(10)
|
| .forEach(entry -> report.append(String.format(" %s: %d times\n",
|
| entry.getKey(), entry.getValue())));
|
| }
|
|
|
| return report.toString();
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| public class EmojiCleanerTestRunner {
|
|
|
| |
| |
| |
|
|
| public static void main(String[] args) {
|
| System.out.println("🎉 Starting Chahuadev Emoji Cleaner Test Suite! 🧪\n");
|
|
|
|
|
| Map<String, Object> config = Map.of(
|
| "🧵 threadCount", 4,
|
| "💾 cacheEnabled", true,
|
| "📊 statisticsEnabled", true,
|
| "⚡ optimizationLevel", "high",
|
| "🔍 detectionMode", "comprehensive"
|
| );
|
|
|
|
|
| AdvancedEmojiCleanerProcessor processor = new AdvancedEmojiCleanerProcessor(config);
|
|
|
| try {
|
|
|
| runBasicTests(processor);
|
| runAdvancedTests(processor);
|
| runPerformanceTests(processor);
|
| runBatchTests(processor);
|
|
|
|
|
| displayFinalStatistics(processor);
|
|
|
| } finally {
|
|
|
| processor.shutdown();
|
| }
|
|
|
| System.out.println("\n🎉 All tests completed successfully! ✅");
|
| }
|
|
|
| |
| |
| |
|
|
| private static void runBasicTests(AdvancedEmojiCleanerProcessor processor) {
|
| System.out.println("🧪 Running basic emoji processing tests...\n");
|
|
|
|
|
| Map<String, String> testCases = Map.of(
|
| "🎯 Simple Faces",
|
| "Hello 😊 World! 😀 This is a test 🙂 with basic emojis 😃!",
|
|
|
| "❤️ Hearts and Love",
|
| "I love ❤️ programming! 💕 Java is amazing 💖 for development 💘!",
|
|
|
| "🚀 Objects and Tools",
|
| "Check out this rocket 🚀! We use tools 🔧 and technology 💻 daily ⚡!",
|
|
|
| "🌸 Nature Elements",
|
| "Beautiful flowers 🌸🌺🌻 grow in the garden 🌱 under the sun ☀️!",
|
|
|
| "🎪 Mixed Content",
|
| "🎉 Celebration time! 🚀 Let's go! 😊 Happy coding 💻 with emojis 🎨!"
|
| );
|
|
|
| testCases.forEach((testName, content) -> {
|
| System.out.println(String.format("Testing: %s", testName));
|
| ProcessingResult result = processor.processContent(content);
|
|
|
| System.out.println(String.format(" 📝 Original: %s",
|
| content.substring(0, Math.min(50, content.length())) + "..."));
|
| System.out.println(String.format(" 🧹 Cleaned: %s",
|
| result.cleanedContent().substring(0, Math.min(50, result.cleanedContent().length())) + "..."));
|
| System.out.println(String.format(" 🔍 Emojis found: %d", result.foundEmojis().size()));
|
| System.out.println(String.format(" ⏱️ Time: %d ms", result.processingTime().toMillis()));
|
| System.out.println();
|
| });
|
| }
|
|
|
| |
| |
| |
|
|
| private static void runAdvancedTests(AdvancedEmojiCleanerProcessor processor) {
|
| System.out.println("🔬 Running advanced emoji processing tests...\n");
|
|
|
|
|
| String complexContent = """
|
| 🎯 Welcome to our comprehensive emoji testing suite! 🧪
|
|
|
| This content includes:
|
| • 😀 Facial expressions: 😊 😂 🤣 😍 🥰 😘 😎 🤓 😴 😇
|
| • ❤️ Hearts and emotions: 💕 💖 💗 💘 💝 💞 💟 💔 ❣️ 💋
|
| • 🚀 Technology objects: 💻 📱 ⌨️ 🖥️ 🖨️ 📡 💾 💿 📀 🔌
|
| • 🌸 Nature elements: 🌱 🌿 🍀 🌾 🌳 🌲 🌴 🌵 🌺 🌻
|
| • 🎯 Symbols and signs: ⭐ 🌟 ✨ 💫 🌙 ☀️ ⛅ 🌈 ⚡ 🔥
|
|
|
| Special sequences and combinations:
|
| 👨💻 Developer working on 💻 computer with ☕ coffee
|
| 👩🚀 Astronaut exploring 🌍 Earth from 🚀 spaceship
|
| 🏳️🌈 Rainbow flag representing 🌈 diversity and inclusion
|
| 👨👩👧👦 Family enjoying 🎪 carnival with 🎠 carousel rides
|
|
|
| Unicode variations and modifiers:
|
| 👋🏻 👋🏼 👋🏽 👋🏾 👋🏿 (skin tone modifiers)
|
| 👍🏻 👍🏼 👍🏽 👍🏾 👍🏿 (approval with variations)
|
|
|
| Mixed language content:
|
| English: Hello 👋 World! 🌍
|
| ไทย: สวัสดี 🙏 โลก! 🌎
|
| 日本語: こんにちは 👋 世界! 🌏
|
| Español: ¡Hola 👋 Mundo! 🌍
|
|
|
| Numbers and measurements:
|
| 📊 Statistics: 85% success rate ✅
|
| 📈 Growth: +25% improvement 🚀
|
| ⏰ Time: 2:30 PM 🕐
|
| 💰 Cost: $1,299.99 💵
|
|
|
| 🎉 End of complex content testing! 🧪✨
|
| """;
|
|
|
| System.out.println("Processing complex multi-line content with 100+ emojis...");
|
| ProcessingResult result = processor.processContent(complexContent);
|
|
|
| System.out.println(result.generateReport());
|
|
|
|
|
| System.out.println("🏷️ Detailed Category Analysis:");
|
| result.categoryStats().forEach((category, count) -> {
|
| double percentage = (double) count / result.foundEmojis().size() * 100;
|
| System.out.println(String.format(" %s: %d emojis (%.1f%%)",
|
| category, count, percentage));
|
| });
|
| System.out.println();
|
| }
|
|
|
| |
| |
| |
|
|
| private static void runPerformanceTests(AdvancedEmojiCleanerProcessor processor) {
|
| System.out.println("⚡ Running performance tests...\n");
|
|
|
|
|
| StringBuilder largeContent = new StringBuilder();
|
| String[] emojiSamples = {
|
| "😀", "😃", "😄", "😁", "😆", "😅", "🤣", "😂", "🙂", "🙃",
|
| "😉", "😊", "😇", "🥰", "😍", "🤩", "😘", "😗", "😚", "😙",
|
| "🚀", "⚡", "🔥", "💧", "🌟", "✨", "💫", "⭐", "🌙", "☀️",
|
| "❤️", "🧡", "💛", "💚", "💙", "💜", "🤎", "🖤", "🤍", "💔"
|
| };
|
|
|
|
|
| for (int i = 0; i < 1000; i++) {
|
| largeContent.append("Sample text ").append(i).append(" ");
|
| largeContent.append(emojiSamples[i % emojiSamples.length]).append(" ");
|
| if (i % 10 == 0) largeContent.append("\n");
|
| }
|
|
|
| String testContent = largeContent.toString();
|
| System.out.println(String.format("📊 Generated test content: %d characters", testContent.length()));
|
|
|
|
|
| long startTime = System.nanoTime();
|
| ProcessingResult result = processor.processContent(testContent);
|
| long endTime = System.nanoTime();
|
|
|
| double totalTimeMs = (endTime - startTime) / 1_000_000.0;
|
| double throughput = result.foundEmojis().size() / (totalTimeMs / 1000.0);
|
|
|
| System.out.println("⚡ PERFORMANCE RESULTS:");
|
| System.out.println(String.format(" 📊 Total processing time: %.2f ms", totalTimeMs));
|
| System.out.println(String.format(" 🔍 Emojis processed: %d", result.foundEmojis().size()));
|
| System.out.println(String.format(" 🚀 Throughput: %.0f emojis/second", throughput));
|
| System.out.println(String.format(" 💾 Memory efficiency: High (streaming processing)"));
|
| System.out.println(String.format(" ✅ Success rate: %s", result.success() ? "100%" : "Failed"));
|
| System.out.println();
|
| }
|
|
|
| |
| |
| |
|
|
| private static void runBatchTests(AdvancedEmojiCleanerProcessor processor) {
|
| System.out.println("📦 Running batch processing tests...\n");
|
|
|
|
|
| List<String> batchContent = Arrays.asList(
|
| "🎯 First document with emojis 😊 and text content 📝",
|
| "🚀 Second item containing rockets 🚀 and stars ⭐✨",
|
| "❤️ Third piece with hearts 💕 and love 💖 symbols",
|
| "🌸 Fourth content about nature 🌿 and flowers 🌺",
|
| "🎪 Fifth document mixing celebration 🎉 and fun 🎈",
|
| "💻 Sixth item about technology 📱 and coding 👨💻",
|
| "🍎 Seventh piece with food 🍕 and drinks ☕ emojis",
|
| "🏠 Eighth content about places 🏢 and travel ✈️",
|
| "🎨 Ninth document with art 🖼️ and creativity 🎭",
|
| "🧪 Tenth item for scientific 🔬 testing purposes 📊"
|
| );
|
|
|
| System.out.println(String.format("Processing batch of %d items...", batchContent.size()));
|
|
|
| try {
|
|
|
| CompletableFuture<List<ProcessingResult>> batchFuture = processor.processBatch(batchContent);
|
| List<ProcessingResult> results = batchFuture.get(10, TimeUnit.SECONDS);
|
|
|
|
|
| long totalEmojis = results.stream()
|
| .mapToLong(r -> r.foundEmojis().size())
|
| .sum();
|
|
|
| long totalTime = results.stream()
|
| .mapToLong(r -> r.processingTime().toMillis())
|
| .sum();
|
|
|
| long successCount = results.stream()
|
| .mapToLong(r -> r.success() ? 1 : 0)
|
| .sum();
|
|
|
| System.out.println("📦 BATCH PROCESSING RESULTS:");
|
| System.out.println(String.format(" 📊 Items processed: %d", results.size()));
|
| System.out.println(String.format(" ✅ Successful: %d (%.1f%%)",
|
| successCount, (double) successCount / results.size() * 100));
|
| System.out.println(String.format(" 🔍 Total emojis removed: %d", totalEmojis));
|
| System.out.println(String.format(" ⏱️ Total processing time: %d ms", totalTime));
|
| System.out.println(String.format(" 📈 Average per item: %.1f ms",
|
| (double) totalTime / results.size()));
|
| System.out.println();
|
|
|
| } catch (Exception e) {
|
| System.err.println("❌ Batch processing failed: " + e.getMessage());
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| private static void displayFinalStatistics(AdvancedEmojiCleanerProcessor processor) {
|
| System.out.println("📊 FINAL PROCESSING STATISTICS");
|
| System.out.println("==============================\n");
|
|
|
| Map<String, Object> stats = processor.getStatistics();
|
| stats.forEach((key, value) -> {
|
| System.out.println(String.format("%s: %s", key, value));
|
| });
|
|
|
| System.out.println();
|
|
|
|
|
| String sampleText = "🎉 Sample analysis: 😊 Testing 🚀 emoji 💻 distribution 📊 in text! ⚡✨";
|
| System.out.println("🎯 SAMPLE EMOJI ANALYSIS:");
|
| System.out.println(EmojiUtils.generateEmojiReport(sampleText));
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| class EmojiTestDataFactory {
|
|
|
| |
| |
| |
| |
| |
|
|
| public static String generateTestContent(int wordCount, double emojiDensity) {
|
| Random random = new Random();
|
| StringBuilder content = new StringBuilder();
|
|
|
| String[] words = {
|
| "test", "content", "sample", "example", "demonstration",
|
| "validation", "processing", "analysis", "performance", "optimization"
|
| };
|
|
|
| String[] emojis = {
|
| "😀", "😃", "😄", "😁", "😆", "😅", "🤣", "😂", "🙂", "🙃",
|
| "🚀", "⚡", "🔥", "💧", "🌟", "✨", "💫", "⭐", "🌙", "☀️",
|
| "❤️", "🧡", "💛", "💚", "💙", "💜", "🤎", "🖤", "🤍", "💔",
|
| "📊", "📈", "📉", "📋", "📌", "📍", "📎", "📏", "📐", "📑"
|
| };
|
|
|
| for (int i = 0; i < wordCount; i++) {
|
| if (random.nextDouble() < emojiDensity) {
|
| content.append(emojis[random.nextInt(emojis.length)]);
|
| } else {
|
| content.append(words[random.nextInt(words.length)]);
|
| }
|
|
|
| if (i < wordCount - 1) {
|
| content.append(" ");
|
| }
|
| }
|
|
|
| return content.toString();
|
| }
|
|
|
| |
| |
| |
|
|
| public static Map<String, String> createTestScenarios() {
|
| return Map.of(
|
| "🧪 Light Emoji Usage",
|
| generateTestContent(100, 0.1),
|
|
|
| "🎯 Medium Emoji Usage",
|
| generateTestContent(100, 0.25),
|
|
|
| "🔥 Heavy Emoji Usage",
|
| generateTestContent(100, 0.5),
|
|
|
| "🎪 Extreme Emoji Usage",
|
| generateTestContent(50, 0.8)
|
| );
|
| }
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |