Examples of YKDictionary


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

    public YKDictionary getDictionary() {
        return dictionary;
    }
   
    public void setDictionary(YKDictionary dict) {
        YKDictionary oldValue = dictionary;
        dictionary = dict;
        DictionaryReplacedEvent dre =
            new DictionaryReplacedEvent(this, oldValue, dictionary);
        pceListeners.firePropertyChange(dre);
    }
View Full Code Here

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

            sb.append(loc);
        }
        sb.append("</td></tr>\n");
        sb.append("</table>");
       
        YKDictionary dict = proj.getDictionary();
        sb.append("<h4>");
        sb.append(Messages.getString("ExportUtil.dictionaryEntriesLabel"));
        sb.append("</h4>\n");
        sb.append("<ul>");
        recurseHTML(dict.getDictionaryRoot(), sb);
        sb.append("</ul>");
       
        sb.append("<h4>");
        sb.append(Messages.getString("ExportUtil.documentsLabel"));
        sb.append("</h4>");
View Full Code Here

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

        if (proj.getLocation()!=null){
            String loc = escapeXML(proj.getLocation().getAbsolutePath());
            sb.append(" location=\"" + loc + "\"")
        }
        sb.append(" creationdate=\"" + (new java.util.Date()) + "\">\n")
        YKDictionary dict = proj.getDictionary();
        //sb.append("<dictionary windowsize=\"" + proj.getWindowSize() + "\"");
        sb.append("<dictionary ");
       
        // XXX skip reporter in export
        /*
        String classname =
            escapeXML(dict.getReporter().getClass().getName());
        sb.append(" reporterclassname=\"" + classname + "\""); 
        */
       
        String pclassname =
            escapeXML(dict.getPatternEngine().getType());
        sb.append(" patternengine=\"" + pclassname + "\">\n");        
        recurse((CategoryNode)dict.getRoot(), sb);
        sb.append("</dictionary>\n");
       
        sb.append("<documentlist>\n");
        for (Iterator<YKDocument> iter = proj.getDocumentList().iterator(); iter.hasNext();) {
            YKDocument doc = iter.next();
View Full Code Here

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

        arrows = Pattern.compile("^\\>+(.+?)\\<+$");
    }
   
    public YKDictionary parse(File f, String enc) throws IOException {
        String s = FileUtil.slurp(f, enc);
        YKDictionary dict = parse(s);
        return dict;
    }
View Full Code Here

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

        return dict;
    }
   
    public YKDictionary parse(String s) {
        errors = new ArrayList();
        YKDictionary dict = new SimpleDictionary();
       
        String newname = "Imported VBPro Dictionary";
        dict.getDictionaryRoot().setName(newname);
        PatternEngine rengine = dict.getPatternEngine();
        dict.setName(newname);
       
        BufferedReader in = new BufferedReader(new StringReader(s));
        String line;
        int ii=0;
        CategoryNode cat = null; // the current category
        int lineNumber = 0;
        try {
            while ((line = in.readLine()) != null) {
                lineNumber++;
                String trimmed = line.trim().toLowerCase();
                if (trimmed.startsWith(">") && trimmed.endsWith("<")) {
                    // a category
                    String categoryName = stripArrows(trimmed);
                   
                    if (categoryName.length() == 0) {
                        categoryName = "Entry_" + ii;
                        ii++;
                    }
                    cat = new CategoryNodeImpl(categoryName);
                    try {
                        dict.addCategory(cat, dict.getDictionaryRoot());
                    } catch (DuplicateException de){
                        errors.add(new BadPattern(lineNumber, trimmed, true));
                    }
                } else if (trimmed.length() > 0) {
                    // no need to fix these for a SubString match-using dictionary
                    //String fixed = fixVBProWildcards(trimmed);
                    try {
                        Pattern regexp = rengine.makeRegexp(trimmed);
                        PatternNode pattern =
                            new PatternNodeImpl(trimmed, null, regexp);
                        dict.addPattern(pattern, cat);
                    } catch (DuplicateException de){
                        errors.add(new BadPattern(lineNumber, trimmed, true));
                    } catch (Exception re) {
                        errors.add(new BadPattern(lineNumber, trimmed, false));
                    }
View Full Code Here

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

    public static void main(String[] args) {
        VBProFileParser parser = new VBProFileParser();
        File f = new File("/Users/will/Desktop/testfile.txt");
       
        try {
            YKDictionary dict = parser.parse(f, "GBK");
            JOptionPane.showMessageDialog(null, new JScrollPane(new JTree(dict)));
        } catch (IOException ioe){
            ioe.printStackTrace();
        }
        for (Iterator iter = parser.getErrors().iterator(); iter.hasNext();) {
View Full Code Here

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

       
        YKOldDictionaryHandler h = new YKOldDictionaryHandler();
        InputStream stream = new FileInputStream(f);
        parser.parse(stream, h);
        stream.close();
        YKDictionary dict = h.getDictionary();
        dict.setName(f.getName());
       
        return dict;
    }
View Full Code Here

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

       
        YKDictionaryHandler h = new YKDictionaryHandler();
        InputStream stream = new FileInputStream(f);
        parser.parse(stream, h);
        stream.close();
        YKDictionary dict = h.getDictionary();
       
        return dict;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.