All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wf.utils.java.misc.WordCollector Maven / Gradle / Ivy

The newest version!
package wf.utils.java.misc;


//import org.jsoup.Jsoup;
//import org.jsoup.nodes.Document;
//import org.jsoup.nodes.Element;
//import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

public class WordCollector {

//    private static final String collectorUrl = "https://makeword.ru/combo/";
//
//
//    public static HashMap> collectWordsMap(String letters){
//        try {
//            return toMap(Jsoup.connect(collectorUrl + letters).get()
//                    .select("body > div.content_wrapper > div.content_left > ul > li > a")
//                    .stream().map(Element::wholeText).collect(Collectors.toList()));
//        } catch (IOException e) {throw new RuntimeException(e);}
//    }
//
//    public static ArrayList collectWords(String letters){
//        HashMap> wordsMap = collectWordsMap(letters);
//        return (ArrayList) wordsMap.get(letters.length());
//    }
//
//    public static String collectWord(String letters){
//        ArrayList words = collectWords(letters);
//        if(words == null || words.size() == 0) return null;
//        return words.get(0);
//    }
//
//    private static HashMap> toMap(Collection words){
//        HashMap> sorted = new HashMap<>();
//        words.forEach((w) ->{
//          if(sorted.containsKey(w.length())) { sorted.get(w.length()).add(w); }
//          else {
//              ArrayList newList = new ArrayList<>();
//              newList.add(w);
//              sorted.put(w.length(), newList);
//          }
//        });
//        return sorted;
//    }



}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy