repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
---|---|---|---|---|---|---|
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFDoc.java | package org.allenai.scienceparse.pdfapi;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Wither;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
public class PDFDoc {
/**
* Index in the lines of the first page which is the stop (one beyond the last)
* line that makes the header of the document (the title, authors, etc.)
* <p>
* This is < 0 if we can't find an appropriate header/main cut.
*/
@Wither public final List<PDFPage> pages;
public final PDFMetadata meta;
public PDFDoc withoutSuperscripts() {
final List<PDFPage> newPages = new ArrayList<>(pages.size());
for(PDFPage page : pages)
newPages.add(page.withoutSuperscripts());
return this.withPages(newPages);
}
}
| 759 | 25.206897 | 81 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFExtractor.java | package org.allenai.scienceparse.pdfapi;
import com.gs.collections.api.list.primitive.FloatList;
import com.gs.collections.impl.list.mutable.primitive.FloatArrayList;
import lombok.Builder;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.allenai.scienceparse.ExtractReferences;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.util.DateConverter;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.text.TextPosition;
import java.io.IOException;
import java.io.InputStream;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.ToDoubleFunction;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
@Slf4j
public class PDFExtractor {
private final Options opts;
public boolean DEBUG = false;
public PDFExtractor(Options opts) {
this.opts = opts;
}
public PDFExtractor() {
this.opts = Options.builder().build();
}
private static List<String> guessKeywordList(String listStr) {
return listStr != null && listStr.length() > 0
? Arrays.asList(listStr.split(","))
: Collections.emptyList();
}
private static List<String> guessAuthorList(String listStr) {
if (listStr != null && listStr.length() > 0) {
String[] authorArray = listStr.indexOf(';') >= 0 ? listStr.split(";") : listStr.split(",");
ArrayList<String> trimmedAuthors = new ArrayList<>(authorArray.length);
for(String author : authorArray)
trimmedAuthors.add(author.trim());
return trimmedAuthors;
} else {
return Collections.emptyList();
}
}
private static double relDiff(double a, double b) {
return Math.abs(a - b) / Math.min(Math.abs(a), Math.abs(b));
}
private boolean badPDFTitleFast(String title) {
if (title == null) {
return true;
}
// Ending with file extension is what Microsoft Word tends to do
if (
title.endsWith(".pdf") || title.endsWith(".doc") ||
// Ellipsis are bad, since title is abbreviated
title.endsWith("...") ||
// Some conferences embed this in start of title
// HACK(aria42) English-specific and conference-structure specific
title.trim().toLowerCase().startsWith("proceedings of") ||
title.trim().startsWith("arXiv:")) {
return true;
}
// Check words are capitalized
String[] words = title.split("\\s+");
boolean hasCapitalWord = Stream.of(words)
.filter(w -> !w.isEmpty())
.anyMatch(w -> Character.isUpperCase(w.charAt(0)));
return !hasCapitalWord;
}
private boolean badPDFTitle(PDFPage firstPage, String title) {
if (badPDFTitleFast(title)) {
return true;
}
Optional<PDFLine> matchLine = firstPage.lines.stream().filter(l -> {
String lineText = l.lineText();
return lineText.startsWith(title) || title.startsWith(lineText);
}).findFirst();
return !matchLine.isPresent();
}
@SneakyThrows
private Date toDate(String cosVal) {
if (cosVal == null) {
return null;
}
String strippedDate = cosVal.replace("^D:", "");
Calendar cal = null;
cal = DateConverter.toCalendar(strippedDate);
return cal == null ? null : cal.getTime();
}
@SneakyThrows
public PdfDocExtractionResult extractResultFromInputStream(InputStream is) {
try (PDDocument pdfBoxDoc = PDDocument.load(is)) {
return extractResultFromPDDocument(pdfBoxDoc);
}
}
@SneakyThrows
public PdfDocExtractionResult extractResultFromPDDocument(PDDocument pdfBoxDoc) {
val info = pdfBoxDoc.getDocumentInformation();
List<String> keywords = guessKeywordList(info.getKeywords());
List<String> authors = guessAuthorList(info.getAuthor());
val meta = PDFMetadata.builder()
.title(info.getTitle() != null ? info.getTitle().trim() : null)
.keywords(keywords)
.authors(authors)
.creator(info.getCreator());
String createDate = info.getCustomMetadataValue(COSName.CREATION_DATE.getName());
if (createDate != null) {
meta.createDate(toDate(createDate));
} else {
// last ditch attempt to read date from non-standard meta
OptionalInt guessYear = Stream.of("Date", "Created")
.map(info::getCustomMetadataValue)
.filter(d -> d != null && d.matches("\\d\\d\\d\\d"))
.mapToInt(Integer::parseInt)
.findFirst();
if (guessYear.isPresent()) {
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(Calendar.YEAR, guessYear.getAsInt());
meta.createDate(calendar.getTime());
}
}
String lastModDate = info.getCustomMetadataValue(COSName.CREATION_DATE.getName());
if (lastModDate != null) {
meta.lastModifiedDate(toDate(lastModDate));
}
val stripper = new PDFCaptureTextStripper();
// SIDE-EFFECT pages ivar in stripper is populated
stripper.getText(pdfBoxDoc);
String title = info.getTitle();
// kill bad title
if (stripper.pages.isEmpty() || badPDFTitle(stripper.pages.get(0), title)) {
title = null;
}
boolean highPrecision = title != null;
// Title heuristic
if (opts.useHeuristicTitle && title == null) {
try {
String guessTitle = getHeuristicTitle(stripper);
if (!badPDFTitleFast(guessTitle)) {
title = guessTitle;
}
} catch (final Exception ex) {
log.warn("Exception while guessing heuristic title", ex);
// continue with previous title
}
}
meta.title(title);
PDFDoc doc = PDFDoc.builder()
.pages(stripper.pages)
.meta(meta.build())
.build();
return PdfDocExtractionResult.builder()
.document(doc)
.highPrecision(highPrecision).build();
}
@SneakyThrows
public PDFDoc extractFromInputStream(InputStream is) {
return extractResultFromInputStream(is).document;
}
private String getHeuristicTitle(PDFCaptureTextStripper stripper) {
PDFPage firstPage = stripper.pages.get(0);
ToDoubleFunction<PDFLine> lineFontSize =
//line -> line.height();
line -> line.getTokens().stream().mapToDouble(t -> t.getFontMetrics().getPtSize()).average().getAsDouble();
double largestSize = firstPage.getLines().stream()
.filter(l -> !l.getTokens().isEmpty())
.mapToDouble(lineFontSize::applyAsDouble)
.max().getAsDouble();
int startIdx = IntStream.range(0, firstPage.lines.size())
//.filter(idx -> relDiff(lineFontSize.applyAsDouble(firstPage.lines.get(idx)), largestSize) < 0.01)
.filter(idx -> lineFontSize.applyAsDouble(firstPage.lines.get(idx)) == largestSize)
.findFirst().getAsInt();
int stopIdx = IntStream.range(startIdx + 1, firstPage.lines.size())
//.filter(idx -> relDiff(lineFontSize.applyAsDouble(firstPage.lines.get(idx)),largestSize) >= 0.05)
.filter(idx -> lineFontSize.applyAsDouble(firstPage.lines.get(idx)) < largestSize)
.findFirst()
.orElse(firstPage.lines.size() - 1);
if (startIdx == stopIdx) {
return null;
}
double lastYDiff = Double.NaN;
List<PDFLine> titleLines = firstPage.lines.subList(startIdx, stopIdx);
if (titleLines.size() == 1) {
return titleLines.get(0).lineText();
}
PDFLine firstLine = titleLines.get(0);
// If the line is to far down the first page, unlikely to be title
float fractionDownPage = firstLine.bounds().get(1) / firstPage.getPageHeight();
if (fractionDownPage > 0.66 || startIdx > 5) {
return null;
}
for (int idx = 0; idx + 1 < titleLines.size(); ++idx) {
PDFLine line = titleLines.get(idx);
PDFLine nextLine = titleLines.get(idx + 1);
double yDiff = nextLine.bounds().get(1) - line.bounds().get(3);
double yDiffNormed = yDiff / line.height();
if (yDiffNormed > 1.5 || (idx > 0 && relDiff(yDiff, lastYDiff) > 0.1)) {
titleLines = titleLines.subList(0, idx + 1);
break;
}
lastYDiff = yDiff;
}
return titleLines.stream().map(PDFLine::lineText).collect(Collectors.joining(" "));
}
@Builder
public static class Options {
public boolean useHeuristicTitle = false;
}
@Data(staticConstructor = "of")
private final static class RawChunk {
// The PDFBox class doesn't get exposed outside of this class
public final List<TextPosition> textPositions;
public PDFToken toPDFToken() {
val builder = PDFToken.builder();
// HACK(aria42) assumes left-to-right text
TextPosition firstTP = textPositions.get(0);
PDFont pdFont = firstTP.getFont();
val desc = pdFont.getFontDescriptor();
String fontFamily = desc == null ? PDFFontMetrics.UNKNWON_FONT_FAMILY : desc.getFontName();
float ptSize = firstTP.getFontSizeInPt();
//HACK(ddowney): it appears that sometimes (maybe when half-pt font sizes are used), pdfbox 2.0 will multiply
// all of the true font sizes by 10. If we detect this is likely, we divide font size by ten:
if(ptSize > 45.0f)
ptSize /= 10.0f;
//HACK(ddowney): ensure unique sizes get unique names/objects:
fontFamily += "_" + ptSize + "_" + firstTP.getWidthOfSpace();
val fontMetrics = PDFFontMetrics.of(fontFamily, ptSize, firstTP.getWidthOfSpace());
builder.fontMetrics(fontMetrics);
float minX = Float.POSITIVE_INFINITY;
float maxX = Float.NEGATIVE_INFINITY;
float minY = Float.POSITIVE_INFINITY;
float maxY = Float.NEGATIVE_INFINITY;
for (TextPosition tp : textPositions) {
float x0 = tp.getX();
if (x0 < minX) {
minX = x0;
}
float x1 = x0 + tp.getWidth();
if (x1 > maxX) {
maxX = x1;
}
float y0 = tp.getY() - tp.getHeight(); //getY returns the bottom-left
if (y0 < minY) {
minY = y0;
}
float y1 = tp.getY();
if (y1 > maxY) {
maxY = y1;
}
}
FloatList bounds = FloatArrayList.newListWith(minX, minY, maxX, maxY);
builder.bounds(bounds);
// put together text from the textPositions, handling superscripts appropriately
// Since we have to map superscripts into flat strings, we encode superscripts by enclosing
// them in ⍐ and ⍗ characters.
String tokenText;
{
final double yThresh = (bounds.get(3) + bounds.get(1)) / 2.0;
final double yGap = (bounds.get(3) - bounds.get(1));
final StringBuilder sb = new StringBuilder();
final StringBuilder superscriptSb = new StringBuilder();
for (TextPosition tp : textPositions) {
if (tp.getY() > yThresh || (yThresh - tp.getY() > yGap / 6.0)) { // latter case suggests a height bug (?) so ignore
// normal character
if(ExtractReferences.mentions.matcher(superscriptSb).matches()) {
assert superscriptSb.length() > 0;
sb.append('⍐');
sb.append(superscriptSb);
sb.append('⍗');
}
superscriptSb.setLength(0);
sb.append(tp.getUnicode());
} else {
// superscript character
superscriptSb.append(tp.getUnicode());
}
}
// pick up leftover superscripts
if(ExtractReferences.mentions.matcher(superscriptSb).matches()) {
assert superscriptSb.length() > 0;
sb.append('⍐');
sb.append(superscriptSb);
sb.append('⍗');
}
tokenText = sb.toString();
}
// separate ligands
tokenText = Normalizer.normalize(tokenText, Normalizer.Form.NFKC);
builder.token(tokenText);
return builder.build();
}
}
private class PDFCaptureTextStripper extends PDFTextStripper {
private List<PDFPage> pages = new ArrayList<>();
private List<PDFLine> curLines;
private List<PDFToken> curLineTokens;
private PDFToken lastToken;
// Mandatory for sub-classes
public PDFCaptureTextStripper() throws IOException {
super();
}
@Override
protected void writeString(String text, List<TextPosition> textPositions) throws IOException {
// Build current token and decide if on the same line as previous token or starts a new line
List<TextPosition> curPositions = new ArrayList<>();
List<PDFToken> tokens = new ArrayList<>();
double prevX = -1.0;
for (TextPosition tp : textPositions) {
if(prevX > 0.0 && tp.getX() < prevX) { //catch out-of-phase columns
List<TextPosition> tokenPositions = new ArrayList<>(curPositions);
if (tokenPositions.size() > 0) {
tokens.add(RawChunk.of(tokenPositions).toPDFToken());
}
curPositions.clear();
curPositions.add(tp);
}
else if (tp.getUnicode().trim().isEmpty()) {
List<TextPosition> tokenPositions = new ArrayList<>(curPositions);
if (tokenPositions.size() > 0) {
tokens.add(RawChunk.of(tokenPositions).toPDFToken());
}
curPositions.clear();
} else {
curPositions.add(tp);
}
prevX = tp.getX();
}
if (!curPositions.isEmpty()) {
tokens.add(RawChunk.of(new ArrayList<>(curPositions)).toPDFToken());
}
for (PDFToken token : tokens) {
updateFromToken(token);
}
}
private void updateFromToken(PDFToken token) {
if (curLineTokens.isEmpty()) {
curLineTokens.add(token);
} else {
final double curTop = token.bounds.get(1);
final double curBottom = token.bounds.get(3);
assert curTop <= curBottom;
final double lastTop = lastToken.bounds.get(1);
final double lastBottom = lastToken.bounds.get(3);
assert lastTop <= lastBottom;
final boolean yOffsetOverlap =
(curTop >= lastTop && curTop <= lastBottom) ||
(curBottom >= lastTop && curBottom <= lastBottom);
float spaceWidth = Math.max(token.getFontMetrics().getSpaceWidth(), token.getFontMetrics().ptSize);
float observedWidth = token.bounds.get(0) - lastToken.bounds.get(2);
boolean withinSpace = observedWidth > 0 && observedWidth < 4 * spaceWidth;
if (yOffsetOverlap && withinSpace) {
curLineTokens.add(token);
} else {
curLines.add(toLine(curLineTokens));
curLineTokens.clear();
curLineTokens.add(token);
}
}
lastToken = token;
}
@Override
protected void startPage(PDPage page) {
curLines = new ArrayList<>();
curLineTokens = new ArrayList<>();
}
private PDFLine toLine(List<PDFToken> tokens) {
// trigger copy of the list to defend against mutation
return PDFLine.builder().tokens(new ArrayList<>(tokens)).build();
}
@Override
protected void endPage(PDPage pdfboxPage) {
if (!curLineTokens.isEmpty()) {
curLines.add(toLine(curLineTokens));
}
PDRectangle pageRect = pdfboxPage.getMediaBox() == null ?
pdfboxPage.getArtBox() :
pdfboxPage.getMediaBox();
val page = PDFPage.builder()
.lines(new ArrayList<>(curLines))
.pageNumber(pages.size())
.pageWidth((int) pageRect.getWidth())
.pageHeight((int) pageRect.getHeight())
.build();
pages.add(page);
}
}
}
| 15,921 | 35.104308 | 125 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFFontMetrics.java | package org.allenai.scienceparse.pdfapi;
import lombok.Data;
import lombok.val;
import java.util.concurrent.ConcurrentHashMap;
@Data
public class PDFFontMetrics {
private static final ConcurrentHashMap<String, PDFFontMetrics> canonical
= new ConcurrentHashMap<>();
/**
* The special value for when the underlying font didn't have
* an extractable family name.
*/
public static String UNKNWON_FONT_FAMILY = "*UNKNOWN*";
public final String name;
public final float ptSize;
public final float spaceWidth;
/**
* Ensures one font object per unique font name
*
* @param name
* @param ptSize
* @param spaceWidth
* @return
*/
public static PDFFontMetrics of(String name, float ptSize, float spaceWidth) {
val fontMetrics = new PDFFontMetrics(name, ptSize, spaceWidth);
val curValue = canonical.putIfAbsent(name, fontMetrics);
return curValue != null ? curValue : fontMetrics;
}
public String stringRepresentation() {
return String.format("%s-%f", name, ptSize);
}
}
| 1,036 | 25.589744 | 80 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFLine.java | package org.allenai.scienceparse.pdfapi;
import com.gs.collections.api.list.primitive.FloatList;
import com.gs.collections.impl.list.mutable.primitive.FloatArrayList;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Wither;
import lombok.val;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
/**
* Immutable value class representing a single contiguous line of a PDF. A contiguous line means
* a sequence of tokens/glyphs which are intended to be read sequentially. For instance, a two column
* paper might have two lines at the same y-position.
*/
@Builder
@Data
public class PDFLine {
@Wither public final List<PDFToken> tokens;
private DoubleStream projectCoord(int dim) {
return tokens.stream().mapToDouble(t -> t.bounds.get(dim));
}
/**
* (0,0) origin bounds [x0,y0, x1, y1] for the entire line.
* Should
*/
public FloatList bounds() {
float x0 = (float) projectCoord(0).min().getAsDouble();
float y0 = (float) projectCoord(1).min().getAsDouble();
float x1 = (float) projectCoord(2).max().getAsDouble();
float y1 = (float) projectCoord(3).max().getAsDouble();
return FloatArrayList.newListWith(x0, y0, x1, y1);
}
public float height() {
val bs = bounds();
return bs.get(3) - bs.get(1);
}
public String lineText() {
return tokens.stream().map(PDFToken::getToken).collect(Collectors.joining(" "));
}
public double avgFontSize() {
return tokens.stream().mapToDouble(t -> t.getFontMetrics().getPtSize()).average().orElse(0.0);
}
public PDFLine withoutSuperscripts() {
final List<PDFToken> newTokens = new ArrayList<>(tokens.size());
for(PDFToken token : tokens) {
final String newTokenText = token.token.replaceAll("⍐[^⍗]*⍗", "");
if(!newTokenText.isEmpty())
newTokens.add(token.withToken(newTokenText));
}
return this.withTokens(newTokens);
}
}
| 2,002 | 29.815385 | 101 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFMetadata.java | package org.allenai.scienceparse.pdfapi;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import lombok.Builder;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.val;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
/**
* Immutable class representing information obtained from scanning for PDF
* meta-data. Many pdf creation programs (like pdflatex) will actuallly output
* information like these fields which substantially aids downstream extraction.
*/
@Builder
@Data
public class PDFMetadata {
public final String title;
public final List<String> authors;
public final List<String> keywords;
public final Date createDate;
public final Date lastModifiedDate;
public final String creator;
// HACK(aria42) For external testing purpose
@SneakyThrows
public static void main(String[] args) {
val extractor = new PDFExtractor();
ObjectWriter ow = new ObjectMapper().writer();
if (args.length <= 1)
ow = ow.withDefaultPrettyPrinter();
for (final String arg : args) {
String prefix = "";
if (args.length > 1)
prefix = arg + "\t";
try (InputStream pdfInputStream = new FileInputStream(arg)) {
try {
PDFMetadata meta = extractor.extractFromInputStream(pdfInputStream).getMeta();
String json = ow.writeValueAsString(meta);
System.out.println(prefix + json);
} catch (final Exception e) {
System.out.println(prefix + "ERROR: " + e);
}
}
}
}
}
| 1,609 | 29.377358 | 88 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFPage.java | package org.allenai.scienceparse.pdfapi;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Wither;
import java.util.ArrayList;
import java.util.List;
@Builder
@Data
public class PDFPage {
@Wither public final List<PDFLine> lines;
public final int pageNumber;
public final int pageWidth;
public final int pageHeight;
public PDFPage withoutSuperscripts() {
final List<PDFLine> newLines = new ArrayList<>(lines.size());
for(PDFLine line : lines) {
final PDFLine newLine = line.withoutSuperscripts();
if(!newLine.tokens.isEmpty())
newLines.add(newLine);
}
return this.withLines(newLines);
}
}
| 661 | 22.642857 | 65 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PDFToken.java | package org.allenai.scienceparse.pdfapi;
import com.gs.collections.api.list.primitive.FloatList;
import lombok.Builder;
import lombok.Value;
import lombok.experimental.Wither;
@Builder
@Value
public class PDFToken {
@Wither public final String token;
public final PDFFontMetrics fontMetrics;
/**
* List of ints [x0, y0, x1, y1] where [0,0] is upper left
*/
public final FloatList bounds;
}
| 406 | 21.611111 | 60 | java |
science-parse | science-parse-master/core/src/main/java/org/allenai/scienceparse/pdfapi/PdfDocExtractionResult.java | package org.allenai.scienceparse.pdfapi;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class PdfDocExtractionResult {
public final PDFDoc document;
public final boolean highPrecision;
}
| 211 | 16.666667 | 40 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/CRFBibRecordParserTest.java | package org.allenai.scienceparse;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.testng.annotations.Test;
import com.gs.collections.api.tuple.Pair;
import junit.framework.Assert;
import lombok.val;
import lombok.extern.slf4j.Slf4j;
@Test
@Slf4j
public class CRFBibRecordParserTest {
public void testReadData() throws IOException {
File coraFile = new File(this.getClass().getResource("/coratest.txt").getFile());
val labels = CRFBibRecordParser.labelFromCoraFile(coraFile);
log.info(labels.toString());
Assert.assertEquals(1, labels.size());
boolean foundOne = false;
boolean foundTwo = false;
boolean foundThree = false;
for(Pair<String, String> p : labels.get(0)) {
if(p.getOne().equals("Formalising") && p.getTwo().equals("B_T"))
foundOne = true;
if(p.getOne().equals("formalism.") && p.getTwo().equals("E_T"))
foundTwo = true;
if(p.getOne().equals("1992.") && p.getTwo().equals("W_Y"))
foundThree = true;
}
Assert.assertTrue(foundOne);
Assert.assertTrue(foundTwo);
Assert.assertTrue(foundThree);
File umassFile = new File(this.getClass().getResource("/umasstest.txt").getFile());
val labels2 = CRFBibRecordParser.labelFromUMassFile(umassFile);
log.info(labels2.toString());
Assert.assertEquals(1, labels2.size());
foundOne = false;
foundTwo = false;
for(Pair<String, String> p : labels2.get(0)) {
if(p.getOne().equals("E.") && p.getTwo().equals("B_A"))
foundOne = true;
if(p.getOne().equals("1979") && p.getTwo().equals("B_Y"))
foundTwo = true;
}
Assert.assertTrue(foundOne);
Assert.assertTrue(foundTwo);
File kermitFile = new File(this.getClass().getResource("/kermittest.txt").getFile());
val labels3 = CRFBibRecordParser.labelFromKermitFile(kermitFile);
log.info(labels3.toString());
Assert.assertEquals(2, labels3.size());
foundOne = false;
foundTwo = false;
for(Pair<String, String> p : labels3.get(1)) {
if(p.getOne().equals("Hinshaw,") && p.getTwo().equals("B_A"))
foundOne = true;
if(p.getOne().equals("Shock") && p.getTwo().equals("E_V"))
foundTwo = true;
}
Assert.assertTrue(foundOne);
Assert.assertTrue(foundTwo);
}
public void testCoraLabeling() throws Exception {
String s = "<author> A. Cau </author> <title> Formalising Dijkstra's development strategy within Stark's formalism. </title> <booktitle> BCS-FACS Refinement Workshop, </booktitle> <date> 1992. </date>";
int tokens = 2 + 21 - 8; //start/stop plus tokens in source minus eight tags.
List<Pair<String, String>> labeledData = CRFBibRecordParser.getLabeledLineCora(s);
Assert.assertEquals(tokens, labeledData.size());
Assert.assertEquals("Cau", labeledData.get(2).getOne());
Assert.assertEquals("E_A", labeledData.get(2).getTwo());
Assert.assertEquals("Formalising", labeledData.get(3).getOne());
Assert.assertEquals("B_T", labeledData.get(3).getTwo());
Assert.assertEquals("development", labeledData.get(5).getOne());
Assert.assertEquals("I_T", labeledData.get(5).getTwo());
Assert.assertEquals("1992.", labeledData.get(13).getOne());
Assert.assertEquals("W_Y", labeledData.get(13).getTwo());
}
}
| 3,323 | 37.206897 | 206 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/CheckReferencesTest.java | package org.allenai.scienceparse;
import junit.framework.Assert;
import lombok.extern.slf4j.Slf4j;
import org.allenai.datastore.Datastore;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Arrays;
@Test
@Slf4j
public class CheckReferencesTest {
public void smallTest() throws IOException {
final String jsonFile =
Datastore.apply().filePath("org.allenai.scienceparse", "gazetteer.json", 5).toString();
CheckReferences cr = new CheckReferences(jsonFile);
log.info("num hashes: " + cr.getHashSize());
Assert.assertEquals(1557178, cr.getHashSize());
Assert.assertTrue(cr.hasPaper(
"Ecological Sampling of Gaze Shifts",
Arrays.asList("Giuseppe Boccignone",
"Mario Ferraro"), 2014, "KDD"));
Assert.assertTrue(cr.hasPaper(
"HIST: A Methodology for the Automatic Insertion of a Hierarchical Self Test",
Arrays.asList("Oliver F. Haberl",
"Thomas Kropf"), 1992, "KDD"));
Assert.assertFalse(cr.hasPaper(
"Fake paper titles: A case study in negative examples",
Arrays.asList("Kevin Bache",
"David Newman",
"Padhraic Smyth"), 2013, "KDD"));
Assert.assertFalse(cr.hasPaper(
"Text-based measures of document diversity",
Arrays.asList("Captain Bananas",
"David Newman",
"Padhraic Smyth"), 2013, "KDD"));
}
}
| 1,371 | 33.3 | 99 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/ExtractReferencesTest.java | package org.allenai.scienceparse;
import com.gs.collections.api.tuple.Pair;
import com.gs.collections.impl.tuple.Tuples;
import junit.framework.Assert;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.allenai.scienceparse.ExtractReferences.BibStractor;
import org.allenai.scienceparse.pdfapi.PDFDoc;
import org.allenai.scienceparse.pdfapi.PDFExtractor;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
@Test
@Slf4j
public class ExtractReferencesTest {
public String filePathOfResource(String path) {
return this.getClass().getResource(path).getFile();
}
public String resourceDirectory(String path) {
return (new File(this.getClass().getResource(path).getFile())).getParent();
}
public void testAuthorPattern() throws Exception {
String auth = ExtractReferences.authLastCommaInitial;
Assert.assertTrue(Pattern.matches(auth, "Jones, C. M."));
Assert.assertTrue(Pattern.matches(auth, "Hu, Y."));
Assert.assertTrue(Pattern.matches(
"(" + auth +
"(?:; " + auth + ")*)",
//"Jones, C. M.; Henry, E. R.; Hu, Y."));
"Jones, C. M.; Henry, E. R.; Hu, Y.; Chan, C. K.; Luck, S. D.; Bhuyan, A.; Roder, H.; Hofrichter, J."));
String auth2 = ExtractReferences.authInitialsLast;
String test2 = "S.H. Han";
Assert.assertTrue(Pattern.matches(auth2, test2));
String auth3 = ExtractReferences.authInitialsLastList + "\\.";
String test3 = "B.K. Shim, Y.K. Cho, J.B. Won, and S.H. Han.";
Assert.assertTrue(Pattern.matches(auth3, test3));
String test4 = "D. Kowalsky and A. Pelc,";
String auth4 = ExtractReferences.authInitialsLastList + ",";
Assert.assertTrue(Pattern.matches(auth4, test4));
String test5 = "E. Agichtein and L. Gravano.";
String auth5 = ExtractReferences.authInitialsLastList + "(?:,|\\.)";
Assert.assertTrue(Pattern.matches(auth5, test5));
String test6 = "E. Agichtein and L.";
String auth6 = ExtractReferences.authInitialsLastList + "(?:,|\\.)";
Assert.assertFalse(Pattern.matches(auth6, test6));
}
public void testAuthorStringToList() throws Exception {
{
final List<String> actual = ExtractReferences.authorStringToList("S Ruzickova, Z Cimburek, T Moravcova");
final List<String> expected = Arrays.asList("S Ruzickova", "Z Cimburek", "T Moravcova");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("Prokunina L, Castillejo-Lopez C, Oberg F, Gunnarsson I, Berg L, Magnusson V, et al.:");
final List<String> expected = Arrays.asList("L Prokunina", "C Castillejo-Lopez", "F Oberg", "I Gunnarsson", "L Berg", "V Magnusson");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("Traber D:");
final List<String> expected = Collections.singletonList("D Traber");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("L. J. van’t Veer, H. Dai, M. J. van de Vijver, S. H. Friend, and etc.");
final List<String> expected = Arrays.asList("L. J. van’t Veer", "H. Dai", "M. J. van de Vijver", "S. H. Friend");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("J. A. Blakeley, P.-Å Larson, and F. W. Tompa");
final List<String> expected = Arrays.asList("J. A. Blakeley", "P.-Å Larson", "F. W. Tompa");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("Sabine Shulte im Walde,");
final List<String> expected = Collections.singletonList("Sabine Shulte im Walde");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("Friedman, N., & Goldszmidt, M.");
final List<String> expected = Arrays.asList("N. Friedman", "M. Goldszmidt");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("Lieberman, H., Paterno, F., & Wulf, V.");
final List<String> expected = Arrays.asList("H. Lieberman", "F. Paterno", "V. Wulf");
Assert.assertEquals(expected, actual);
}
{
final List<String> actual = ExtractReferences.authorStringToList("K. Apt");
final List<String> expected = Collections.singletonList("K. Apt");
Assert.assertEquals(expected, actual);
}
}
public void testNumberDotAuthorNoTitleBibRecordParser() {
val f = new ExtractReferences.NumberDotAuthorNoTitleBibRecordParser();
String line = "1. Jones, C. M.; Henry, E. R.; Hu, Y.; Chan, C. K.; Luck S. D.; Bhuyan, A.; Roder, H.; Hofrichter, J.; "
+ "Eaton, W. A. Proc Natl Acad Sci USA 1993, 90, 11860.";
BibRecord br = f.parseRecord(line);
Assert.assertTrue(br != null);
Assert.assertEquals(br.year, 1993);
}
private Pair<List<String>, List<String>> parseDoc(final File file) throws IOException {
final PDDocument pdDoc;
try(final InputStream is = new FileInputStream(file)) {
pdDoc = PDDocument.load(is);
}
val ext = new PDFExtractor();
final PDFDoc doc = ext.extractResultFromPDDocument(pdDoc).document;
final List<String> raw = PDFDocToPartitionedText.getRaw(doc);
final List<String> rawReferences = PDFDocToPartitionedText.getRawReferences(doc);
return Tuples.pair(raw, rawReferences);
}
public void testCRFExtractor() throws Exception { //TODO: target crf correctness more specifically
ExtractReferences er = new ExtractReferences(
Parser.getDefaultGazetteer().toString(),
filePathOfResource("/model-bib-crf-test.dat"));
File paper2 = new File(filePathOfResource("/c0690a1d74ab781bd54f9fa7e67267cce656.pdf"));
final Pair<List<String>, List<String>> content = parseDoc(paper2);
final List<String> raw = content.getOne();
final List<String> rawReferences = content.getTwo();
final Pair<List<BibRecord>, BibStractor> fnd = er.findReferences(rawReferences);
final List<BibRecord> br = fnd.getOne();
final BibStractor bs = fnd.getTwo();
int j = 0;
for (BibRecord b : br)
log.info("reference " + (j++) + " " + (b == null ? "null" : b.toString()));
for (BibRecord b : br)
Assert.assertNotNull(b);
Assert.assertTrue(br.size() >= 15);
//commented to allow CRF to make accuracy errors:
// Assert.assertEquals(16, br.size());
// BibRecord tbr = br.get(15);
// Assert.assertEquals("DASD dancing: A disk load balancing optimization scheme for video-on-demand computer systems", tbr.title);
// Assert.assertEquals("Wolf et al\\.,? 1995", tbr.citeRegEx.pattern());
// Assert.assertEquals("J. Wolf", tbr.author.get(0));
// Assert.assertEquals("P. Yu", tbr.author.get(1));
// Assert.assertEquals("H. Shachnai", tbr.author.get(2));
// Assert.assertEquals(1995, tbr.year);
// log.info(br.get(0).venue.trim());
// Assert.assertTrue(br.get(0).venue.trim().startsWith("ACM SIGMOD Conference, "));
// final List<CitationRecord> crs = ExtractReferences.findCitations(raw, br, bs);
// log.info("found " + crs.size() + " citations.");
// CitationRecord cr = crs.get(crs.size() - 1);
// log.info(cr.toString());
// Assert.assertEquals("[Shachnai and Tamir 2000a]", cr.context.substring(cr.startOffset, cr.endOffset));
// log.info(cr.context);
// Assert.assertTrue(cr.context.startsWith("We have implemented"));
}
public void testFindReferencesAndCitations() throws Exception {
ExtractReferences er = new ExtractReferences(
Parser.getDefaultGazetteer().toString(),
filePathOfResource("/model-bib-crf-test.dat"));
File paper1 = new File(filePathOfResource("/2a774230b5328df3f8125da9b84a82d92b46a240.pdf"));
File paper2 = new File(filePathOfResource("/c0690a1d74ab781bd54f9fa7e67267cce656.pdf"));
File paper3 = new File(filePathOfResource("/e4faf2c1d76b9bf8f8b4524dfb8c5c6b93be5f35.pdf"));
//paper 1:
{
final Pair<List<String>, List<String>> content = parseDoc(paper1);
final List<String> lines = content.getOne();
final List<String> rawReferences = content.getTwo();
final Pair<List<BibRecord>, List<CitationRecord>> refsAndMentions =
Parser.getReferences(lines, rawReferences, er);
final List<BibRecord> br = refsAndMentions.getOne();
final List<CitationRecord> crs = refsAndMentions.getTwo();
int j = 0;
for (BibRecord b : br)
log.info("reference " + (j++) + " " + (b == null ? "null" : b.toString()));
for (BibRecord b : br)
Assert.assertNotNull(b);
//Assert.assertEquals(17, br.size()); // We miss one of the references in this paper, so this is disabled.
Assert.assertEquals("Scalable video data placement on parallel disk arrays", br.get(0).title);
Assert.assertEquals("1", br.get(0).citeRegEx.pattern());
Assert.assertEquals("E. Chang", br.get(0).author.get(0));
Assert.assertEquals("A. Zakhor", br.get(0).author.get(1));
Assert.assertEquals(1994, br.get(0).year);
Assert.assertTrue(br.get(0).venue.trim().startsWith("IS&T/SPIE Int. Symp. Electronic Imaging: Science and Technology, Volume 2185: Image and Video Databases II, San Jose, CA, Feb. 1994, pp. 208"));
//can't use below because dash is special:
// Assert.assertEquals("IS&T/SPIE Int. Symp. Electronic Imaging: Science and Technology, "
// + "Volume 2185: Image and Video Databases II, San Jose, CA, Feb. 1994, pp. 208–221.", br.get(0).venue.trim());
log.info("found " + crs.size() + " citations.");
Assert.assertEquals("[12]", crs.get(0).context.substring(crs.get(0).startOffset, crs.get(0).endOffset));
Assert.assertTrue(crs.get(0).context.startsWith("Keeton and Katz"));
}
//paper2:
{
final Pair<List<String>, List<String>> content = parseDoc(paper2);
final List<String> lines = content.getOne();
final List<String> rawReferences = content.getTwo();
final Pair<List<BibRecord>, List<CitationRecord>> refsAndMentions =
Parser.getReferences(lines, rawReferences, er);
final List<BibRecord> br = refsAndMentions.getOne();
final List<CitationRecord> crs = refsAndMentions.getTwo();
int j = 0;
for (BibRecord b : br)
log.info("reference " + (j++) + " " + (b == null ? "null" : b.toString()));
for (BibRecord b : br)
Assert.assertNotNull(b);
Assert.assertEquals(16, br.size());
BibRecord tbr = br.get(15);
Assert.assertEquals("DASD dancing: A disk load balancing optimization scheme for video-on-demand computer systems", tbr.title);
Assert.assertEquals("Wolf et al\\.,? 1995", tbr.citeRegEx.pattern());
Assert.assertEquals("J. Wolf", tbr.author.get(0));
Assert.assertEquals("P. Yu", tbr.author.get(1));
Assert.assertEquals("H. Shachnai", tbr.author.get(2));
Assert.assertEquals(1995, tbr.year);
log.info(br.get(0).venue.trim());
Assert.assertTrue(br.get(0).venue.trim().startsWith("ACM SIGMOD Conference, "));
log.info("found " + crs.size() + " citations.");
CitationRecord cr = crs.get(crs.size() - 1);
log.info(cr.toString());
Assert.assertEquals("[Shachnai and Tamir 2000a]", cr.context.substring(cr.startOffset, cr.endOffset));
log.info(cr.context);
Assert.assertTrue(cr.context.startsWith("We have implemented"));
}
// paper3:
{
final Pair<List<String>, List<String>> content = parseDoc(paper3);
final List<String> lines = content.getOne();
final List<String> rawReferences = content.getTwo();
final Pair<List<BibRecord>, List<CitationRecord>> refsAndMentions =
Parser.getReferences(lines, rawReferences, er);
final List<BibRecord> br = refsAndMentions.getOne();
final List<CitationRecord> crs = refsAndMentions.getTwo();
int j = 0;
for (BibRecord b : br)
log.info("reference " + (j++) + " " + (b == null ? "null" : b.toString()));
for (BibRecord b : br)
Assert.assertNotNull(b);
Assert.assertEquals(58, br.size());
BibRecord tbr = br.get(56);
Assert.assertEquals("Protection against heat stress-induced oxidative damage in Arabidopsis involves calcium, abscisic acid, ethylene, and salicylic acid", tbr.title);
Assert.assertEquals("58", tbr.citeRegEx.pattern());
Assert.assertEquals("J Larkindale", tbr.author.get(0));
Assert.assertEquals("M. Knight", tbr.author.get(1));
Assert.assertEquals(2002, tbr.year);
log.info(tbr.venue.trim());
Assert.assertEquals("Plant Physiol", tbr.venue.trim());
log.info("found " + crs.size() + " citations.");
CitationRecord cr = crs.get(crs.size() - 1);
log.info(cr.toString());
Assert.assertEquals("[58; 59]", cr.context.substring(cr.startOffset, cr.endOffset));
log.info(cr.context);
Assert.assertTrue(cr.context.startsWith("Alpha-aminoadipate and pipecolate had relatively strong negative correlations with yield and physiological parameters"));
}
}
}
| 13,420 | 45.600694 | 203 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/GazetteerFeaturesTest.java | package org.allenai.scienceparse;
import java.util.Arrays;
import java.util.List;
import org.testng.annotations.Test;
import junit.framework.Assert;
import lombok.val;
import lombok.extern.slf4j.Slf4j;
@Test
@Slf4j
public class GazetteerFeaturesTest {
public String filePathOfResource(String path) {
return this.getClass().getResource(path).getFile();
}
public void testLength() {
Assert.assertTrue(GazetteerFeatures.withinLength("this string is only six words."));
Assert.assertFalse(GazetteerFeatures.withinLength("this string by contrast is eight words long."));
}
public void testGazetteers() throws Exception {
GazetteerFeatures gf = new GazetteerFeatures(filePathOfResource("/gazetteer-test/"));
int namesId = gf.gazetteerNumber("names.male.txt");
int univId = gf.gazetteerNumber("education.university.small.txt");
Assert.assertEquals(gf.size(), 2);
Assert.assertEquals(3, gf.sizeOfSet(univId));
Assert.assertEquals(5, gf.sizeOfSet(namesId));
boolean [] abbeyInSet = gf.inSet("Abbey");
Assert.assertEquals(2, abbeyInSet.length);
Assert.assertFalse(abbeyInSet[univId]);
Assert.assertTrue(abbeyInSet[namesId]);
boolean [] beautyInSet = gf.inSet("marinello school of beauty");
Assert.assertEquals(2, beautyInSet.length);
Assert.assertTrue(beautyInSet[univId]);
Assert.assertFalse(beautyInSet[namesId]);
boolean [] wilkinsInSet = gf.inSet("d. wilkins school of windmill dunks");
Assert.assertEquals(2, wilkinsInSet.length);
Assert.assertFalse(wilkinsInSet[univId]);
Assert.assertFalse(wilkinsInSet[namesId]);
boolean [] apolloInSet = gf.inSet("Apollo College Phoenix Inc.");
Assert.assertTrue(apolloInSet[univId]);
}
public void testGazetteerFeatures() throws Exception {
List<String> elems = Arrays.asList("Abbey", "is", "at", "Apollo", "College", "Phoenix", "Inc.");
ReferencesPredicateExtractor rpe = new ReferencesPredicateExtractor();
GazetteerFeatures gf = new GazetteerFeatures(filePathOfResource("/gazetteer-test/"));
val spns = gf.getSpans(elems);
log.info(spns.toString());
Assert.assertEquals(2, spns.size());
rpe.setGf(gf);
val preds = rpe.nodePredicates(elems);
log.info(preds.toString());
Assert.assertEquals(1.0, preds.get(0).get("%gaz_W_names.male.txt"));
Assert.assertFalse(preds.get(2).containsKey("%gaz_B_education.university.small.txt"));
Assert.assertEquals(1.0, preds.get(3).get("%gaz_B_education.university.small.txt"));
Assert.assertEquals(1.0, preds.get(4).get("%gaz_I_education.university.small.txt"));
Assert.assertEquals(1.0, preds.get(6).get("%gaz_E_education.university.small.txt"));
}
}
| 2,718 | 38.405797 | 103 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/HeaderIntegrationTest.java | package org.allenai.scienceparse;
import junit.framework.Assert;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.pdfbox.io.IOUtils;
import org.testng.annotations.Test;
import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class HeaderIntegrationTest {
private final static PaperSource paperSource = PaperSource.getDefault();
static final int kSampledPapers = 100;
public static class Result {
int authorHits;
int authorInvalid;
boolean titleMatch;
String title;
int totalAuthors;
boolean titleMissing;
}
public static HashSet<String> authorSet(Iterable<String> authors) {
HashSet<String> result = new HashSet<String>();
for (String author : authors) {
result.add(Parser.lastName(author));
}
return result;
}
public static Result testPaper(
final Parser parser,
final ParserGroundTruth pgt,
final String paperId
) {
ExtractedMetadata metadata;
ParserGroundTruth.Paper paper = pgt.forKey(paperId.substring(4));
try {
metadata = parser.doParse(
paperSource.getPdf(paperId),
Parser.MAXHEADERWORDS);
} catch (Exception e) {
log.info("Failed to parse or extract from {}. Skipping.", paper.url);
return null;
}
HashSet<String> golden = authorSet(Arrays.asList(paper.authors));
HashSet<String> extracted = authorSet(metadata.authors);
int hits = 0;
int invalid = 0;
for (String name : golden) {
if (extracted.contains(name)) {
hits += 1;
}
}
for (String name : extracted) {
if (!golden.contains(name)) {
log.info("Bad author {}: {} ", name,
String.join(",", golden.toArray(new String[]{}))
);
invalid += 1;
}
}
Result res = new Result();
res.totalAuthors = golden.size();
res.authorHits = hits;
res.authorInvalid = invalid;
res.title = paper.title;
if (metadata.title == null) {
res.titleMatch = false;
res.titleMissing = true;
} else {
res.titleMatch = Parser.processTitle(paper.title)
.equals(Parser.processTitle(metadata.title));
}
if (res.authorInvalid > 0 || !res.titleMatch) {
metadata.authors.sort((String a, String b) -> a.compareTo(b));
Arrays.sort(paper.authors);
log.info("Failed match for paper {}.", paperId);
log.info("Titles: GOLD:\n{} OURS:\n{}", paper.title, metadata.title);
for (int i = 0; i < Math.max(paper.authors.length, metadata.authors.size()); ++i) {
String goldAuthor = null;
String metaAuthor = null;
if (i < paper.authors.length) { goldAuthor = paper.authors[i]; }
if (i < metadata.authors.size()) { metaAuthor = metadata.authors.get(i); }
log.info("Author: ({}) ({})", goldAuthor, metaAuthor);
}
}
return res;
}
public void testAuthorAndTitleExtraction() throws Exception {
ParserGroundTruth pgt = new ParserGroundTruth(
Files.newInputStream(Parser.getDefaultGazetteer()));
// TODO (build and train a classifier at test time).
// Parser parser = trainParser(pgt);
Parser parser = new Parser();
ArrayList<ParserGroundTruth.Paper> sampledPapers = new ArrayList<>();
for (int i = 0; i < pgt.papers.size(); i += pgt.papers.size() / kSampledPapers) {
sampledPapers.add(pgt.papers.get(i));
}
long startTime = System.currentTimeMillis();
ArrayList<Result> results = sampledPapers
.stream()
.parallel()
.map(p -> testPaper(parser, pgt, p.id))
.filter(f -> f != null)
.collect(Collectors.toCollection(ArrayList::new));
// Gahh I wish I had a dataframe library...
int totalHits = 0, totalInvalid = 0, totalAuthors = 0, titleMatches = 0, titleMissing = 0;
for (Result res : results) {
totalHits += res.authorHits;
totalInvalid += res.authorInvalid;
totalAuthors += res.totalAuthors;
if (res.titleMatch) {
titleMatches += 1;
}
if (res.titleMissing) {
titleMissing += 1;
}
}
long finishTime = System.currentTimeMillis();
double elapsed = (finishTime - startTime) / 1000.0;
log.info("Testing complete. {} papers processed in {} seconds; {} papers/sec ",
results.size(), elapsed, results.size() / elapsed);
Assert.assertTrue(results.size() > 5);
log.info("Authors: {} (Match: {} Invalid: {} Total {})",
totalHits / (double)totalAuthors, totalHits, totalInvalid, totalAuthors);
log.info("Titles: {} (Match: {} Missing: {} Total {})",
titleMatches / (double)results.size(), titleMatches, titleMissing, results.size());
}
}
| 5,370 | 33.651613 | 99 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/PDFPredicateExtractorTest.java | package org.allenai.scienceparse;
import com.gs.collections.api.map.primitive.ObjectDoubleMap;
import com.gs.collections.api.tuple.Pair;
import lombok.extern.slf4j.Slf4j;
import org.allenai.scienceparse.pdfapi.PDFDoc;
import org.allenai.scienceparse.pdfapi.PDFExtractor;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@Slf4j
public class PDFPredicateExtractorTest {
private void titleFontFeatureCheckForStream(InputStream pdfInputStream) throws IOException {
String target = "How to make words with vectors: Phrase generation in distributional semantics";
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
List<PaperToken> pts = PDFToCRFInput.getSequence(doc);
// Iterator<PaperToken> it = pts.iterator();
// while(it.hasNext()) {
// PaperToken pt = it.next();
// log.info((pt.getPdfToken()==null)?"null":pt.getPdfToken().token + " f:" + pt.getPdfToken().fontMetrics.ptSize);
// }
Pair<Integer, Integer> pos = PDFToCRFInput.findString(PDFToCRFInput.asStringList(pts), target);
PDFPredicateExtractor ppe = new PDFPredicateExtractor();
List<ObjectDoubleMap<String>> preds = ppe.nodePredicates(pts);
int[] idxes = new int[]{pos.getOne() - 1, pos.getOne(),
pos.getTwo(), pos.getTwo() + 1, pos.getTwo() + 2};
log.info("fonts for " + Arrays.toString(idxes));
log.info(Arrays.toString(Arrays.stream(idxes).mapToDouble((int a) -> preds.get(a).get("%font")).toArray()));
log.info("tokens for " + Arrays.toString(idxes));
log.info(Arrays.toString(Arrays.stream(idxes).mapToObj((int a) -> pts.get(a).getPdfToken().token).toArray()));
Assert.assertEquals(preds.get(pos.getOne()).get("%fcb"), 1.0);
Assert.assertTrue(!preds.get(pos.getTwo() - 1).containsKey("%fcb"));
log.info("Title font change features correct.");
}
@Test
public void titleFontFeatureCheck() throws IOException {
InputStream is = PDFPredicateExtractorTest.class.getResource("/P14-1059.pdf").openStream();
titleFontFeatureCheckForStream(is);
is.close();
}
public void titleFontForExplicitFilePath(String f) throws IOException {
InputStream is = new FileInputStream(new File(f));
titleFontFeatureCheckForStream(is);
is.close();
}
@Test
public void testCaseMasks() {
String cap = "Exploring";
List<String> ls = PDFPredicateExtractor.getCaseMasks(cap);
Assert.assertEquals(ls.size(), 2);
Assert.assertTrue(ls.contains("%Xxx"));
Assert.assertTrue(ls.contains("%letters"));
String nonSimple = "Dharmaratnå";
ls = PDFPredicateExtractor.getCaseMasks(nonSimple);
Assert.assertTrue(ls.contains("%hasNonAscii"));
Assert.assertTrue(!ls.contains("%hasAt"));
String email = "[email protected]";
ls = PDFPredicateExtractor.getCaseMasks(email);
Assert.assertTrue(ls.contains("%hasAt"));
}
public static void main(String [] args) throws Exception {
(new PDFPredicateExtractorTest()).titleFontForExplicitFilePath("src\\test\\resources\\P14-1059.pdf");
}
}
| 3,199 | 37.554217 | 119 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/PDFToCRFInputTest.java | package org.allenai.scienceparse;
import com.gs.collections.api.tuple.Pair;
import com.gs.collections.impl.tuple.Tuples;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.allenai.scienceparse.pdfapi.PDFDoc;
import org.allenai.scienceparse.pdfapi.PDFExtractor;
import org.testng.Assert;
import org.testng.annotations.Test;
import scala.Option;
import scala.Some;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Date;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Test
@Slf4j
public class PDFToCRFInputTest {
public String filePathOfResource(String path) {
return this.getClass().getResource(path).getFile();
}
public void testGetPaperTokens() throws IOException {
InputStream pdfInputStream = PDFToCRFInputTest.class.getResourceAsStream("/P14-1059.pdf");
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
List<PaperToken> pts = PDFToCRFInput.getSequence(doc);
log.info("got " + pts.size() + " things.");
assert (pts.size() > 50);
}
public void testFindString() throws IOException {
String target = "How to make words with vectors: Phrase generation in distributional semantics";
InputStream pdfInputStream = PDFToCRFInputTest.class.getResourceAsStream("/P14-1059.pdf");
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
List<PaperToken> pts = PDFToCRFInput.getSequence(doc);
Pair<Integer, Integer> pos = PDFToCRFInput.findString(PDFToCRFInput.asStringList(pts), target);
Pair<Integer, Integer> posNot = PDFToCRFInput.findString(PDFToCRFInput.asStringList(pts), "this string won't be found");
Assert.assertTrue(pos != null);
Assert.assertTrue(pos.getOne() > 0 && (pos.getTwo() - pos.getOne() == 11));
log.info("found title at " + pos.getOne() + ", " + pos.getTwo());
log.info("title is " + PDFToCRFInput.stringAt(pts, pos));
Assert.assertTrue(posNot == null);
}
public void testLabelMetadata() throws IOException {
InputStream pdfInputStream = PDFToCRFInputTest.class.getResourceAsStream("/P14-1059.pdf");
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
List<PaperToken> pts = PDFToCRFInput.getSequence(doc);
final ExtractedMetadata em = new ExtractedMetadata(
"How to make words with vectors: Phrase generation in distributional semantics",
Arrays.asList("Georgiana Dinu", "Marco Baroni"),
new Date(1388556000000L));
val labeledData = LabeledData$.MODULE$.fromExtractedMetadata("dummyid", em);
val result = PDFToCRFInput.labelMetadata("P14-1059", pts, labeledData);
log.info(PDFToCRFInput.getLabelString(result));
log.info(pts.stream().map((PaperToken p) -> p.getPdfToken().token).collect(Collectors.toList()).toString());
Assert.assertEquals(result.get(26).getTwo(), "O");
Assert.assertEquals(result.get(27).getTwo(), "B_T");
Assert.assertEquals(result.get(34).getTwo(), "I_T");
Assert.assertEquals(result.get(37).getTwo(), "E_T");
Assert.assertEquals(result.get(38).getTwo(), "B_A");
Assert.assertEquals(result.get(47).getTwo(), "O");
Assert.assertEquals(result.get(47).getOne(), pts.get(46)); //off by one due to start/stop
Assert.assertEquals(result.get(0).getTwo(), "<S>");
Assert.assertEquals(result.get(result.size() - 1).getTwo(), "</S>");
}
public void testGetSpans() {
List<String> ls = Arrays.asList("O", "O", "B_A", "I_A", "E_A");
val spans = ExtractedMetadata.getSpans(ls);
Assert.assertEquals(spans.size(), 1);
Assert.assertEquals(spans.get(0).tag, "A");
Assert.assertEquals(spans.get(0).loc, Tuples.pair(2, 5));
}
public void testAuthorPatterns() {
List<Pair<Pattern, Boolean>> authOpt = PDFToCRFInput.authorToPatternOptPair("Marco C. Baroni");
Assert.assertTrue(authOpt.get(0).getOne().matcher("Marco").matches());
Assert.assertTrue(authOpt.get(1).getOne().matcher("C").matches());
Assert.assertTrue(authOpt.get(2).getOne().matcher("Baroni").matches());
Pair<Integer, Integer> span = PDFToCRFInput.findPatternSequence(Arrays.asList("Marco", "C", "Baroni"), authOpt);
Assert.assertEquals(span, Tuples.pair(0, 3));
span = PDFToCRFInput.findPatternSequence(Arrays.asList("Marco", "Baroni"), authOpt);
Assert.assertEquals(span, Tuples.pair(0, 2));
authOpt = PDFToCRFInput.authorToPatternOptPair("Marco Baroni");
span = PDFToCRFInput.findPatternSequence(Arrays.asList("M.", "G.", "Baroni"), authOpt);
Assert.assertEquals(span, Tuples.pair(0, 3));
span = PDFToCRFInput.findPatternSequence(Arrays.asList("M.", "G.", "B."), authOpt);
Assert.assertEquals(span, null);
}
public void testAuthor() throws IOException {
InputStream pdfInputStream = PDFToCRFInputTest.class.getResourceAsStream("/P14-1059.pdf");
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
List<PaperToken> pts = PDFToCRFInput.getSequence(doc);
final ExtractedMetadata em = new ExtractedMetadata(
"How to make words with vectors: Phrase generation in distributional semantics",
Arrays.asList("Georgiana Dinu", "Marco C. Baroni"),
new Date(1388556000000L));
val labeledData = LabeledData$.MODULE$.fromExtractedMetadata("dummyid", em);
val result = PDFToCRFInput.labelMetadata("P14-1059", pts, labeledData);
Assert.assertEquals(result.get(38).getTwo(), "B_A");
Assert.assertEquals(result.get(39).getTwo(), "E_A");
Assert.assertEquals(result.get(41).getTwo(), "B_A");
Assert.assertEquals(result.get(42).getTwo(), "E_A");
}
}
| 5,629 | 47.534483 | 124 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/ParserLMFeaturesTest.java | package org.allenai.scienceparse;
import com.gs.collections.impl.set.mutable.UnifiedSet;
import junit.framework.Assert;
import lombok.extern.slf4j.Slf4j;
import org.testng.annotations.Test;
import java.io.File;
@Test
@Slf4j
public class ParserLMFeaturesTest {
public String filePathOfResource(String path) {
return this.getClass().getResource(path).getFile();
}
public void testParserLMFeatures() throws Exception {
File f = new File(filePathOfResource("/groundTruth.json"));
ParserGroundTruth pgt = new ParserGroundTruth(f.getPath());
log.info("pgt 0: " + pgt.papers.get(0));
ParserLMFeatures plf = new ParserLMFeatures(pgt.papers, new UnifiedSet<String>(), f.getParentFile(), 3);
log.info("of count in background: " + plf.backgroundBow.get("of"));
Assert.assertEquals(1.0, plf.authorBow.get("Seebode"));
Assert.assertEquals(1.0, plf.titleBow.get("Disk-based"));
Assert.assertTrue(plf.backgroundBow.get("of") > 2.0);
}
}
| 972 | 31.433333 | 108 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/ParserTest.java | package org.allenai.scienceparse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gs.collections.api.tuple.Pair;
import com.gs.collections.impl.tuple.Tuples;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.testng.Assert;
import org.testng.annotations.Test;
import scala.Function0;
import scala.Option;
import scala.collection.JavaConverters;
import scala.runtime.AbstractFunction0;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
@Test
@Slf4j
public class ParserTest {
private final static List<String> pdfKeys = Arrays.asList("/bagnell11", "/seung08", "/ding11", "/mooney05",
"/roark13", "/dyer12", "/bohnet09", "/P14-1059", "/map-reduce", "/fader11", "/proto06",
"/agarwal11", "/smola10", "/senellart10", "/zolotov04", "/pedersen04", "/smith07",
"/aimag10");
public static String filePathOfResource(String path) {
return ParserTest.class.getResource(path).getFile();
}
public static String resourceDirectory(String path) {
return (new File(ParserTest.class.getResource(path).getFile())).getParent();
}
public static InputStream inputStreamOfResource(String path) throws Exception {
return new FileInputStream(new File(filePathOfResource(path)));
}
private List<File> resolveKeys(List<String> keys) {
return keys.stream().map((String s) -> new File(filePathOfResource(s + ".pdf"))).collect(Collectors.toList());
}
private Pair<Double, Double> testModel(String id, Parser p) throws Exception {
String jsonPath = id + ".extraction.json";
String pdfPath = id + ".pdf";
InputStream jsonInputStream = getClass().getResourceAsStream(jsonPath);
InputStream pdfInputStream = getClass().getResourceAsStream(pdfPath);
List<List<?>> arr = new ObjectMapper().readValue(jsonInputStream, List.class);
jsonInputStream.close();
ExtractedMetadata em = p.doParse(pdfInputStream, Parser.MAXHEADERWORDS);
pdfInputStream.close();
double titleTP = 0.0;
double titleFP = 0.0;
double authorTP = 0.0;
double authorFN = 0.0;
for (List<?> elems : arr) {
String type = (String) elems.get(0);
Object expectedValue = elems.get(1);
if (type.equalsIgnoreCase("title")) {
String guessValue = em.title;
if (guessValue != null && guessValue.equals(expectedValue))
titleTP++;
else
titleFP++;
//Assert.assertEquals(guessValue, expectedValue, String.format("Title error on %s", id));
}
if (type.equalsIgnoreCase("author")) {
if (em.authors.contains(expectedValue))
authorTP++;
else
authorFN++;
//Assert.assertTrue(em.authors.contains(expectedValue),
//"could not find author " + expectedValue + " in extracted authors " + em.authors.toString());
}
// if (type.equalsIgnoreCase("year")) {
// Assert.assertEquals(em.year, expectedValue, String.format("Year error on %s", id));
// }
}
return Tuples.pair((titleTP / (titleTP + titleFP + 0.000001)), authorTP / (authorTP + authorFN + 0.000001));
}
public void testParserWithGroundTruth() throws Exception {
final File testModelFile = File.createTempFile("science-parse-test-model.", ".dat");
testModelFile.deleteOnExit();
/*
* We'll use this to override the default paper source which pulls from S2. The problem with
* pulling from S2 is that the set of publicly available PDFs changes over time making this
* test rather flappy.
*/
PaperSource previousSource = PaperSource.defaultPaperSource;
PaperSource.defaultPaperSource = new DirectoryPaperSource(
new File(resourceDirectory("/groundTruth.json")));
try {
Parser.ParseOpts opts = new Parser.ParseOpts();
opts.iterations = 10;
opts.threads = 4;
opts.modelFile = testModelFile.getPath();
opts.headerMax = Parser.MAXHEADERWORDS;
opts.backgroundSamples = 3;
opts.gazetteerFile = null;
opts.trainFraction = 0.9;
opts.backgroundDirectory = resourceDirectory("/groundTruth.json");
opts.minYear = -1;
opts.checkAuthors = false;
File f = new File(opts.modelFile);
f.deleteOnExit();
final Iterator<LabeledPaper> labeledTrainingData =
JavaConverters.asJavaIteratorConverter(
LabeledPapersFromDBLP.getFromGroundTruth(
Paths.get(filePathOfResource("/groundTruth.json")))).asJava();
Parser.trainParser(labeledTrainingData, opts);
final Parser p = new Parser(
testModelFile,
Parser.getDefaultGazetteer().toFile(),
Parser.getDefaultBibModel().toFile());
double avgTitlePrec = 0.0;
double avgAuthorRec = 0.0;
double cases = 0.0;
for (String s : pdfKeys) {
val res = testModel(s, p);
cases++;
avgTitlePrec += res.getOne();
avgAuthorRec += res.getTwo();
}
avgTitlePrec /= cases;
avgAuthorRec /= cases;
log.info("Title precision = recall = " + avgTitlePrec);
log.info("Author recall = " + avgAuthorRec);
testModelFile.delete();
} finally {
PaperSource.defaultPaperSource = previousSource;
}
}
public void testParserGroundTruth() throws Exception {
ParserGroundTruth pgt = new ParserGroundTruth(filePathOfResource("/groundTruth.json"));
Assert.assertEquals(pgt.papers.size(), 4);
}
public void testParserRobustness() throws Exception {
// ParserGroundTruth pgt = new ParserGroundTruth(filePathOfResource("/papers-parseBugs.json"));
// Assert.assertEquals(false, true);
}
}
| 5,851 | 35.805031 | 114 | java |
science-parse | science-parse-master/core/src/test/java/org/allenai/scienceparse/pdfapi/PDFExtractorTest.java | package org.allenai.scienceparse.pdfapi;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.text.Normalizer;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
public class
PDFExtractorTest {
private final static List<String> pdfKeys = Arrays.asList("/bagnell11", "/seung08", "/ding11", "/mooney05",
"/roark13", "/dyer12", "/bohnet09", "/P14-1059", "/map-reduce", "/fader11", "/proto06",
"/agarwal11", "/smola10", "/senellart10", "/zolotov04", "/pedersen04", "/smith07",
"/aimag10");
private static String processTitle(String t) {
// case fold and remove lead/trail space
t = t.trim().toLowerCase();
// strip accents and unicode changes
t = Normalizer.normalize(t, Normalizer.Form.NFKD);
// kill non-character letters
// kill xml
t = t.replaceAll("\\&.*?\\;", "");
// kill non-letter chars
//t = t.replaceAll("\\W","");
return t.replaceAll("\\s+", " ");
}
@SneakyThrows
public static void main(String[] args) {
// args[0] should be directory with eval PDFs
File dir = new File(args[0]);
// args[1] should be src/test/resources/id-titles.txt
// tab-separared: content-sha, expected title
BufferedReader keyReader = new BufferedReader(new FileReader(args[1]));
Iterator<String> keyIt = keyReader.lines().iterator();
int tp = 0;
int fp = 0;
int fn = 0;
int numEvents = 0;
while (keyIt.hasNext()) {
String line = keyIt.next();
String[] fields = line.split("\\t");
String key = fields[0];
String expectedTitle = fields[1];
File pdfFile = new File(dir, key + ".pdf");
// This PDF isn't part of evaluation PDFs
if (!pdfFile.exists()) {
continue;
}
// We know we need to evaluate on this
numEvents++;
PDFExtractor.Options opts = PDFExtractor.Options.builder().useHeuristicTitle(false).build();
PDFDoc doc = new PDFExtractor(opts).extractFromInputStream(new FileInputStream(pdfFile));
if (doc == null) {
fn++;
continue;
}
String guessTitle = doc.getMeta().getTitle();
if (guessTitle == null) {
// Didn't guess but there is an answer
fn++;
continue;
}
String guessTitleCollapsed = processTitle(guessTitle);
String expectedTitleCollapsed = processTitle(expectedTitle);
boolean equiv = expectedTitleCollapsed.equals(guessTitleCollapsed);
if (equiv) {
// we guessed and guess correctly
tp++;
} else {
// we guessed and guess incorrectly
fp++;
}
if (!equiv) {
System.out.println("pdf: " + pdfFile.getName());
System.out.println("expectedTitle: " + expectedTitle);
System.out.println("guessTitle: " + guessTitle);
System.out.println("");
PDFExtractor extractor = new PDFExtractor(opts);
extractor.DEBUG = true;
extractor.extractFromInputStream(new FileInputStream(pdfFile));
}
}
double precision = tp / ((double) (tp + fp));
double recall = tp / ((double) (tp + fn));
int guessNumEvents = tp + fp + fn;
System.out.println("");
System.out.println("Num events known, guessed: " + numEvents + ", " + guessNumEvents);
System.out.println("Precision: " + precision);
System.out.println("Recall: " + recall);
double f1 = 2 * precision * recall / (precision + recall);
System.out.println("F1: " + f1);
}
@Test
private void testCoordinates() {
String pdfPath = "/coordinate_calibrator.pdf";
InputStream pdfInputStream = getClass().getResourceAsStream(pdfPath);
PDFExtractor.Options opts = PDFExtractor.Options.builder().useHeuristicTitle(true).build();
PDFDoc doc = new PDFExtractor(opts).extractFromInputStream(pdfInputStream);
for(PDFPage p : doc.pages) {
for(PDFLine l : p.lines) {
for(PDFToken t : l.tokens) {
Assert.assertEquals(t.token, "M"); //should be in upper-left:
System.out.println("bounds x0: " + t.bounds.get(0) + " y0: " + t.bounds.get(1));
Assert.assertTrue(t.bounds.get(0) < 0.1);
Assert.assertTrue(t.bounds.get(1) < 0.1);
}
}
}
}
@SneakyThrows
private void testPDF(String id) {
String jsonPath = id + ".extraction.json";
String pdfPath = id + ".pdf";
InputStream jsonInputStream = getClass().getResourceAsStream(jsonPath);
InputStream pdfInputStream = getClass().getResourceAsStream(pdfPath);
PDFExtractor.Options opts = PDFExtractor.Options.builder().useHeuristicTitle(true).build();
PDFDoc doc = new PDFExtractor(opts).extractFromInputStream(pdfInputStream);
List<List<?>> arr = new ObjectMapper().readValue(jsonInputStream, List.class);
for (List<?> elems : arr) {
String type = (String) elems.get(0);
Object expectedValue = elems.get(1);
if (type.equalsIgnoreCase("title")) {
String guessValue = doc.getMeta().getTitle();
Assert.assertEquals(guessValue==null?"":guessValue.trim(), expectedValue, String.format("Title error on %s", id));
}
if (type.equalsIgnoreCase("line")) {
List<PDFLine> lines = doc.getPages().stream().flatMap(x -> x.getLines().stream()).collect(Collectors.toList());
boolean matchedLine = lines.stream().anyMatch(l -> l.lineText().equals(expectedValue));
Assert.assertTrue(matchedLine, String.format("Line-match error on %s for line: %s", id, expectedValue));
}
if (type.equalsIgnoreCase("year")) {
Calendar cal = Calendar.getInstance();
cal.setTime(doc.getMeta().getCreateDate());
int year = cal.get(Calendar.YEAR);
Assert.assertEquals(year, expectedValue, String.format("Year error on %s", id));
}
}
}
@Test
public void testPDFExtraction() throws Exception {
pdfKeys.forEach(this::testPDF);
}
@Test
public void testSuperscript() throws Exception {
String pdfPath = "/superscripttest.pdf";
InputStream pdfInputStream = getClass().getResourceAsStream(pdfPath);
PDFExtractor.Options opts = PDFExtractor.Options.builder().useHeuristicTitle(true).build();
PDFDoc doc = new PDFExtractor(opts).extractFromInputStream(pdfInputStream);
doc = doc.withoutSuperscripts();
for(PDFPage p : doc.pages) {
for(PDFLine l : p.lines) {
for(PDFToken t : l.tokens) {
if(t.token.startsWith("SHEIKHAHMADI"))
Assert.assertEquals(t.token, "SHEIKHAHMADI,");
if(t.token.startsWith("(CN")) {
Assert.assertEquals(t.token, "(CN)");
break;
}
}
}
}
}
public void testPDFBenchmark() throws Exception {
long numTitleBytes = 0L;
for (int idx = 0; idx < 10; ++idx) {
for (String pdfKey : pdfKeys) {
InputStream pdfInputStream = PDFExtractorTest.class.getResourceAsStream(pdfKey + ".pdf");
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
numTitleBytes += doc.getMeta().hashCode();
}
}
long start = System.currentTimeMillis();
long testNum = 0L;
for (int idx = 0; idx < 10; ++idx) {
for (String pdfKey : pdfKeys) {
InputStream pdfInputStream = PDFExtractorTest.class.getResourceAsStream(pdfKey + ".pdf");
PDFDoc doc = new PDFExtractor().extractFromInputStream(pdfInputStream);
numTitleBytes += doc.getMeta().hashCode();
testNum++;
}
}
long stop = System.currentTimeMillis();
int numPasses = pdfKeys.size() * 20;
log.info("Time {} on {}, avg: {}ms\n", stop - start, numPasses, (stop - start) / testNum);
log.info("Just to ensure no compiler tricks: " + numTitleBytes);
}
}
| 8,036 | 37.090047 | 122 | java |
Pottslab | Pottslab-master/Java/src/pottslab/IndexedLinkedHistogram.java | package pottslab;
import java.util.ArrayList;
/**
* @author martinstorath
*
*/
public class IndexedLinkedHistogram {
ArrayList<HistNode> originalOrder; // stores the nodes in order of the incoming insertions
double[] weights; // stores all weights
HistNode first, last, median; // list pointers
HistNode firstTemp, lastTemp; // temporary list pointers
double totalDeviation; // stores the deviation from the median
double weightAboveMedian, weightBelowMedian;
double totalWeight;
public double[] currentMedians;
/**
* Constructor
* @param initialSize
* the expected list size
*/
public IndexedLinkedHistogram(double[] weights) {
// initialize the array which indexes the nodes in their original order
originalOrder = new ArrayList<HistNode>(weights.length);
// init weights
this.weights = weights;
}
/**
* Node inner class
*/
class HistNode {
// the value
double value;
double weight, weightTemp;
int count, countTemp;
// pointer to the next and previous elements
HistNode next, prev;
// temporary pointers to the next and previous elements
HistNode nextTemp, prevTemp;
/**
* Node constructor
* @param element
*/
HistNode(double element, double weight) {
this.value = element;
this.weight = weight;
this.count = 1;
}
void addWeight(double weight) {
this.weight += weight;
count++;
}
void removeWeightTemp(double weight) {
this.weightTemp -= weight;
countTemp--;
if (countTemp < 0) {
throw new RuntimeException("Error in List.");
}
if (weightTemp < 0) {
weightTemp = 0;
}
}
/**
* Reset all temporary values to the non-temporary ones
*/
void resetTemp() {
nextTemp = next;
prevTemp = prev;
weightTemp = weight;
countTemp = count;
}
}
/**
* inserts an element sorted by value in ascending order from first to last
*/
public void insertSorted(double elem) {
double weight = weights[this.size()];
HistNode pivot = null;
HistNode iterator = null;
if (first == null) { // empty list
pivot = new HistNode(elem, weight);
first = pivot;
last = first;
median = first;
totalDeviation = 0;
weightAboveMedian = 0;
weightBelowMedian = 0;
totalWeight = weight;
} else { // non-empty list
iterator = first;
while (iterator != null) {
if (iterator.value >= elem) {
break;
}
iterator.resetTemp();
iterator = iterator.next;
}
// insert node at right place or add weight to existing node
if (iterator != null) {
if (iterator.value == elem) {
pivot = iterator;
pivot.addWeight(weight);
} else {
pivot = new HistNode(elem, weight);
insertBefore(iterator, pivot);
}
} else {
pivot = new HistNode(elem, weight);
insertAfter(last, pivot);
}
// continue loop to reset temporary pointers
while (iterator != null) {
iterator.resetTemp();
iterator = iterator.next;
}
// add weight to total weight
totalWeight += weight;
}
// add the pivot node to the original order (allows removeTemp in O(1)!)
originalOrder.add(pivot);
// reset temporary first and last
/* OBSOLETE: leads to loss of significance
// update weights
if (elem > median.value) {
weightAboveMedian += weight;
} else if (elem < median.value) {
weightBelowMedian += weight;
}
shifting median and updating deviations
totalDeviation += Math.abs(median.value - elem) * weight; // new element increases deviation
double oldMedian = median.value; // store old median
double medDiff; // difference between old and new median
// if weight above the median is to large, execute the following loop
while ((weightAboveMedian > totalWeight/2) && (median.next != null)) {
// the null check is important if loss of significance occurs
weightBelowMedian += median.weight; // update weight above
median = median.next; // shift median
// update median deviation
medDiff = Math.abs(oldMedian - median.value); // difference between old and new median
totalDeviation -= medDiff * Math.abs(weightBelowMedian - weightAboveMedian); // update deviation
weightAboveMedian -= median.weight; // update weight below
}
// if the weight below the median is to large, execute the following loop
while ((weightBelowMedian > totalWeight/2) && (median.prev != null)) {
// the null check is important if loss of significance occurs
weightAboveMedian += median.weight;
// shift median to the left
median = median.prev;
// update median deviation
medDiff = Math.abs(oldMedian - median.value);
totalDeviation -= medDiff * Math.abs(weightAboveMedian - weightBelowMedian);
weightBelowMedian -= median.weight;
}
*/
// determine median
iterator = first;
double wbm = 0;
double twh = totalWeight/2.0;
while (iterator != null) {
wbm += iterator.weight;
if (wbm > twh) {
median = iterator.prev;
break;
}
iterator = iterator.next;
}
if (median == null) {
median = first;
}
// determine weight below and above
weightAboveMedian = 0;
weightBelowMedian = 0;
totalDeviation = 0;
iterator = first;
while (iterator != null) {
if (iterator.value < median.value) {
weightBelowMedian += iterator.weight;
} else if (iterator.value > median.value) {
weightAboveMedian += iterator.weight;
}
totalDeviation += Math.abs(median.value - iterator.value) * iterator.weight;
iterator = iterator.next;
}
}
/**
*
* @return
* the number of elements currently in the list, equals the (outer) r-loop index
*/
public int size() {
return originalOrder.size();
}
/**
* inserts the newNode after the pivot
* @param pivot
* @param newNode
*/
private void insertAfter(HistNode pivot, HistNode newNode) {
newNode.next = pivot.next;
pivot.next = newNode;
newNode.prev = pivot;
if (pivot == last) {
last = newNode;
} else {
newNode.next.prev = newNode;
newNode.next.resetTemp();
}
// reset temporary pointers
newNode.prev.resetTemp();
newNode.resetTemp();
}
/**
* inserts the newNode before the pivot
* @param pivot
* @param newNode
*/
private void insertBefore(HistNode pivot, HistNode newNode) {
newNode.prev = pivot.prev;
pivot.prev = newNode;
newNode.next = pivot;
if (pivot == first) {
first = newNode;
} else {
newNode.prev.next = newNode;
newNode.prev.resetTemp();
}
// reset temporary pointers
newNode.resetTemp();
newNode.next.resetTemp();
}
/**
* Computes the deviations from the median of every connected interval in the original data vector (stored in indices)
* @return
*/
public double[] computeDeviations() {
// init the output array, i.e., deviation between d_[l,r]
double[] deviationsArray = new double[this.size()];
// init the corresponding median array, i.e., deviation between d_[l,r]
currentMedians = new double[this.size()];
// init all temporary values
firstTemp = first;
lastTemp = last;
HistNode medianTemp = median;
double deviationTemp = totalDeviation;
double weightAboveMedianTemp = weightAboveMedian;
double weightBelowMedianTemp = weightBelowMedian;
double totalWeightTemp = totalWeight;
double medDiff, oldMedian;
for (int l = 1; l < this.size(); l++) {
// set the deviation array entry to the temporary distance
deviationsArray[l-1] = deviationTemp;
// set the median array entry to the temporary median
currentMedians[l-1] = medianTemp.value;
// pointer to the node to be removed
HistNode nodeToRemove = originalOrder.get(l-1);
// removes the node temporarily
double weightToRemove = weights[l-1];
// remove weight from node
nodeToRemove.removeWeightTemp(weightToRemove);
// update deviation
deviationTemp -= weightToRemove * Math.abs(nodeToRemove.value - medianTemp.value);
// update total weight
totalWeightTemp -= weightToRemove;
// update weights above, below
if (nodeToRemove.value > medianTemp.value) {
weightAboveMedianTemp -= weightToRemove;
} else if (nodeToRemove.value < medianTemp.value) {
weightBelowMedianTemp -= weightToRemove;
}
// if weights are unbalanced, the median pointer has to be shifted and the deviations require updates
// if weight above is too large, shift right
double twth = totalWeightTemp/2.0;
while ((weightAboveMedianTemp > twth) && (medianTemp.nextTemp != null)) {
oldMedian = medianTemp.value;
weightBelowMedianTemp += medianTemp.weightTemp; // update weight below
medianTemp = medianTemp.nextTemp;
// calculate difference between old and new median
medDiff = Math.abs(oldMedian - medianTemp.value);
// decrease deviation according median and weight differences
deviationTemp -= medDiff * Math.abs(weightBelowMedianTemp - weightAboveMedianTemp);
weightAboveMedianTemp -= medianTemp.weightTemp; // update weight above
}
// if weight below is too large, shift right
while ((weightBelowMedianTemp > twth) && (medianTemp.prevTemp != null)) {
oldMedian = medianTemp.value; // store old median
weightAboveMedianTemp += medianTemp.weightTemp; // update weight above
medianTemp = medianTemp.prevTemp; // shift median to left
// calculate difference between old and new median
medDiff = Math.abs(oldMedian - medianTemp.value);
// decrease deviation according median and weight differences
deviationTemp -= medDiff * Math.abs(weightAboveMedianTemp - weightBelowMedianTemp);
weightBelowMedianTemp -= medianTemp.weightTemp; // update weight below
}
// remove node temporary, if it contains no more weights
if (nodeToRemove.countTemp == 0) {
removeTemp(nodeToRemove);
}
}
return deviationsArray;
}
/**
* remove temporarily a HistNode from the histogram
*
* @param index
*/
private void removeTemp(HistNode nodeToRemove) {
// remove node temporarily
if (nodeToRemove == lastTemp) {
lastTemp = lastTemp.prevTemp;
lastTemp.nextTemp = null;
} else if (nodeToRemove == firstTemp) {
firstTemp = firstTemp.nextTemp;
firstTemp.prevTemp = null;
} else {
nodeToRemove.nextTemp.prevTemp = nodeToRemove.prevTemp;
nodeToRemove.prevTemp.nextTemp = nodeToRemove.nextTemp;
}
}
}
| 10,452 | 29.475219 | 122 | java |
Pottslab | Pottslab-master/Java/src/pottslab/IndexedLinkedHistogramUnweighted.java | package pottslab;
import java.util.ArrayList;
/**
* @author martinstorath
*
*/
public class IndexedLinkedHistogramUnweighted {
private ArrayList<HistNode> originalOrder; // stores the nodes in order of the incoming insertions
private HistNode first, last, median; // list pointers
private HistNode firstTemp, lastTemp; // temporary list pointers
private double currentDeviation; // stores the deviation from the median
/**
* Constructor
* @param initialSize
* the expected list size
*/
public IndexedLinkedHistogramUnweighted(int initialSize) {
// initialize the array which indexes the nodes in their original order
originalOrder = new ArrayList<HistNode>(initialSize);
}
/**
* Node inner class
*/
class HistNode {
// the value
double value;
// pointer to the next and previous elements
HistNode next, prev;
// temporary pointers to the next and previous elements
HistNode nextTemp, prevTemp;
/**
* Node constructor
* @param element
*/
HistNode(double element) {
this.value = element;
}
void resetTemp() {
nextTemp = next;
prevTemp = prev;
}
}
/**
* inserts an element sorted in ascending order from first to last
*/
public void insertSorted(double elem) {
HistNode node = new HistNode(elem);
if (first == null) { // empty list
first = node;
last = node;
median = node;
currentDeviation = 0;
} else { // non empty list
HistNode iterator = first;
// isEven is true, if the size of the list is even
boolean isEven = (this.size() % 2 == 0);
// for speed-up, we insert and reset the temporary pointers in one sweep
HistNode pivot = null;
while (iterator != null) {
// find pivot element
if ((pivot == null) && (iterator.value > node.value)) {
pivot = iterator;
}
// set temporary pointers
iterator.prevTemp = iterator.prev;
iterator.nextTemp = iterator.next;
iterator = iterator.next;
}
// insert node at right place
if (pivot != null) {
insertBefore(pivot, node);
} else { // iterator is null if elem is greater than all elements in the list
insertAfter(last, node);
}
// update deviation from (old) median
currentDeviation = currentDeviation + Math.abs(node.value - median.value);
HistNode medianOld = median; // store old median
// update median and distances
boolean insertAboveMedian = median.value <= node.value;
if (!insertAboveMedian && isEven) {
median = median.prev;
currentDeviation = currentDeviation - medianOld.value + median.value;
} else if (insertAboveMedian && !isEven) {
median = median.next;
}
}
// add the node to the original order (allows removeTemp in O(1)!)
originalOrder.add(node);
// set temporary first and last
firstTemp = first;
lastTemp = last;
}
/**
*
* @return
* the number of elements currently in the list
*/
public int size() {
return originalOrder.size();
}
/**
* inserts the newNode after the pivot
* @param pivot
* @param newNode
*/
private void insertAfter(HistNode pivot, HistNode newNode) {
newNode.next = pivot.next;
pivot.next = newNode;
newNode.prev = pivot;
if (pivot == last) {
last = newNode;
} else {
newNode.next.prev = newNode;
newNode.next.resetTemp();
}
// reset temporary pointers
newNode.prev.resetTemp();
newNode.resetTemp();
}
/**
* inserts the newNode before the pivot
* @param pivot
* @param newNode
*/
private void insertBefore(HistNode pivot, HistNode newNode) {
newNode.prev = pivot.prev;
pivot.prev = newNode;
newNode.next = pivot;
if (pivot == first) {
first = newNode;
} else {
newNode.prev.next = newNode;
newNode.prev.resetTemp();
}
// reset temporary pointers
newNode.resetTemp();
newNode.next.resetTemp();
}
/**
* Computes the deviations from the median of every connected interval in the original data vector (stored in indices)
* @return
*/
public double[] computeDeviations() {
// Initialization
double[] deviationsArray = new double[this.size()];
HistNode medianTemp = median;
double deviationTemp = currentDeviation;
// reset all temporary values and pointers to the non-temporary ones
//resetTemp();
for (int l = 1; l < this.size(); l++) {
// set the deviation to the temporary distance
deviationsArray[l-1] = deviationTemp;
// pointer to the node to be removed
HistNode nodeToRemove = originalOrder.get(l-1);
// removes the node temporarily
removeTemp(nodeToRemove);
// update median and distances
deviationTemp = deviationTemp - Math.abs(medianTemp.value - nodeToRemove.value);
/* the correct update of medTemp and deviationTemp requires to differentiate
between even and odd temporary length and if removedNode was
above or below medianTemp */
double medianValueOld = medianTemp.value;
boolean isEven = ((this.size() - l + 1) % 2 == 0);
if (isEven) {
if ((medianValueOld < nodeToRemove.value) || (medianTemp == nodeToRemove)) {
medianTemp = medianTemp.prevTemp;
deviationTemp = deviationTemp - medianValueOld + medianTemp.value;
}
} else if ((nodeToRemove.value <= medianValueOld) ) {
medianTemp = medianTemp.nextTemp;
}
}
return deviationsArray;
}
/**
* remove temporarily
*
* @param index
*/
private void removeTemp(HistNode nodeToRemove) {
// remove node temporarily
if (nodeToRemove == lastTemp) {
lastTemp = lastTemp.prevTemp;
lastTemp.nextTemp = null;
} else if (nodeToRemove == firstTemp) {
firstTemp = firstTemp.nextTemp;
firstTemp.prevTemp = null;
} else {
nodeToRemove.nextTemp.prevTemp = nodeToRemove.prevTemp;
nodeToRemove.prevTemp.nextTemp = nodeToRemove.nextTemp;
}
}
public String printList(boolean temp) {
String str = "";
HistNode iterator = first;
while (iterator != null) {
// find pivot element
str = str + ", " + iterator.value;
if (temp) {
iterator = iterator.nextTemp;
} else {
iterator = iterator.next;
}
}
return str;
}
public static void main(String[] args) {
IndexedLinkedHistogramUnweighted list = new IndexedLinkedHistogramUnweighted(10);
list.insertSorted(1);
list.insertSorted(0);
list.insertSorted(0);
list.insertSorted(0);
list.computeDeviations();
System.out.println(list.printList(true));
System.out.println(list.printList(false));
list.insertSorted(2);
System.out.println(list.printList(true));
System.out.println(list.printList(false));
}
}
| 6,695 | 26.784232 | 122 | java |
Pottslab | Pottslab-master/Java/src/pottslab/JavaTools.java | package pottslab;
/**
* @author Martin Storath
*
*/
public class JavaTools {
public static int OR_HORIZONTAL = 1,
OR_VERTICAL = 2,
OR_DIAGONAL = 3,
OR_ANTIDIAGONAL = 4;
/**
* minimization of univariate scalar valued Potts functional
* @param f
* @param gamma
* @param weights
* @return
*/
public static double[] minL2Potts(double[] f, double gamma, double[] weights) {
PLVector[] plVec = PLVector.array1DToVector1D(f);
L2Potts pottsCore = new L2Potts(plVec, weights, gamma);
pottsCore.call();
return PLVector.vector1DToArray1D(plVec);
}
/**
* minimization of univariate vector-valued Potts functional
* @param f
* @param gamma
* @param weights
* @return
*/
public static double[][] minL2Potts(double[][] f, double gamma, double[] weights) {
PLVector[] plVec = PLVector.array2DToVector1D(f);
L2Potts pottsCore = new L2Potts(plVec, weights, gamma);
pottsCore.call();
return PLVector.vector1DToArray2D(plVec);
}
/**
* Minimization of univariate L2-Potts along indicated orientation
* @param img
* @param gamma
* @param weights
* @param orientation
* @return
*/
public static PLImage minL2PottsOrientation(PLImage img, double gamma, double[][] weights, String orientation) {
PLProcessor proc = new PLProcessor();
proc.setMultiThreaded(true);
proc.setGamma(gamma);
proc.set(img, weights);
switch (orientation) {
case "horizontal":
proc.applyHorizontally();
break;
case "vertical":
proc.applyVertically();
break;
case "diagonal":
proc.applyDiag();
break;
case "antidiagonal":
proc.applyAntiDiag();
break;
}
return img;
}
/**
* ADMM strategy to the scalar-valued 2D Potts problem anisotropic neighborhood (4-connected)
* @param f
* @param gamma
* @param weights
* @param muInit
* @param muStep
* @param stopTol
* @param verbose
* @return
*/
public static PLImage minL2PottsADMM4(PLImage img, double gamma, double[][] weights, double muInit, double muStep, double stopTol, boolean verbose, boolean multiThreaded, boolean useADMM) {
// init
int m = img.mRow;
int n = img.mCol;
int l = img.mLen;
PLImage u = PLImage.zeros(m,n,l);
PLImage v = img.copy();
PLImage lam = PLImage.zeros(m,n,l);
PLImage temp = PLImage.zeros(m,n,l);
double[][] weightsPrime = new double[m][n];
double error = Double.POSITIVE_INFINITY;
double mu = muInit;
double gammaPrime;
int nIter = 0;
PLProcessor proc = new PLProcessor();
proc.setMultiThreaded(multiThreaded);
double fNorm = img.normQuad();
// a shortcut
if (fNorm == 0) {
return img;
}
// main loop
while (error >= stopTol * fNorm) {
// set Potts parameters
gammaPrime = 2 * gamma;
// set weights
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++){
weightsPrime[i][j] = weights[i][j] + mu;
}
// solve horizontal univariate Potts problems
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++) {
u.get(i, j).set(k, (img.get(i, j).get(k) * weights[i][j] + v.get(i, j).get(k) * mu - lam.get(i, j).get(k)) / weightsPrime[i][j]);
}
proc.set(u, weightsPrime);
proc.setGamma(gammaPrime);
proc.applyHorizontally();
// solve vertical univariate Potts problems
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++) {
v.get(i, j).set(k, (img.get(i, j).get(k) * weights[i][j] + u.get(i, j).get(k) * mu + lam.get(i, j).get(k)) / weightsPrime[i][j]);
}
proc.set(v, weightsPrime);
proc.setGamma(gammaPrime);
proc.applyVertically();
// update Lagrange multiplier and calculate difference between u and v
error = 0;
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++){
temp.get(i, j).set(k, u.get(i, j).get(k) - v.get(i, j).get(k));
if (useADMM) {
lam.get(i, j).set(k, lam.get(i, j).get(k) + temp.get(i, j).get(k) * mu); // update Lagrange multiplier
}
error += Math.pow(temp.get(i, j).get(k), 2); // compute error
}
// update coupling
mu *= muStep;
// count iterations
nIter++;
// show some information
if (verbose) {
System.out.print("*");
if (nIter % 50 == 0) {
System.out.print("\n");
}
}
}
// show some information
if (verbose) {
System.out.println("\n Total number of iterations " + nIter + "\n");
}
// shut down the processor
proc.shutdown();
return u;
}
/**
* ADMM strategy to the scalar-valued 2D Potts problem with near-isotropic neighborhood (8-connected)
* @param img
* @param gamma
* @param weights
* @param muInit
* @param muStep
* @param stopTol
* @param verbose
* @return
*/
public static PLImage minL2PottsADMM8(PLImage img, double gamma, double[][] weights, double muInit, double muStep, double stopTol, boolean verbose, boolean multiThreaded, boolean useADMM, double[] omega) {
// init image dimensions
int m = img.mRow;
int n = img.mCol;
int l = img.mLen;
// init ADMM variables
PLImage u = PLImage.zeros(m,n,l);
PLImage v = img.copy();
PLImage w = img.copy();
PLImage z = img.copy();
PLImage lam1 = PLImage.zeros(m,n,l);
PLImage lam2 = PLImage.zeros(m,n,l);
PLImage lam3 = PLImage.zeros(m,n,l);
PLImage lam4 = PLImage.zeros(m,n,l);
PLImage lam5 = PLImage.zeros(m,n,l);
PLImage lam6 = PLImage.zeros(m,n,l);
// init modified weight vector
double[][] weightsPrime = new double[m][n];
// init coupling
double mu = muInit;
// auxiliary variables
double gammaPrimeC, gammaPrimeD;
// set neighborhood weights
double omegaC = omega[0];
double omegaD = omega[1];
// init up the Potts processer
PLProcessor proc = new PLProcessor();
proc.setMultiThreaded(multiThreaded);
// compute the norm of the input image
double fNorm = img.normQuad();
if (fNorm == 0) {
return img;
}
double error = Double.POSITIVE_INFINITY;
// init number of iterations
int nIter = 0;
// main ADMM iteration
while (error >= stopTol * fNorm) {
// set jump penalty
gammaPrimeC = 4.0 * omegaC * gamma;
gammaPrimeD = 4.0 * omegaD * gamma;
// set weights
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++){
weightsPrime[i][j] = weights[i][j] + 6 * mu;
}
// solve univariate Potts problems horizontally
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++){
u.get(i, j).set(k, ( img.get(i, j).get(k) * weights[i][j] + 2 * mu * (w.get(i, j).get(k) + v.get(i, j).get(k) + z.get(i, j).get(k))
+ 2 * (-lam1.get(i, j).get(k) - lam2.get(i, j).get(k) - lam3.get(i, j).get(k)) ) / weightsPrime[i][j] );
}
proc.set(u, weightsPrime);
proc.setGamma(gammaPrimeC);
proc.applyHorizontally();
// solve 1D Potts problems diagonally
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++){
w.get(i,j).set(k, (img.get(i,j).get(k) * weights[i][j] + 2 * mu * (u.get(i,j).get(k) + v.get(i,j).get(k) + z.get(i,j).get(k))
+ 2 * (lam2.get(i,j).get(k) + lam4.get(i,j).get(k) - lam6.get(i,j).get(k))) / weightsPrime[i][j] );
}
proc.set(w, weightsPrime);
proc.setGamma(gammaPrimeD);
proc.applyDiag();
// solve 1D Potts problems vertically
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++){
v.get(i,j).set(k, (img.get(i,j).get(k) * weights[i][j] + 2 * mu * (u.get(i,j).get(k) + w.get(i,j).get(k) + z.get(i,j).get(k))
+ 2 * (lam1.get(i,j).get(k) - lam4.get(i,j).get(k) - lam5.get(i,j).get(k))) / weightsPrime[i][j]);
}
proc.set(v, weightsPrime);
proc.setGamma(gammaPrimeC);
proc.applyVertically();
// solve 1D Potts problems antidiagonally
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++){
z.get(i,j).set(k, (img.get(i,j).get(k) * weights[i][j] + 2 *mu * (u.get(i,j).get(k) + w.get(i,j).get(k) + v.get(i,j).get(k))
+ 2 * (lam3.get(i,j).get(k) + lam5.get(i,j).get(k) + lam6.get(i,j).get(k))) / weightsPrime[i][j]);
}
proc.set(z, weightsPrime);
proc.setGamma(gammaPrimeD);
proc.applyAntiDiag();
// update Lagrange multiplier and calculate difference between u and v
error = 0;
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++){
if (useADMM) {
//lam1.get(i,j).set(k, lam1.get(i,j).get(k) + mu * (u.get(i,j).get(k) - u.get(i,j).get(k)) );
//lam2.get(i,j).set(k, lam2.get(i,j).get(k) + mu * (u.get(i,j).get(k) - v.get(i,j).get(k)) );
lam1.get(i,j).set(k, lam1.get(i,j).get(k) + mu * (u.get(i,j).get(k) - v.get(i,j).get(k)) );
lam2.get(i,j).set(k, lam2.get(i,j).get(k) + mu * (u.get(i,j).get(k) - w.get(i,j).get(k)) );
lam3.get(i,j).set(k, lam3.get(i,j).get(k) + mu * (u.get(i,j).get(k) - z.get(i,j).get(k)) );
lam4.get(i,j).set(k, lam4.get(i,j).get(k) + mu * (v.get(i,j).get(k) - w.get(i,j).get(k)) );
lam5.get(i,j).set(k, lam5.get(i,j).get(k) + mu * (v.get(i,j).get(k) - z.get(i,j).get(k)) );
lam6.get(i,j).set(k, lam6.get(i,j).get(k) + mu * (w.get(i,j).get(k) - z.get(i,j).get(k)) );
}
error += Math.pow(u.get(i,j).get(k) - v.get(i,j).get(k), 2);
}
// increase coupling parameter
mu *= muStep;
// increase iteration counter
nIter++;
// show some information
if (verbose) {
System.out.print("*");
if (nIter % 50 == 0) {
System.out.print("\n");
}
}
}
// show some information
if (verbose) {
System.out.println("\n Total number of iterations " + nIter + "\n");
}
// shut down the processor
proc.shutdown();
return u;
}
}
| 9,785 | 30.567742 | 210 | java |
Pottslab | Pottslab-master/Java/src/pottslab/L2Potts.java | /**
*
*/
package pottslab;
import java.util.concurrent.Callable;
/**
* @author Martin Storath
*
*/
@SuppressWarnings("rawtypes")
public class L2Potts implements Callable {
PLVector[] mData;
double mGamma;
double[] mWeights;
int mExcludedIntervalSize;
public L2Potts (PLVector[] data, double[] weights, double gamma) {
set(data, weights, gamma);
}
/**
* Set up the data and parameters
* @param data
* @param weights
* @param gamma
*/
public void set(PLVector[] data, double[] weights, double gamma) {
mData = data;
mWeights = weights;
mGamma = gamma;
mExcludedIntervalSize = 0;
}
/**
* Set up the data and parameters
* @param data
* @param weights
* @param gamma
*/
public void setExcludedIntervalSize(int excludedIntervalSize) {
mExcludedIntervalSize = excludedIntervalSize;
}
public double getWeight(int i) {
return (mWeights == null) ? 1 : mWeights[i];
}
/**
* Solve one-dimensional Potts problem in situ on mData
*/
public Object call() {
int n = mData.length;
int[] arrJ = new int[n];
int nVec = mData[0].length();
double[] arrP = new double[n]; // array of Potts values
double d = 0, p = 0, dpg = 0; // temporary variables to save some float operation
PLVector[] m = new PLVector[n + 1]; // cumulative first moments
double[] s = new double[n + 1]; // cumulative second moments (summed up in 3 dimension)
double[] w = new double[n + 1]; // cumulative weights
// precompute cumulative moments
m[0] = PLVector.zeros(nVec);
s[0] = 0;
double wTemp, mTemp, wDiffTemp;
for (int j = 0; j < n; j++) {
wTemp = getWeight(j);
m[j + 1] = mData[j].mult(wTemp);
m[j + 1].plusAssign(m[j]);
s[j + 1] = mData[j].normQuad() * wTemp + s[j];
w[j + 1] = w[j] + wTemp;
}
// main loop
for (int r = 1; r <= n; r++) {
arrP[r-1] = s[r] - m[r].normQuad() / (w[r]); // set Potts value of constant solution
arrJ[r-1] = 0; // set jump location of constant solution
for (int l = r - mExcludedIntervalSize; l >= 2 ; l--) {
// compute squared deviation from mean value d
mTemp = 0;
for (int k = 0; k < nVec; k++) {
mTemp = mTemp + Math.pow(m[r].get(k) - (m[l - 1].get(k)), 2);
}
wDiffTemp = (w[r] - w[l - 1]);
if (wDiffTemp == 0) {
d = 0;
} else {
d = s[r] - s[l - 1] - mTemp / wDiffTemp;
}
dpg = d + mGamma; // temporary variable
if (dpg > arrP[r-1]) {
// Acceleration: if deviation plus jump penalty is larger than best
// Potts functional value, we can break the loop
break;
}
p = arrP[l - 2] + dpg; // candidate Potts value
if (p < arrP[r-1]) {
arrP[r-1] = p; // set optimal Potts value
arrJ[r-1] = l - 1; // set jump location
}
}
}
// Reconstruction from best partition
int r = n;
int l = arrJ[r-1];
PLVector mu = PLVector.zeros(nVec);
while (r > 0) {
// compute mean value on interval [l+1, r]
for (int k = 0; k < nVec; k++) {
mu.set(k, (m[r].get(k) - m[l].get(k)) / (w[r] - w[l]));
}
// set mean value on interval [l+1, r]
for (int j = l; j < r; j++) {
for (int k = 0; k < mu.length(); k++) {
mData[j].set(k, mu.get(k));
}
}
r = l;
if (r < 1) break;
// go to next jump
l = arrJ[r-1];
}
return mData;
}
public void clear() {
mData = null;
mWeights = null;
}
}
| 3,435 | 24.080292 | 89 | java |
Pottslab | Pottslab-master/Java/src/pottslab/PLImage.java | /**
*
*/
package pottslab;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* A structure for a vector valued image
*
* @author Martin Storath
*
*/
public class PLImage {
public PLVector[][] mData;
public int mRow, mCol, mLen;
public PLImage(PLVector[][] vecArr) {
mRow = vecArr.length;
mCol = vecArr[0].length;
mLen = vecArr[0][0].length();
mData = vecArr;
}
public PLImage(double[][] img) {
set(img);
}
public PLImage(double[][][] img) {
set(img);
}
public void set(double[][] img) {
mRow = img.length;
mCol = img[0].length;
mLen = 1;
mData = new PLVector[mRow][mCol];
for (int i = 0; i < mRow; i++) for (int j = 0; j < mCol; j++) {
this.set(i, j, new PLVector(img[i][j]));
}
}
public void set(double[][][] img) {
mRow = img.length;
mCol = img[0].length;
mLen = img[0][0].length;
mData = new PLVector[mRow][mCol];
for (int i = 0; i < mRow; i++) for (int j = 0; j < mCol; j++) {
this.set(i, j, new PLVector(img[i][j]));
}
}
public PLVector get(int i, int j) {
return mData[i][j];
}
public void set(int i, int j, PLVector data) {
mData[i][j] = data;
}
public double[][][] toDouble3D() {
double[][][] arr = new double[mRow][mCol][mLen];
for (int i = 0; i < mRow; i++) for (int j = 0; j < mCol; j++) for (int k = 0; k < mLen; k++) {
arr[i][j][k] = get(i,j).get(k);
}
return arr;
}
public double[] toDouble() {
double[] arr = new double[mRow * mCol * mLen];
for (int i = 0; i < mRow; i++) for (int j = 0; j < mCol; j++) for (int k = 0; k < mLen; k++) {
arr[mRow * mCol * k + mRow * j + i] = get(i,j).get(k);
}
return arr;
}
public double normQuad() {
double norm = 0;
for (int i = 0; i < mRow; i++) for (int j = 0; j < mCol; j++) {
norm += get(i,j).normQuad();
}
return norm;
}
public PLImage copy() {
PLVector[][] newData = new PLVector[mRow][mCol];
for (int i = 0; i < mRow; i++) for (int j = 0; j < mCol; j++) {
newData[i][j] = get(i, j).copy();
}
return new PLImage(newData);
}
public static PLImage zeros(int rows, int cols, int len) {
return new PLImage(new double[rows][cols][len]);
}
public void show() {
final BufferedImage img = toBufferedImage();
JFrame frame = new JFrame("Image test");
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.clearRect(0, 0, getWidth(), getHeight());
g2d.setRenderingHint(
RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// Or _BICUBIC
g2d.scale(2, 2);
g2d.drawImage(img, 0, 0, this);
}
};
panel.setPreferredSize(new Dimension(mRow*4, mCol*4));
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
public BufferedImage toBufferedImage() {
final BufferedImage img = new BufferedImage(mRow, mCol, BufferedImage.TYPE_INT_RGB);
if(mLen == 1) {
for (int i = 0; i < mRow; i++) {
for (int j = 0; j < mCol; j++) {
float c = (float) Math.min(Math.abs(mData[i][j].get(0)), 1.0);
img.setRGB(i, j, new Color(c, c, c).getRGB());
}
}
} else {
for (int i = 0; i < mRow; i++) {
for (int j = 0; j < mCol; j++) {
float r = (float) Math.min(Math.abs(mData[i][j].get(0)), 1.0);
float g = (float) Math.min(Math.abs(mData[i][j].get(1)), 1.0);
float b = (float) Math.min(Math.abs(mData[i][j].get(2)), 1.0);
img.setRGB(i, j, new Color(r, g, b).getRGB());
}
}
}
return img;
}
public static PLImage fromBufferedImage(BufferedImage image) {
double[][][] imgdata = new double[image.getWidth()][image.getHeight()][3];
float[] tmp = new float[3];
for(int i = 0; i < image.getWidth(); i++) {
for(int j = 0; j < image.getHeight(); j++) {
Color c = new Color(image.getRGB(i,j));
c.getRGBColorComponents(tmp);
for (int k = 0; k < 3; k++) {
imgdata[i][j][k] = tmp[k];
}
}
}
return new PLImage(imgdata);
}
}
| 4,256 | 23.894737 | 96 | java |
Pottslab | Pottslab-master/Java/src/pottslab/PLProcessor.java | /**
*
*/
package pottslab;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* @author Martin Storath
*
*/
@SuppressWarnings("rawtypes")
public class PLProcessor {
public PLImage mImg;
public double[][] mWeights;
public int mCol, mRow;
public int mProcessors;
public double mGamma;
public boolean mNonNegative;
public ExecutorService eservice;
public PLProcessor() {
init();
}
public PLProcessor(PLImage img, double[][] weights) {
init();
set(img, weights);
}
protected void init() {
setMultiThreaded(true);
setNonNegative(false);
}
/**
* @param b
*/
public void setNonNegative(boolean b) {
mNonNegative = b;
}
public void set(PLImage img, double[][] weights) {
mImg = img;
mWeights = weights;
mCol = img.mCol;
mRow = img.mRow;
}
/**
* Enable/disable parallel execution
* @param bool
*/
public void setMultiThreaded(boolean bool) {
if (bool) {
mProcessors = Runtime.getRuntime().availableProcessors();
} else {
mProcessors = 1;
}
eservice = Executors.newFixedThreadPool(mProcessors);
}
public void shutdown() {
eservice.shutdown();
}
public void setGamma(double gamma) {
mGamma = gamma;
}
/**
* Applies Potts algorithm in horizontal direction
*
* @param gamma
*/
public void applyHorizontally() {
List<Future> futuresList = new ArrayList<Future>(mRow);
PLVector[] array;
double[] weightsArr;
for (int i = 0; i < mRow; i++) {
// set up arrays
array = new PLVector[mCol];
weightsArr = new double[mCol];
for (int j = 0; j < mCol; j++) {
array[j] = mImg.get(i, j);
weightsArr[j] = mWeights[i][j];
}
// add to task list
futuresList.add(eservice.submit(createTask(array, weightsArr)));
}
for(Future future:futuresList) {
try {
future.get();
}
catch (InterruptedException e) {e.printStackTrace();}
catch (ExecutionException e) {e.printStackTrace();}
}
}
/**
* Applies Potts algorithm in vertical direction
*
* @param gamma
*/
public void applyVertically() {
List<Future> futuresList = new ArrayList<Future>(mCol);
PLVector[] array;
double[] weightsArr;
for (int j = 0; j < mCol; j++) {
// set up arrays
array = new PLVector[mRow];
weightsArr = new double[mRow];
for (int i = 0; i < mRow; i++) {
array[i] = mImg.get(i, j);
weightsArr[i] = mWeights[i][j];
}
futuresList.add(eservice.submit(createTask(array, weightsArr)));
}
for(Future future:futuresList) {
try {
future.get();
}
catch (InterruptedException e) {e.printStackTrace();}
catch (ExecutionException e) {e.printStackTrace();}
}
}
/**
* Applies Potts algorithm in diagonal direction (top left to bottom right)
*
* @param gamma
*/
public void applyDiag() {
int row, col;
List<Future> futuresList = new ArrayList<Future>(mRow+mCol-1);
PLVector[] array;
double[] weightsArr;
for (int k = 0; k < (mCol); k++) {
int sDiag = Math.min(mRow, mCol - k);
array = new PLVector[sDiag];
weightsArr = new double[sDiag];
for (int j = 0; j < sDiag; j++) {
row = j;
col = j + k;
array[j] = mImg.get(row, col);
weightsArr[j] = mWeights[row][col];
}
futuresList.add(eservice.submit(createTask(array, weightsArr)));
}
for (int k = mRow-1; k > 0; k--) {
int sDiag = Math.min(mRow - k, mCol);
array = new PLVector[sDiag];
weightsArr = new double[sDiag];
for (int j = 0; j < sDiag; j++) {
row = j + k;
col = j;
array[j] = mImg.get(row, col);
weightsArr[j] = mWeights[row][col];
}
futuresList.add(eservice.submit(createTask(array, weightsArr)));
}
for(Future future:futuresList) {
try {
future.get();
}
catch (InterruptedException e) {e.printStackTrace();}
catch (ExecutionException e) {e.printStackTrace();}
}
}
/**
* Applies Potts algorithm in antidiagonal direction (top right to bottom left)
*
* @param gamma
*/
public void applyAntiDiag() {
int row, col;
List<Future> futuresList = new ArrayList<Future>(mRow+mCol-1);
PLVector[] array;
double[] weightsArr;
for (int k = 0; k < (mCol); k++) {
int sDiag = Math.min(mRow, mCol - k);
array = new PLVector[sDiag];
weightsArr = new double[sDiag];
for (int j = 0; j < sDiag; j++) {
row = j;
col = mCol - 1 - (j + k);
array[j] = mImg.get(row, col);
weightsArr[j] = mWeights[row][col];
}
futuresList.add(eservice.submit(createTask(array, weightsArr)));
}
for (int k = mRow-1; k > 0; k--) {
int sDiag = Math.min(mRow - k, mCol);
array = new PLVector[sDiag];
weightsArr = new double[sDiag];
for (int j = 0; j < sDiag; j++) {
row = (j + k);
col = mCol - 1 - j;
array[j] = mImg.get(row, col);
weightsArr[j] = mWeights[row][col];
}
futuresList.add(eservice.submit(createTask(array, weightsArr)));
}
for(Future future:futuresList) {
try {
future.get();
}
catch (InterruptedException e) {e.printStackTrace();}
catch (ExecutionException e) {e.printStackTrace();}
}
}
/**
* Applies univariate Potts algorithm into indicated direction
*
* @param gamma
*/
public void applyToDirection(int[] direction) {
int pCol = direction[0];
int pRow = direction[1];
if (pRow == 0) {
this.applyHorizontally();
return;
}
if (pCol == 0) {
this.applyVertically();
return;
}
int row, col;
List<Future> futuresList = new LinkedList<Future>();
PLVector[] array;
double[] weightsArr;
int sDiag;
for(int rOffset = 0; rOffset < pRow ; rOffset++ ) {
for(int cOffset = rOffset; cOffset < mCol; cOffset++ ) {
sDiag = Math.min( (mCol - cOffset - 1)/pCol, (mRow - rOffset-1)/pRow ) + 1;
array = new PLVector[sDiag];
weightsArr = new double[sDiag];
row = rOffset;
col = cOffset;
for (int j = 0; j < sDiag; j++) {
array[j] = mImg.get(row, col);
weightsArr[j] = mWeights[row][col];
row += pRow;
col += pCol;
}
//futuresList.add(eservice.submit(createTask(array, weightsArr)));
Callable l2Potts = createTask(array, weightsArr);
futuresList.add(eservice.submit(l2Potts));
}
}
for(int cOffset = 0; cOffset < pCol ; cOffset++ ) {
for(int rOffset = cOffset; rOffset < mRow; rOffset++ ) {
//int cOffset = 0;
sDiag = Math.min( (mCol - cOffset - 1)/pCol, (mRow - rOffset-1)/pRow ) + 1;
array = new PLVector[sDiag];
weightsArr = new double[sDiag];
row = rOffset;
col = cOffset;
for (int j = 0; j < sDiag; j++) {
array[j] = mImg.get(row, col);
weightsArr[j] = mWeights[row][col];
row += pRow;
col += pCol;
}
//futuresList.add(eservice.submit(createTask(array, weightsArr)));
Callable l2Potts = createTask(array, weightsArr);
futuresList.add(eservice.submit(l2Potts));
}
}
for(Future future:futuresList) {
try {
future.get();
}
catch (InterruptedException e) {e.printStackTrace();}
catch (ExecutionException e) {e.printStackTrace();}
}
}
public Callable<?> createTask(PLVector[] array, double[] weightsArr) {
//if (mNonNegative) {
// return new L2PottsNonNeg(array, weightsArr, mGamma);
//} else {
return new L2Potts(array, weightsArr, mGamma);
//}
}
}
| 7,609 | 23.788274 | 83 | java |
Pottslab | Pottslab-master/Java/src/pottslab/PLVector.java | /**
*
*/
package pottslab;
/**
* Data structure for a vector with some frequently used methods
*
* @author Martin Storath
*
*/
public class PLVector {
private double[] mData;
public PLVector(double data) {
mData = new double[1];
mData[0] = data;
}
public PLVector(double[] data) {
mData = data;
}
public double get(int idx) {
return mData[idx];
}
public double[] get() {
return mData;
}
public void set(double[] data) {
mData = data;
}
public void set(int k, double d) {
mData[k] = d;
}
public double norm() {
return Math.sqrt(this.normQuad());
}
public void normalize() {
double norm = this.norm();
if (norm == 0) {
mData = new double[mData.length];
} else {
for (int i=0; i < mData.length; i++) {
mData[i] /= norm;
}
}
}
public double normQuad() {
double norm = 0;
for (int i=0; i < mData.length; i++) {
norm += Math.pow(mData[i], 2);
}
return norm;
}
public double sum() {
double sum = 0;
for (int i=0; i < mData.length; i++) {
sum += mData[i];
}
return sum;
}
public int length() {
return mData.length;
}
public PLVector mult(double x) {
double[] data = new double[length()];
for (int i=0; i < mData.length; i++) {
data[i] = mData[i] * x;
}
return new PLVector(data);
}
public PLVector multAssign(double x) {
for (int i=0; i < mData.length; i++) {
mData[i] *= x;
}
return this;
}
public PLVector divAssign(double x) {
for (int i=0; i < mData.length; i++) {
mData[i] /= x;
}
return this;
}
public PLVector pow(double p) {
double[] data = new double[length()];
for (int i=0; i < mData.length; i++) {
data[i] = Math.pow(mData[i], p);
}
return new PLVector(data);
}
public PLVector powAssign(double p) {
for (int i=0; i < mData.length; i++) {
mData[i] = Math.pow(mData[i], p);
}
return this;
}
public PLVector plus(PLVector x) {
assert x.length() == this.length();
double[] data = new double[length()];
for (int i=0; i < mData.length; i++) {
data[i] = mData[i] + x.get(i);
}
return new PLVector(data);
}
public PLVector plusAssign(PLVector x) {
assert x.length() == this.length();
for (int i=0; i < mData.length; i++) {
mData[i] += x.get(i);
}
return this;
}
public PLVector minus(PLVector x) {
assert x.length() == this.length();
double[] data = new double[length()];
for (int i=0; i < mData.length; i++) {
data[i] = mData[i] - x.get(i);
}
return new PLVector(data);
}
public PLVector minusAssign(PLVector x) {
assert x.length() == this.length();
for (int i=0; i < mData.length; i++) {
mData[i] -= x.get(i);
}
return this;
}
/**
* Deep copy
* @return
*/
public PLVector copy() {
double datac[] = new double[this.length()];
for (int i=0; i < mData.length; i++) {
datac[i] = mData[i];
}
return new PLVector(datac);
}
public static PLVector zeros(int length) {
return new PLVector(new double[length]);
}
public static PLVector[] array1DToVector1D(double[] arr) {
int m = arr.length;
PLVector[] vec = new PLVector[m];
for (int i = 0; i < m; i++) {
vec[i] = new PLVector(arr[i]);
}
return vec;
}
public static PLVector[] array2DToVector1D(double[][] arr) {
int m = arr.length;
PLVector[] vec = new PLVector[m];
for (int i = 0; i < m; i++) {
vec[i] = new PLVector(arr[i]);
}
return vec;
}
public static PLVector[][] array3DToVector2D(double[][][] arr) {
int m = arr.length;
int n = arr[0].length;
PLVector[][] vec = new PLVector[m][n];
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) {
vec[i][j] = new PLVector(arr[i][j]);
}
return vec;
}
public static PLVector[][] array2DToVector2D(double[][] arr) {
int m = arr.length;
int n = arr[0].length;
PLVector[][] vec = new PLVector[m][n];
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) {
vec[i][j] = new PLVector(arr[i][j]);
}
return vec;
}
public static double[] vector1DToArray1D(PLVector[] vec) {
int m = vec.length;
double[] arr = new double[m];
for (int i = 0; i < m; i++) {
arr[i]= vec[i].get(0);
}
return arr;
}
public static double[][] vector1DToArray2D(PLVector[] vec) {
int m = vec.length;
int l = vec[0].length();
double[][] arr = new double[m][l];
for (int i = 0; i < m; i++) for (int k = 0; k < l; k++) {
arr[i][k] = vec[i].get(k);
}
return arr;
}
public static double[][][] vector2DToArray3D(PLVector[][] vec) {
int m = vec.length;
int n = vec[0].length;
int l = vec[0][0].length();
double[][][] arr = new double[m][n][l];
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) for (int k = 0; k < l; k++) {
arr[i][j][k] = vec[i][j].get(k);
}
return arr;
}
public static double[][] vector2DToArray2D(PLVector[][] vec) {
int m = vec.length;
int n = vec[0].length;
double[][] arr = new double[m][n];
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) {
arr[i][j] = vec[i][j].get(0);
}
return arr;
}
public String toString() {
String str = "(";
int l = this.length();
for (int i=0; i < l; i++) {
str += mData[i];
if (i == l-1) {
str += ")";
} else {
str += ", ";
}
}
return str;
}
}
| 5,359 | 19.694981 | 87 | java |
Pottslab | Pottslab-master/Java/src/pottslab/RunMe.java | package pottslab;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class RunMe {
public static void main(String[] args) throws IOException {
if(args.length < 3) {
System.err.println("pottslab: Multilabel image segmentation based on the Potts model (aka piecewise constant Mumford-Shah model).");
System.err.println("Algorithm: M. Storath, A. Weinmann. \"Fast partitioning of vector-valued images\" SIAM Journal on Imaging Sciences, 2014");
System.err.println("USAGE: java -jar pottslab.jar <input> <output.png> <gamma>");
System.exit(1);
}
PLImage img = PLImage.fromBufferedImage(ImageIO.read(new File(args[0])));
double gamma = Double.valueOf(args[2]);
double[][]weights = new double[img.mRow][img.mCol];
for (int y = 0; y < weights.length; y++) {
for (int x = 0; x < weights[y].length; x++) {
weights[y][x] = 1.0;
}
}
double muInit = gamma * 1e-2;
double muStep = 2;
double stopTol = 1e-10;
boolean verbose = true;
boolean multiThreaded = true;
boolean useADMM = true;
double[] omega = new double[]{Math.sqrt(2.0)-1.0, 1.0-Math.sqrt(2.0)/2.0};
PLImage img2 = JavaTools.minL2PottsADMM8(img, gamma, weights, muInit, muStep, stopTol, verbose, multiThreaded, useADMM, omega);
ImageIO.write(img2.toBufferedImage(), "png", new File(args[1]));
}
}
| 1,590 | 39.794872 | 155 | java |
defects4j | defects4j-master/framework/lib/formatter/src/edu/washington/cs/mut/testrunner/Formatter.java | package edu.washington.cs.mut.testrunner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
public class Formatter implements JUnitResultFormatter {
private PrintStream ps;
private PrintStream allTests;
{
try {
this.ps = new PrintStream(new FileOutputStream(System.getProperty("OUTFILE", "failing-tests.txt"), true), true);
this.allTests = new PrintStream(new FileOutputStream(System.getProperty("ALLTESTS", "all_tests"), true), true);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public void endTestSuite(JUnitTest arg0) throws BuildException {
}
@Override
public void setOutput(OutputStream arg0) {
}
@Override
public void setSystemError(String arg0) {
}
@Override
public void setSystemOutput(String arg0) {
}
String className ;
boolean alreadyPrinted = true;
@Override
public void startTestSuite(JUnitTest junitTest) throws BuildException {
className = junitTest.getName();
alreadyPrinted = false;
}
@Override
public void addError(Test test, Throwable t) {
handle(test, t);
}
@Override
public void addFailure(Test test, AssertionFailedError t) {
handle(test,t);
}
private void handle(Test test, Throwable t) {
String prefix = "--- " ;
String className = null;
String methodName = null;
if (test == null) { // if test is null it indicates an initialization error for the class
failClass(t, prefix);
return;
}
className = test.getClass().getName();
{
Pattern regexp = Pattern.compile("(.*)\\((.*)\\)\\s*");
Matcher match = regexp.matcher(test.toString());
if (match.matches()) {
// Class name will equal to junit.framework.Junit4TestCaseFacade if Junit4
// style tests are ran with Junit3 style test runner.
if(className.equals("junit.framework.JUnit4TestCaseFacade"))
className = match.group(2);
methodName = match.group(1);
}
}
{
Pattern regexp = Pattern.compile("(.*):(.*)\\s*"); // for some weird reson this format is used for Timeout in Junit4
Matcher match = regexp.matcher(test.toString());
if (match.matches()) {
className = match.group(1);
methodName = match.group(2);
}
}
if ("warning".equals(methodName) || "initializationError".equals(methodName)) {
failClass(t, prefix); // there is an issue with the class, not the method.
} else if (null != methodName && null != className) {
if (isJunit4InitFail(t)) {
failClass(t, prefix);
} else {
ps.println(prefix + className + "::" + methodName); // normal case
t.printStackTrace(ps);
}
} else {
ps.print(prefix + "broken test input " + test.toString());
t.printStackTrace(ps);
}
}
private void failClass(Throwable t, String prefix) {
if (!this.alreadyPrinted) {
ps.println(prefix + this.className);
t.printStackTrace(ps);
this.alreadyPrinted = true;
}
}
private boolean isJunit4InitFail(Throwable t) {
for (StackTraceElement ste: t.getStackTrace()) {
if ("createTest".equals(ste.getMethodName())) {
return true;
}
}
return false;
}
@Override
public void endTest(Test test) {
}
@Override
public void startTest(Test test) {
allTests.println(test.toString());
}
}
| 3,671 | 24.678322 | 119 | java |
defects4j | defects4j-master/framework/lib/formatter/src/edu/washington/cs/mut/testrunner/SingleTestRunner.java | package edu.washington.cs.mut.testrunner;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
/**
* Simple JUnit test runner that takes a single test class or test method as
* command line argument and executes only this class or method.
*
* Examples:
* org.x.y.z.TestClass::testMethod1
* -> only testMethod1 in TestClass gets executed
*
* org.x.y.z.TestClass
* -> only TestClass (with all its test methods) gets executed
*/
public class SingleTestRunner {
private static void usageAndExit() {
System.err.println("usage: java " + SingleTestRunner.class.getName() + " testClass[::testMethod]");
System.exit(1);
}
public static void main(String ... args) {
if (args.length != 1) {
usageAndExit();
}
Matcher m = Pattern.compile("(?<className>[^:]+)(::(?<methodName>[^:]+))?").matcher(args[0]);
if (!m.matches()) {
usageAndExit();
}
// Determine and load test class
String className=m.group("className");
Class<?> clazz = null;
try {
clazz = Class.forName(className);
} catch(Exception e) {
System.err.println("Couldn't load class (" + className + "): " + e.getMessage());
System.exit(1);
}
// Check whether a test method is provided and create request
String methodName=m.group("methodName");
Request req;
if (methodName == null) {
req = Request.aClass(clazz);
} else {
req = Request.method(clazz, methodName);
}
Result res = new JUnitCore().run(req);
if (!res.wasSuccessful()) {
System.err.println("Test failed!");
for (Failure f: res.getFailures()) {
System.err.println(f.toString());
}
System.exit(2);
}
// Exit and indicate success. Use System.exit in case any waiting
// threads are preventing a proper JVM shutdown.
System.exit(0);
}
}
| 2,207 | 29.666667 | 107 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/AbstractTestClass.java | package edu.washington.cs.mut.testrunner.junit3;
import org.junit.Assert;
import junit.framework.TestCase;
public abstract class AbstractTestClass extends TestCase {
public void test1() {
Assert.assertTrue(true);
}
public void test2() {
Assert.assertTrue(true);
}
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 370 | 17.55 | 58 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/EmptyTestClass.java | package edu.washington.cs.mut.testrunner.junit3;
import junit.framework.TestCase;
public class EmptyTestClass extends TestCase {
}
| 134 | 15.875 | 48 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/InitError.java | package edu.washington.cs.mut.testrunner.junit3;
import org.junit.Assert;
import junit.framework.TestCase;
public class InitError extends TestCase {
public InitError() {
throw new RuntimeException("Constructor failed");
}
public void test1() {
Assert.assertTrue(true);
}
public void test2() {
Assert.assertTrue("because it should be true", false);
}
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 456 | 19.772727 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/NonJUnitTest.java | package edu.washington.cs.mut.testrunner.junit3;
public class NonJUnitTest {
public static void main(String ... args) {
}
public void runTest() {
}
}
| 171 | 12.230769 | 48 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/NotPublicSuite.java | package edu.washington.cs.mut.testrunner.junit3;
import org.junit.Assert;
import junit.framework.TestCase;
class NotPublicSuite extends TestCase {
public NotPublicSuite() {
}
public void test1() {
Assert.assertTrue(true);
}
public void test2() {
Assert.assertTrue("because it should be true", false);
}
public void test3() {
Assert.assertTrue(true);
}
}
| 378 | 14.791667 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/SimpleTest.java | package edu.washington.cs.mut.testrunner.junit3;
import org.junit.Assert;
import junit.framework.TestCase;
public class SimpleTest extends TestCase{
public void test1() {
Assert.assertTrue(true);
}
public void test2() {
Assert.assertTrue(false);
}
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 364 | 17.25 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit3/Timeout.java | package edu.washington.cs.mut.testrunner.junit3;
import org.junit.Assert;
import junit.framework.TestCase;
public class Timeout extends TestCase {
public void test1() {
Assert.assertTrue(true);
}
public void test2() {
while (true) {
Assert.assertTrue(true);
}
}
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 388 | 16.681818 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/AbstractTestClass.java | package edu.washington.cs.mut.testrunner.junit4;
import org.junit.Assert;
import org.junit.Test;
public abstract class AbstractTestClass {
@Test
public void test1() {
Assert.assertTrue(true);
}
@Test
public void test2() {
Assert.assertTrue(true);
}
@Test
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 373 | 15.26087 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/EmptyTestClass.java | package edu.washington.cs.mut.testrunner.junit4;
import junit.framework.TestCase;
public class EmptyTestClass {
}
| 117 | 13.75 | 48 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/InitError.java | package edu.washington.cs.mut.testrunner.junit4;
import org.junit.Assert;
import org.junit.Test;
public class InitError {
public InitError() {
throw new RuntimeException("Constructor failed");
}
@Test
public void test1() {
Assert.assertTrue(true);
}
@Test
public void test2() {
Assert.assertTrue("because it should be true", false);
}
@Test
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 469 | 16.407407 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/MethodTimeout.java | package edu.washington.cs.mut.testrunner.junit4;
import org.junit.Test;
public class MethodTimeout {
@Test public void test1() {
// this passes
}
@Test(timeout=1000) public void test2() throws Exception {
// this fails
while (true) { Thread.sleep(100); }
}
}
| 278 | 15.411765 | 60 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/NonJUnitTest.java | package edu.washington.cs.mut.testrunner.junit4;
public class NonJUnitTest {
public static void main(String ... args) {
}
public void runTest() {
}
}
| 171 | 12.230769 | 48 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/NotPublicSuite.java | package edu.washington.cs.mut.testrunner.junit4;
import org.junit.Assert;
import org.junit.Test;
class NotPublicSuite {
public NotPublicSuite() {
}
@Test
public void test1() {
Assert.assertTrue(true);
}
@Test
public void test2() {
Assert.assertTrue("because it should be true", false);
}
@Test
public void test3() {
Assert.assertTrue(true);
}
}
| 381 | 13.148148 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/SimpleTest.java | package edu.washington.cs.mut.testrunner.junit4;
import org.junit.Assert;
import org.junit.Test;
public class SimpleTest {
@Test
public void test1() {
Assert.assertTrue(true);
}
@Test
public void test2() {
Assert.assertTrue(false);
}
@Test
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 370 | 15.130435 | 56 | java |
defects4j | defects4j-master/framework/lib/formatter/test/edu/washington/cs/mut/testrunner/junit4/Timeout.java | package edu.washington.cs.mut.testrunner.junit4;
import org.junit.Assert;
import org.junit.Test;
public class Timeout {
@Test
public void test1() {
Assert.assertTrue(true);
}
@Test
public void test2() {
while (true) {
Assert.assertTrue(true);
}
}
@Test
public void test3() {
Assert.assertTrue("because it should be true", false);
}
}
| 391 | 14.68 | 56 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.10.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.10.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 607 | 27.952381 | 73 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.2.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.2.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.3.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.3.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.4.1/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.4.5/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.5-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.5.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.5.1/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.5.5/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.5-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.6.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.6.1/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.6.2/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.6.3/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.7.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.7.2/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.7.4/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.4-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.7.7/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.7-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.7.8/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.8-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.8.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.8.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.8.12/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.8.12-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 607 | 27.952381 | 73 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.8.3/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.8.3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.8.8/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.8.8-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.8.9/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.8.9-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.9.0.pr2/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.9.0.pr2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 610 | 28.095238 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.9.0.pr3/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.9.0.pr3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 610 | 28.095238 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.9.0/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.9.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.9.6/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.9.6-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.9.7/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.9.7-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonCore/generated_sources/2.9.9/PackageVersion.java | package com.fasterxml.jackson.core.json;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.9.9-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-core");
@Override
public Version version() {
return VERSION;
}
}
| 606 | 27.904762 | 72 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.10.0/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.10.0-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 614 | 28.285714 | 77 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.2.2/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.2.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.3.1/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.3.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.0/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.0-rc4-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 617 | 28.428571 | 80 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.1/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.2/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.3/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.4/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.4-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.6/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.6-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.4.7/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.4.7-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.5.1/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.5.2/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.5.3/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.5.4/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.4-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.5.5/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.5-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.5.6/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.5.6-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.0/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.0-rc2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 617 | 28.428571 | 80 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.1/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.2/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.3/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.4/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.4-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.5/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.5-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.6.1/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.6.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 615 | 28.333333 | 78 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.6/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.6-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.6.7.2/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.6.7.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 615 | 28.333333 | 78 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.7.0/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.0-rc3-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 617 | 28.428571 | 80 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.7.1/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.1-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.7.10/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.10-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 614 | 28.285714 | 77 | java |
defects4j | defects4j-master/framework/projects/JacksonDatabind/generated_sources/2.7.2/PackageVersion.java | package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
import com.fasterxml.jackson.core.util.VersionUtil;
/**
* Automatically generated from PackageVersion.java.in during
* packageVersion-generate execution of maven-replacer-plugin in
* pom.xml.
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.7.2-SNAPSHOT", "com.fasterxml.jackson.core", "jackson-databind");
@Override
public Version version() {
return VERSION;
}
}
| 613 | 28.238095 | 76 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.