首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Java中的PostFix押韵词查找器,功能和数据结构缺失

Java中的PostFix押韵词查找器,功能和数据结构缺失
EN

Stack Overflow用户
提问于 2018-10-19 03:57:42
回答 1查看 101关注 0票数 2

我需要创建一个后缀查找器。下面是我写的代码。我必须导入整个单词字典,不知道已排序或未排序的单词以及它将使用哪种数据结构/文件类型。此外,通过过滤后缀关键字来查找单词的功能,然后显示到列表是要做的。

代码语言:javascript
复制
package hamqafia;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javafx.scene.text.Text;
import javax.swing.JButton;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JTextField;

/**
 *
 * @author Zeeshan
 */
public class HamQafia {
    private static JTextField text;
    private static JFrame frame;
    private static JButton findBtn;
    DataStructure Dictionary_of_all_words;


    public static void main(String[] args) {
        // TODO code application logic here

        //String[] words = {"Runner, Stealth, Gunner, male, Butter, Old, sar, gold"};


        windowMaker();

    }

    private static void windowMaker(){
        //Initializing and painting GUI components
        frame = new JFrame();
        text = new JTextField(20);

        findBtn = new JButton("Find");
        findBtn.setSize(200,200);
        findBtn.setVisible(true);

        frame.setSize(600, 600);
        frame.setLayout(new FlowLayout());
        frame.setVisible(true);
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);


        frame.add(text);
        frame.add(findBtn);


        //Click Action
        findBtn.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            String postFix = text.getText().toString();
            finder(postFix);
            }


        });
    }

    private static void finder(String postFix){
        //Find method to search the words from entire dictionary an show them in the list. 
        // For example:
        // postFix = ry
        //Output: cry, fry, try, dry
    }

}
EN

回答 1

Stack Overflow用户

发布于 2018-10-19 04:16:53

您可以创建字符串类型的数组,并存储以逗号分隔的整个英语单词字典。是的,字典应该是有序的格式,以便快速查找。下面是关于finder函数的一些粗略想法

代码语言:javascript
复制
private static void finder(String postFix){
     for(int i=0, i<dictionaryArray.length; i++){
          if(dictionaryArray[i] == postFix){
                 ListView.add(dictionaryArray[i]);
          }
      }  


      //Find method to search the words from entire dictionary an show them in the list. 
        // For example:
        // postFix = ry
        //Output: cry, fry, try, dry
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52881606

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档