Skip to content

Conversation

madmike200590
Copy link
Collaborator

In order to aid data exploration and visualization, this PR introduces a new feature, allowing answer sets to be written as xlsx files rather than just printed to stdout.

API Changes and Additions

  • new package at.ac.tuwien.kr.alpha.api as top-level package for public API types (such as Alpha.java)
  • Interface AnswerSetToObjectMapper<T> defining a mapping function from AnswerSet to a type parameter T
  • Mapper implementation to map from AnswerSet to Workbook, i.e. xlsx workbooks. Implementation is realized using Apache POI using the approach outlined here

Commandline-Interface

  • New argument -wx <path>: When set, answer sets will be written to xlsx files at the given path, e.g. the call java -jar alpha.jar -i prog.asp -wx /some/dir/progAnswerSet will result in the first answer set being written to /some/dir/progAnswerSet.1.xlsx, the second answer set to /some/dir/progAnswerSet.2.xlsx etc.

XLSX Workbook structure

  • One worksheet (i.e. "tab") for each predicate with arity greater zero
  • One worksheet "Flags" listing all predicates with arity zero
  • In predicate-specific worksheets, each row corresponds to one atom, where columns correspond to the terms of the atom in question

@codecov
Copy link

codecov bot commented Feb 10, 2020

Codecov Report

Merging #219 into master will decrease coverage by <.01%.
The diff coverage is 76.78%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #219      +/-   ##
============================================
- Coverage        79%   78.99%   -0.01%     
- Complexity     2071     2091      +20     
============================================
  Files           145      147       +2     
  Lines          6582     6689     +107     
  Branches       1152     1162      +10     
============================================
+ Hits           5200     5284      +84     
- Misses          979     1001      +22     
- Partials        403      404       +1
Impacted Files Coverage Δ Complexity Δ
src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java 84.21% <ø> (ø) 11 <0> (?)
...java/at/ac/tuwien/kr/alpha/config/InputConfig.java 71.79% <28.57%> (-9.46%) 15 <1> (+1)
...t/ac/tuwien/kr/alpha/config/CommandLineParser.java 82.17% <42.85%> (-1.92%) 26 <0> (ø)
src/main/java/at/ac/tuwien/kr/alpha/Main.java 46.77% <47.05%> (-1.06%) 5 <2> (+1)
...a/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriter.java 92.3% <92.3%> (ø) 3 <3> (?)
...pha/api/mapper/impl/AnswerSetToWorkbookMapper.java 95.83% <95.83%> (ø) 14 <14> (?)
...in/java/at/ac/tuwien/kr/alpha/common/Interner.java 100% <0%> (+10%) 4% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c27810...8f1d5a2. Read the comment docs.

Copy link
Collaborator

@AntoniusW AntoniusW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality provided by this PR will be of high value to many users. There are some minor comments left but overall looks very good.

@madmike200590
Copy link
Collaborator Author

@AntoniusW I made the changes we discussed on Wednesday - Sheets now have a header line, with columns labelled "Attribute x", with 1 <= x <= N and N being the arity of the predicate in question. Furthermore, when the input is unsatisfiable and xlsx output is set, a workbook with one sheet and the content "Input is unsatisfiable - No answer sets!" is written. Also added a few more tests. PR is ready for merging from my end.

@AntoniusW
Copy link
Collaborator

The coverage can be further improved by testing the UNSAT case.

Copy link
Collaborator Author

@madmike200590 madmike200590 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coverage can be further improved by testing the UNSAT case.

Added a testcase for that. The real problem with coverage is that the changes in Main are hard to test without writing lots of code..

@AntoniusW AntoniusW merged commit 5cd8c92 into master Feb 18, 2020
@AntoniusW AntoniusW deleted the write_answersets_to_xlsx branch February 18, 2020 16:09
madmike200590 added a commit to madmike200590/Alpha that referenced this pull request Feb 18, 2020
madmike200590 added a commit to madmike200590/Alpha that referenced this pull request Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants