Package edu.harvard.wcfia.yoshikoder.dictionary

Examples of edu.harvard.wcfia.yoshikoder.dictionary.CategoryNode


  protected void writeExcel(List<YKDocument> documents, File file, CategoryNode node, int winsize) throws Exception {
    final List<YKDocument> docs = documents;
    final File outputFile = file;
    final FileOutputStream stream = new FileOutputStream(outputFile);       
    final CategoryNode catnode = node;
    final YKDictionary dict = yoshikoder.getDictionary();
    final int wsize = winsize;
   
    tworker = new TaskWorker(yoshikoder){
      protected void doWork() throws Exception {
View Full Code Here


  protected void writeCsvUTF8(List<YKDocument> documents, File file, CategoryNode node, int winsize) throws Exception {
    final List<YKDocument> docs = documents;
    final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),
        Charset.forName("UTF8")));
    final CategoryNode catnode = node;
    final YKDictionary dict = yoshikoder.getDictionary();
    final int wsize = winsize;
   
    tworker = new TaskWorker(yoshikoder){
      protected void doWork() throws Exception {
View Full Code Here

  public void actionPerformed(ActionEvent e) {
    if (yoshikoder.getProject().getDocumentList().size() > 1){

      Node n = yoshikoder.getSelectedNode();
      CategoryNode cnode = null;
      if (n instanceof CategoryNode)
        cnode = (CategoryNode)n;
      else // patternnode
      cnode = (CategoryNode)n.getParent();
      final CategoryNode catnode = cnode;

      File file;
      try {
        int resp = chooser.showSaveDialog(yoshikoder);
        if (resp != JFileChooser.APPROVE_OPTION)
View Full Code Here

 
  @Override
  public void actionPerformed(ActionEvent e) {
    Node node = yoshikoder.getSelectedNode();
    YKDictionary dict = yoshikoder.getDictionary();
    CategoryNode cnode = null;
    if (node instanceof CategoryNode)
      cnode = (CategoryNode)node;
    else
      cnode = (CategoryNode)node.getParent();
   
    if (area == null){
      area = new JTextArea(20,30);
      area.setEditable(true);
      area.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
      area.setDropMode(DropMode.INSERT);
      area.setLineWrap(true);
      area.setWrapStyleWord(true);
    } else {
      area.setText("");
    }
   
    JScrollPane pane = new JScrollPane(area);
    int resp = JOptionPane.showConfirmDialog(yoshikoder, pane, "Add patterns to " + cnode.getName(),
      JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (resp != JOptionPane.OK_OPTION)
      return;
   
    String str = area.getText();
    String[] spl = str.split("[^\\w]+");
    List<String> errors = new ArrayList<String>();
    for (int ii = 0; ii < spl.length; ii++) {
      String newpat = spl[ii];
      try {
        dict.addPattern(spl[ii], null, cnode);
      } catch (DuplicateException dex){
        // quietly supress duplicates
      } catch (Exception ex){
        errors.add(spl[ii]);
      }
    }
    yoshikoder.setSelectedNode(cnode);
   
    if (errors.size() > 0){
      StringBuffer sb = new StringBuffer();
      sb.append("There were some problems adding the patterns:\n\n");
      for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
        String string = (String) iterator.next();
        sb.append(string);
        sb.append(" ");
      }
      sb.append("\nThis is usually because " +
          "a dictionary entry of the same name already exists.");
     
      area.setText(sb.toString());
      JOptionPane.showMessageDialog(yoshikoder, new JScrollPane(area), "Error adding patterns to " + cnode.getName(),
        JOptionPane.PLAIN_MESSAGE);
    }
  }
View Full Code Here

    public void actionPerformed(ActionEvent e) {
        Node node = yoshikoder.getSelectedNode();
        if (node != null){
            if (node instanceof CategoryNode) {
                CategoryNode n = (CategoryNode)node;
                JDialog dia =
                    new EditCategoryDialog(yoshikoder, (CategoryNode)n.getParent(), n);
                dia.show();
               
            } else if (node instanceof PatternNode) {
                PatternNode n = (PatternNode)node;
                JDialog dia =
                    new EditPatternDialog(yoshikoder, (CategoryNode)n.getParent(), n);
                dia.show();
            }
        }
    }
View Full Code Here

 
  protected void writeExcel(List<YKDocument> documents, File file, CategoryNode node) throws Exception {
    final List<YKDocument> docs = documents;
    final File outputFile = file;
    final FileOutputStream stream = new FileOutputStream(outputFile);       
    final CategoryNode catnode = node;
   
    tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
              // FIRST DOC
              YKDocument doc1 = (YKDocument)docs.get(0);
View Full Code Here

  protected void writeCsvUTF8(List<YKDocument> documents, File file, CategoryNode node) throws Exception {
    final List<YKDocument> docs = documents;
    final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),
        Charset.forName("UTF8")));
    final CategoryNode catnode = node;
   
    tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
              // FIRST DOC
              YKDocument doc1 = (YKDocument)docs.get(0);
View Full Code Here

 
    public void actionPerformed(ActionEvent e) {
        if (yoshikoder.getProject().getDocumentList().size() > 1){

          Node n = yoshikoder.getSelectedNode();
            CategoryNode cnode = null;
            if (n instanceof CategoryNode)
              cnode = (CategoryNode)n;
            else // patternnode
              cnode = (CategoryNode)n.getParent();
            final CategoryNode catnode = cnode;
         
          File file;
          try {
            int resp = chooser.showSaveDialog(yoshikoder);
            if (resp != JFileChooser.APPROVE_OPTION)
View Full Code Here

        final Map<YKDocument,Concordance> concmap = yoshikoder.getDocumentConcordanceMap();
        if (concmap == null || concmap.size()==0)
          return;

        Node n = yoshikoder.getSelectedNode();
        CategoryNode cnode = null;
        if (n instanceof CategoryNode)
          cnode = (CategoryNode)n;
        else // patternnode
          cnode = (CategoryNode)n.getParent();
        final CategoryNode catnode = cnode;
       
        TaskWorker tworker = new TaskWorker(yoshikoder){
            YKDictionaryReportDialog dia;
          Map<YKDocument,EntryFrequencyMap> efmMap;
           
          protected void doWork() throws Exception {
            EntryFrequencyMap efm = null;
            for (YKDocument doc : concmap.keySet()) {
              TokenList tlist = new TokenListImpl();
              Concordance conc = concmap.get(doc);
              for (Iterator iter = conc.iterator(); iter.hasNext();) {
                ConcordanceLine line = (ConcordanceLine) iter.next();
                for (Iterator iterator = line.getLeftHandSide().iterator(); iterator.hasNext();) {
                  Token token = (Token) iterator.next();
                  tlist.add(token);
                }
                for (Iterator iterator = line.getRightHandSide().iterator(); iterator.hasNext();) {
                  Token token = (Token) iterator.next();
                  tlist.add(token);
                }
              }
              efm = new EntryFrequencyMap(yoshikoder.getDictionary(), tlist);
              efmMap.put(doc, efm);
            }
           
            // FIXME use efmMap in the report, not the most recent one!
           
            YKDocument fake =
                    YKDocumentFactory.createDummyDocument("Concordance", "none", "UTF-8");
                DictionaryFrequencyReport reportcatsonly =
                    new DictionaryFrequencyReport("Concordance Report",
                            catnode.getName() + " applied to current concordance",
                            yoshikoder.getDictionary().getName(),
                            fake, efm, false);
                DictionaryFrequencyReport reportcatsandpats =
                    new DictionaryFrequencyReport("Concordance Report",
                        catnode.getName() + "applied to current concordance",
                            yoshikoder.getDictionary().getName(),
                            fake, efm, true);
                dia = new YKDictionaryReportDialog(yoshikoder, reportcatsonly, reportcatsandpats, onlyShowCats);
            }
            protected void onSuccess() {
View Full Code Here

                throw new Exception(Messages.getString("noEntryName")); //$NON-NLS-1$
            }
            Double d = getScore();
            String desc = description.getText();
           
            CategoryNode node =
                new CategoryNodeImpl(name.getText(), d, desc)
            yoshikoder.addCategory(node, parent);
            yoshikoder.setSelectedNode(node);
            yoshikoder.setUnsavedChanges(true);
View Full Code Here

TOP

Related Classes of edu.harvard.wcfia.yoshikoder.dictionary.CategoryNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.