Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2017-04-14 16:46:13 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8eeca23449c84bf87372f3da4dfad76855da316c
8eeca234
1 parent
9d54ef94
Ajout sortie
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
grog-recommendation/grog-recommendation-postprocess/src/main/java/org/legrog/recommendation/postprocess/PostprocessingRunner.java
grog-recommendation/grog-recommendation-postprocess/src/main/java/org/legrog/recommendation/postprocess/PostprocessingRunner.java
View file @
8eeca23
package
org
.
legrog
.
recommendation
.
postprocess
;
import
org.apache.commons.csv.CSVFormat
;
import
org.apache.commons.csv.CSVPrinter
;
import
org.apache.commons.csv.CSVRecord
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -12,6 +13,7 @@ import org.springframework.stereotype.Component;
import
java.io.*
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.StreamSupport
;
...
...
@@ -33,6 +35,9 @@ public class PostprocessingRunner implements ApplicationRunner {
@Value
(
"${recommandations.filename}"
)
private
String
recommandationsFilename
;
@Value
(
"${coverage.filename}"
)
private
String
coverageFilename
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
String
sampleFilename
;
...
...
@@ -47,10 +52,23 @@ public class PostprocessingRunner implements ApplicationRunner {
PostprocessingExpert
expert
=
new
PostprocessingExpert
(
samples
,
recommendations
);
PostprocessingCoverage
coverage
=
expert
.
getCoverage
();
writeCsvCoverage
(
coverage
,
dataDir
,
coverageFilename
);
//todo write coverage in a file to be read by user
//...
}
private
void
writeCsvCoverage
(
PostprocessingCoverage
coverage
,
String
dataDir
,
String
coverageFilename
)
throws
PostprocessingException
{
try
{
CSVPrinter
csvPrinter
=
new
CSVPrinter
(
new
FileWriter
(
new
File
(
dataDir
,
coverageFilename
)),
CSVFormat
.
TDF
.
withHeader
(
"c1 (item)"
,
"c2 (item-user)"
,
"c3 (item#)"
));
csvPrinter
.
printRecord
(
coverage
.
getC1
(),
coverage
.
getC2
(),
coverage
.
getC3
());
csvPrinter
.
close
();
}
catch
(
IOException
e
)
{
throw
new
PostprocessingException
(
"Can't write coverage file "
+
dataDir
+
coverageFilename
,
e
);
}
}
/**
* read csv (TDF) file and map it to a list of PostprocessingSample
*
...
...
Please
register
or
login
to post a comment