Package com.inet.jorthodictionaries.BookGenerator_ru

Examples of com.inet.jorthodictionaries.BookGenerator_ru.Template


    @Override
    boolean isValidLanguage( String word, String wikiText ) {

        //The list of templates can be found at:
        //http://ru.wiktionary.org/wiki/%D0%9A%D0%B0%D1%82%D0%B5%D0%B3%D0%BE%D1%80%D0%B8%D1%8F:%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD%D1%8B_%D1%81%D0%BB%D0%BE%D0%B2%D0%BE%D0%B8%D0%B7%D0%BC%D0%B5%D0%BD%D0%B5%D0%BD%D0%B8%D0%B9/%D0%A4%D0%B0%D0%BC%D0%B8%D0%BB%D0%B8%D0%B8
        Template template = findRules( word, wikiText );
        if(template.getRuleCount() > 0 ){
            templates.put( template.getName(), template );
            System.out.print(".");
        }
        return false;
    }
View Full Code Here


     * @return
     */
    private Template findRules( String word, String wikiText ) {
        int idxStart = wikiText.indexOf( "{{{" );
        int idxEnd = wikiText.indexOf( "}}}", idxStart );
        Template template = generator.new Template(word);
        while( idxStart >= 0 && idxEnd >= 0 ) {
            String rule = wikiText.substring( idxStart+3, idxEnd );
           
            //ignore cascading rules
            boolean validRule = rule.length() > 0;
            for(int i=0; i<rule.length(); i++){
                char c = rule.charAt( i );
                if(c != ' ' && !Character.isLetterOrDigit( c ) ){
                    validRule = false;
                    break;
                }
            }
            if(validRule){
                String ending = findEnding(wikiText, idxEnd+3);
                if(ending.length() > 0){
                    template.addEnding( rule, ending );
                }
            }
           
            idxStart = wikiText.indexOf( "{{{", idxEnd );
            idxEnd = wikiText.indexOf( "}}}", idxStart );
View Full Code Here

TOP

Related Classes of com.inet.jorthodictionaries.BookGenerator_ru.Template

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.