Added some style modifications.

This commit is contained in:
2018-11-20 09:52:16 +01:00
parent cbfe3e6025
commit a7f3bdb925
13 changed files with 233 additions and 114 deletions

View File

@@ -43,7 +43,7 @@ public class StatisticsNew {
private LocalDateTime timeBeginning;
private LocalDateTime timeEnding;
private Map<Collocability, Map<MultipleHMKeys, Double>> collocability;
private AtomicLong uniGramOccurrences;
private Map<String, AtomicLong> uniGramTaxonomyOccurrences;
public StatisticsNew(Corpus corpus, Filter filter, boolean useDB) {
this.corpus = corpus;
@@ -51,7 +51,8 @@ public class StatisticsNew {
this.taxonomyResult = new ConcurrentHashMap<>();
this.taxonomyResult.put("Total", new ConcurrentHashMap<>());
this.collocability = new ConcurrentHashMap<>();
this.uniGramOccurrences = new AtomicLong(0L);
this.uniGramTaxonomyOccurrences = new ConcurrentHashMap<>();
this.uniGramTaxonomyOccurrences.put("Total", new AtomicLong(0L));
// create table for counting word occurrences per taxonomies
@@ -342,12 +343,20 @@ public class StatisticsNew {
return Util.sortByValue(Util.atomicInt2StringAndInt(map), limit);
}
public void updateUniGramOccurrences(int amount){
uniGramOccurrences.set(uniGramOccurrences.get() + amount);
public void updateUniGramOccurrences(int amount, ArrayList<String> taxonomy){
uniGramTaxonomyOccurrences.get("Total").set(uniGramTaxonomyOccurrences.get("Total").longValue() + amount);
for (String t : taxonomy){
if (uniGramTaxonomyOccurrences.get(t) != null){
uniGramTaxonomyOccurrences.get(t).set(uniGramTaxonomyOccurrences.get(t).longValue() + amount);
} else {
uniGramTaxonomyOccurrences.put(t, new AtomicLong(amount));
}
}
}
public long getUniGramOccurrences(){
return uniGramOccurrences.longValue();
public Map<String, AtomicLong> getUniGramOccurrences(){
// return uniGramTaxonomyOccurrences.get("Total").longValue();
return uniGramTaxonomyOccurrences;
}
public void updateTaxonomyResults(MultipleHMKeys o, List<String> taxonomy) {
@@ -456,16 +465,21 @@ public class StatisticsNew {
info.put("Korpus:", corpus.getCorpusType().toString());
setTimeEnding();
info.put("Datum:", timeEnding.format(DateTimeFormatter.ofPattern("dd.MM.yyyy hh:mm")));
// time elapsed
long seconds = ChronoUnit.MILLIS.between(timeBeginning, timeEnding) / 1000;
info.put("Čas izvajanja:", String.valueOf(seconds) + " s");
if (filter.getAl() == AnalysisLevel.STRING_LEVEL) {
Integer ngramLevel = filter.getNgramValue();
if (ngramLevel == 0)
info.put("Analiza:", "Črke");
info.put("Analiza:", "črke");
else if (ngramLevel == 1) {
// if suffixes or prefixes are not null print word parts
if (filter.getSuffixLength() != null || filter.getSuffixList() != null || filter.getPrefixLength() != null || filter.getPrefixList() != null) {
info.put("Analiza:", "Besedni deli");
info.put("Analiza:", "besedni deli");
} else {
info.put("Analiza:", "Besede");
info.put("Analiza:", "besede");
}
} else
info.put("Analiza:", filter.getAl().toString());
@@ -473,97 +487,102 @@ public class StatisticsNew {
info.put("Analiza:", filter.getAl().toString());
}
if (filter.getAl() == AnalysisLevel.STRING_LEVEL) {
Integer ngramLevel = filter.getNgramValue();
// n.gram nivo
if (ngramLevel > 1) {
info.put("n-gram nivo:", String.valueOf(ngramLevel));
}
// skip
if (ngramLevel > 1)
info.put("Skip:", isNotEmpty(filter.getSkipValue()) ? filter.getSkipValue().toString() : "0");
// calculate for
info.put("Izračunaj za:", filter.getCalculateFor().toString());
// also write
if (filter.getMultipleKeys().size() > 0){
StringBuilder mk = new StringBuilder();
for (CalculateFor s : filter.getMultipleKeys()) {
mk.append(s.toString()).append("; ");
}
info.put("Izpiši tudi: ", String.join("; ", mk.substring(0, mk.length() - 2)));
}
// time elapsed
// setTimeEnding();
long seconds = ChronoUnit.MILLIS.between(timeBeginning, timeEnding) / 1000;
info.put("Čas izvajanja:", String.valueOf(seconds) + " s");
// data limitations
if (filter.getDisplayTaxonomy()){
info.put("Izpiši taksonomije: ", "Da");
} else {
info.put("Izpiši taksonomije: ", "Ne");
}
// note punctuations - ngram > 1
if(ngramLevel > 1) {
if (filter.getNotePunctuations()) {
info.put("Upoštevaj ločila: ", "Da");
} else {
info.put("Upoštevaj ločila: ", "Ne");
}
}
// also write - n - gram > 1
if (ngramLevel > 1 && filter.getCollocability().size() > 0){
StringBuilder mk = new StringBuilder();
for (Collocability s : filter.getCollocability()) {
mk.append(s.toString()).append("; ");
}
info.put("Kolokabilnost: ", String.join("; ", mk.substring(0, mk.length() - 2)));
}
// fragmented MSD - n-gram = 1
if (info.get("Analiza:").equals("Besede")){
if (filter.getWriteMsdAtTheEnd()){
info.put("Izpiši razbit MSD: ", "Da");
} else {
info.put("Izpiši razbit MSD: ", "Ne");
}
}
if (filter.getSuffixLength() != null || filter.getSuffixList() != null || filter.getPrefixLength() != null || filter.getPrefixList() != null) {
if (filter.getPrefixLength() > 0 || filter.getSuffixLength() > 0) {
info.put("Dolžina predpone: ", String.valueOf(filter.getPrefixLength()));
info.put("Dolžina pripone: ", String.valueOf(filter.getSuffixLength()));
} else {
info.put("Seznam predpon: ", String.join("; ", filter.getPrefixList()));
info.put("Seznam pripon: ", String.join("; ", filter.getSuffixList()));
}
}
// msd
if (!isEmpty(filter.getMsd())) {
StringBuilder msdPattern = new StringBuilder();
for (Pattern pattern : filter.getMsd()) {
msdPattern.append(pattern.toString()).append(" ");
}
info.put("MSD:", msdPattern.toString());
}
// if (filter.getAl() == AnalysisLevel.STRING_LEVEL) {
Integer ngramLevel = filter.getNgramValue();
if (ngramLevel == 0){
info.put("Število črk:", filter.getStringLength().toString());
}
// calculate for
info.put("Izračunaj za:", filter.getCalculateFor().toString());
// also write
if (filter.getMultipleKeys().size() > 0){
StringBuilder mk = new StringBuilder();
for (CalculateFor s : filter.getMultipleKeys()) {
mk.append(s.toString()).append("; ");
}
info.put("Izpiši tudi: ", String.join("; ", mk.substring(0, mk.length() - 2)));
} else {
info.put("Izpiši tudi: ", "");
}
// data limitations
if (filter.getDisplayTaxonomy()){
info.put("Izpiši taksonomije: ", "da");
} else {
info.put("Izpiši taksonomije: ", "ne");
}
// n.gram nivo
if (ngramLevel > 1) {
info.put("N-gram nivo:", String.valueOf(ngramLevel));
}
// skip
if (ngramLevel > 1)
info.put("Preskok besed:", isNotEmpty(filter.getSkipValue()) ? filter.getSkipValue().toString() : "0");
// note punctuations - ngram > 1
if(ngramLevel > 1) {
if (filter.getNotePunctuations()) {
info.put("Upoštevaj ločila: ", "da");
} else {
info.put("Upoštevaj ločila: ", "ne");
}
}
// also write - n - gram > 1
if (ngramLevel > 1 && filter.getCollocability().size() > 0){
StringBuilder mk = new StringBuilder();
for (Collocability s : filter.getCollocability()) {
mk.append(s.toString()).append("; ");
}
info.put("Kolokabilnost: ", String.join("; ", mk.substring(0, mk.length() - 2)));
} else {
info.put("Kolokabilnost: ", "");
}
// fragmented MSD - n-gram = 1
if (info.get("Analiza:").equals("besede")){
if (filter.getWriteMsdAtTheEnd()){
info.put("Izpiši razbit MSD: ", "da");
} else {
info.put("Izpiši razbit MSD: ", "ne");
}
}
if (filter.getSuffixLength() != null || filter.getSuffixList() != null || filter.getPrefixLength() != null || filter.getPrefixList() != null) {
if (filter.getPrefixLength() > 0 || filter.getSuffixLength() > 0) {
info.put("Dolžina predpone: ", String.valueOf(filter.getPrefixLength()));
info.put("Dolžina pripone: ", String.valueOf(filter.getSuffixLength()));
} else {
info.put("Seznam predpon: ", String.join("; ", filter.getPrefixList()));
info.put("Seznam pripon: ", String.join("; ", filter.getSuffixList()));
}
}
// msd
if (!isEmpty(filter.getMsd())) {
StringBuilder msdPattern = new StringBuilder();
for (Pattern pattern : filter.getMsd()) {
msdPattern.append(pattern.toString()).append(" ");
}
info.put("Oznaka MSD:", msdPattern.toString());
} else {
info.put("Oznaka MSD:", "");
}
// }
info.put("Taksonomija: ", "");
if (isNotEmpty(filter.getTaxonomy()) && Tax.getCorpusTypesWithTaxonomy().contains(corpus.getCorpusType())) {
ArrayList<String> tax = Tax.getTaxonomyForInfo(corpus.getCorpusType(), filter.getTaxonomy());
info.put("Taksonomija: ", "");
String sep = "";
for (String s : tax) {
info.put(sep = sep + " ", s);