-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: Fix and refactor tutorials * chore: Add icons * fix: Fix split tables replacing recursivity by a queue --------- Co-authored-by: Romuald Rousseau <[email protected]>
- Loading branch information
1 parent
6eb68a6
commit 069b877
Showing
18 changed files
with
270 additions
and
149 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 28 additions & 12 deletions
40
archery-examples/src/main/java/com/github/romualdrousseau/archery/examples/Tutorial4.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,59 @@ | ||
package com.github.romualdrousseau.archery.examples; | ||
|
||
import java.util.ArrayList; | ||
import java.util.EnumSet; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.github.romualdrousseau.archery.Document; | ||
import com.github.romualdrousseau.archery.DocumentFactory; | ||
import com.github.romualdrousseau.archery.parser.LayexTableParser; | ||
|
||
public class Tutorial4 implements Runnable { | ||
|
||
public Tutorial4() { | ||
public static void main(final String[] args) { | ||
new Tutorial4().run(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
final var tableParser = new LayexTableParser( | ||
List.of("(v.$)+"), | ||
List.of("(()(S+$))(()([/^TOTAL/|v].+$)())+(/TOTAL/.+$)")); | ||
|
||
final var builder = Common.loadModelBuilderFromGitHub("sales-english"); | ||
builder.setTableParser(tableParser); | ||
builder.getEntityList().add("PRODUCTNAME"); | ||
builder.getPatternMap().put("\\D+\\dml", "PRODUCTNAME"); | ||
final var model = builder.build(); | ||
|
||
final var model = builder | ||
.setTableParser(this.customTableParser()) | ||
.setEntityList(this.customEntities(builder.getEntityList())) | ||
.setPatternMap(this.customPatternMap(builder.getPatternMap())) | ||
.build(); | ||
|
||
final var file = Common.loadData("document with multiple tables.xlsx", this.getClass()); | ||
try (final var doc = DocumentFactory.createInstance(file, "UTF-8") | ||
.setModel(model) | ||
.setHints(EnumSet.of(Document.Hint.INTELLI_LAYOUT, Document.Hint.INTELLI_TAG)) | ||
.setRecipe("sheet.setCapillarityThreshold(0)")) { | ||
|
||
doc.sheets().forEach(s -> Common.addSheetDebugger(s).getTable().ifPresent(t -> { | ||
Common.printTags(t.headers()); | ||
Common.printRows(t.rows()); | ||
})); | ||
} | ||
} | ||
|
||
public static void main(final String[] args) { | ||
new Tutorial4().run(); | ||
private LayexTableParser customTableParser() { | ||
return new LayexTableParser( | ||
List.of("(v.$)+"), | ||
List.of("(()(S+$))(()([/^TOTAL/|v].+$)())+(/TOTAL/.+$)")); | ||
} | ||
|
||
private List<String> customEntities(final List<String> entities) { | ||
final var result = new ArrayList<String>(entities); | ||
result.add("PRODUCTNAME"); | ||
result.remove("PACKAGE"); | ||
return result; | ||
} | ||
|
||
private Map<String, String> customPatternMap(final Map<String, String> patterns) { | ||
final var result = new HashMap<String, String>(patterns); | ||
result.put("\\D+\\dml", "PRODUCTNAME"); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.