MCPcopy Index your code
hub / github.com/antlr/codebuff / getWSEditDistance

Method getWSEditDistance

src/org/antlr/codebuff/Formatter.java:169–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167 }
168
169 public float getWSEditDistance() throws Exception {
170 List<Token> wsTokens = filter(originalTokens.getTokens(),
171 t -> t.getText().matches("\\s+")); // only count whitespace
172 String originalWS = tokenText(wsTokens);
173
174 String formattedOutput = getOutput();
175 CommonTokenStream formatted_tokens = tokenize(formattedOutput, corpus.language.lexerClass);
176 wsTokens = filter(formatted_tokens.getTokens(),
177 t -> t.getText().matches("\\s+"));
178 String formattedWS = tokenText(wsTokens);
179
180 float editDistance = normalizedLevenshteinDistance(originalWS, formattedWS);
181 return editDistance;
182 }
183
184 public void processToken(int indexIntoRealTokens, int tokenIndexInStream, boolean collectAnalysis) {
185 CommonToken curToken = (CommonToken)testDoc.tokens.get(tokenIndexInStream);

Callers

nothing calls this directly

Calls 7

getOutputMethod · 0.95
tokenTextMethod · 0.80
tokenizeMethod · 0.80
getTextMethod · 0.65
filterMethod · 0.45
matchesMethod · 0.45

Tested by

no test coverage detected