printf - Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '_' -



printf - Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '_' -

the problem conversion = "_". source code here. tried read txt , ok! code "tokenize" words , ok too. when seek save in txt error.

but if delete "__" save don't want delete "_"!

this programme used tokenize words.

i want know should in line. or can run project without exception.

exception in thread "main" java.util.unknownformatconversionexception: conversion = '_' @ cugru.test.main(test.java:81)

at line 81!!

here code:

package cugru; import java.io.bufferedreader; import java.io.file; import java.io.filereader; import java.io.filewriter; import java.io.ioexception; import java.io.printwriter; import java.util.locale; import org.cogroo.analyzer.analyzer; import org.cogroo.analyzer.componentfactory; import org.cogroo.text.document; import org.cogroo.text.impl.documentimpl; public class test { public static void main(string[] args) throws ioexception { filereader reader = new filereader(new file("d:/felipe/downloads/eclipse/workspace/java worskpace luna/excel java/sumarios/gold sem tokens.txt")); bufferedreader leitor = new bufferedreader(reader); string linha = null; int contadortokens = 0; filewriter arq = new filewriter("d:\\tabuada.txt"); printwriter gravararq = new printwriter(arq); //cria procedimentos padrao cogroo componentfactory mill = componentfactory.create(new locale("pt", "br")); analyzer cogroo = factory.createpipe(); int qtde = 0; while((linha = leitor.readline()) != null) { qtde++; if(qtde >10) break; //linha = linha.tolowercase(); //deixa em minusculo //system.out.println(linha); linha = expandiracronimos(linha); //system.out.println(linha); //system.out.println("======================================"); /** (int = 0; < sentenca.length; i++) { sentenca = linha.split(" ");// separa "linha" emdentro das aspas) e joga para o array sentenca // system.out.println(sentenca[i]);ido acetil saliclico "); // system.out.println(sentenca[i]); sentenca[i] = sentenca[i].replace(" aas "," ido acetil saliico "); }**/ document document = new documentimpl(); document.settext(linha); cogroo.analyze(document); (org.cogroo.text.sentence sentence : document.getsentences()) { // lista de sentencas sentence.getstart(); sentence.getend(); // caracteres onde sentenca comeca e termina string texto_sentenca = sentence.gettext(); // texto da sentenca //imprime sentenca //system.out.println(texto_sentenca); // tokens (org.cogroo.text.token token : sentence.gettokens()) { // lista de tokens token.getstart(); token.getend(); // caracteres onde o token comeca e termina token.getlexeme(); // o texto token (palavra que ele separa e pega exp: "clinico" token.getlemmas(); // um array com os possiveis lemas para o par lexeme+postag token.getpostag(); // classe morfologica de acordo com o contexto("coloca "prp, adj,n(noun)) token.getfeatures(); // genero, numero, tempo etc contadortokens++; system.out.println(token.getlexeme() + "_" + token.getpostag() + "_" + token.getfeatures());// imprime palavra com o tag gravararq.printf(token.getlexeme() + "__" + token.getpostag() + "__" + token.getfeatures()); //system.out.println(token.getlexeme()); } //system.out.println("total de tokens sao: "+contadortokens); } } reader.close(); arq.close(); } }

the method printf() not same println(). used formatted output. first parameter string formats characters. example:

system.out.printf( "%2d %2d%n", x, y );

but used thing wanted print first argument. method thinks format string, , looks parts begin %. have % in string, after there _. not legal format, exception.

you wanted utilize println() method. using eliminate exception.

java printf

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -