Package edu.harvard.wcfia.yoshikoder.util

Examples of edu.harvard.wcfia.yoshikoder.util.TaskWorker


    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 {
        // TODO remove redundant code here!
       
        // FIRST DOC
        YKDocument doc1 = (YKDocument)docs.get(0);
View Full Code Here


        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 {
        // FIRST DOC
        YKDocument doc1 = (YKDocument)docs.get(0);
        // tokenize the document
        TokenizationCache tcache = yoshikoder.getTokenizationCache();
View Full Code Here

        final int wsize = yoshikoder.getWindowSize();
        final YKDocument[] docs = yoshikoder.getSelectedDocuments();
        if (docs == null || docs.length == 0)
          return;
       
        tworker = new TaskWorker(yoshikoder){
            Map<YKDocument,Concordance> m = null;
            protected void doWork() throws Exception {
              m = makeMultipleDocumentConcordance(docs, n, wsize);
            }
            protected void onError(){
View Full Code Here

        String fname = dictionarySaver.getFile();
        if (fname == null) return;
        File f = new File(dictionarySaver.getDirectory(), FileUtil.suffix(fname, "ykd"));
       
        final File file = FileUtil.suffix(f, "ykd");
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
                YKDictionary dict = yoshikoder.getDictionary();
                ExportUtil.exportAsXML(dict, file);
            }
            protected void onError() {
View Full Code Here

        String fname = documentExporter.getFile();
        if (fname == null) return;
       
        File filed = new File(documentExporter.getDirectory(), fname);
        final File file = FileUtil.suffix( filed, "txt");
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
                FileUtil.save(file, doc.getText(), "UTF-16");
            }
            protected void onError() {
                DialogUtil.yelp(yoshikoder, "Could not export the document", e); // TODO loc
View Full Code Here

        String filename = concordanceExporter.getFile();
        if (filename == null) return;
       
        final File file = new File(concordanceExporter.getDirectory(),
                FileUtil.suffix(filename, "html", "htm"));
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
                ExportUtil.exportAsHTML(dcMap, file);
            }
            protected void onError() {
                DialogUtil.yelp(yoshikoder, "Could not export concordance as HTML", e);
View Full Code Here

    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);
              // tokenize the document
            TokenizationCache tcache = yoshikoder.getTokenizationCache();
View Full Code Here

    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);
              // tokenize the document
            TokenizationCache tcache = yoshikoder.getTokenizationCache();
View Full Code Here

        final File[] fs = documentChooser.getSelectedFiles();
        if (fs.length == 0) return;
       
        final Locale defLoc = yoshikoder.getDefaultLocale();
       
        tworker = new TaskWorker(yoshikoder){
            YKDocument[] docs;
            protected void doWork() throws Exception {
                docs = new YKDocument[fs.length];
                for (int ii = 0; ii < fs.length; ii++) {      
                    YKDocument doc = YKDocumentFactory.createYKDocument(fs[ii], fs[ii].getName(),
View Full Code Here

          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() {
              dia.setVisible(true);
              onlyShowCats = !dia.getCurrentReport().getShowPatterns();
            }
           
            protected void onError() {
                if (e instanceof TokenizationException){
                    DialogUtil.yelp(yoshikoder, "Tokenization Error", e);
                } else if (e instanceof IOException){
                    DialogUtil.yelp(yoshikoder, "Input/Ouput Error", e);
                } else {
                    DialogUtil.yelp(yoshikoder, "Error", e);
                }
            }
        };
        tworker.start();
    }
View Full Code Here

TOP

Related Classes of edu.harvard.wcfia.yoshikoder.util.TaskWorker

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.