|
|
@ -138,7 +138,7 @@ public final class plasmaCondenser {
|
|
|
|
words = new TreeMap(kelondroMSetTools.fastStringComparator);
|
|
|
|
words = new TreeMap(kelondroMSetTools.fastStringComparator);
|
|
|
|
sentences = new HashMap();
|
|
|
|
sentences = new HashMap();
|
|
|
|
HashSet currsentwords = new HashSet();
|
|
|
|
HashSet currsentwords = new HashSet();
|
|
|
|
String sentence = "";
|
|
|
|
StringBuffer sentence = new StringBuffer(100);
|
|
|
|
String word = "";
|
|
|
|
String word = "";
|
|
|
|
String k;
|
|
|
|
String k;
|
|
|
|
int wordlen;
|
|
|
|
int wordlen;
|
|
|
@ -163,7 +163,7 @@ public final class plasmaCondenser {
|
|
|
|
if (sentence.length() > 0) {
|
|
|
|
if (sentence.length() > 0) {
|
|
|
|
// we store the punctuation symbol as first element of the sentence vector
|
|
|
|
// we store the punctuation symbol as first element of the sentence vector
|
|
|
|
allsentencecounter++;
|
|
|
|
allsentencecounter++;
|
|
|
|
sentence = word + sentence;
|
|
|
|
sentence.insert(0, word); // append at beginning
|
|
|
|
if (sentences.containsKey(sentence)) {
|
|
|
|
if (sentences.containsKey(sentence)) {
|
|
|
|
// sentence already exists
|
|
|
|
// sentence already exists
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
@ -184,7 +184,7 @@ public final class plasmaCondenser {
|
|
|
|
words.put(k,sp);
|
|
|
|
words.put(k,sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sentence = "";
|
|
|
|
sentence = new StringBuffer(100);
|
|
|
|
currsentwords.clear();
|
|
|
|
currsentwords.clear();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// store word
|
|
|
|
// store word
|
|
|
@ -202,13 +202,13 @@ public final class plasmaCondenser {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
words.put(word, sp);
|
|
|
|
words.put(word, sp);
|
|
|
|
// we now have the unique handle of the word, put it into the sentence:
|
|
|
|
// we now have the unique handle of the word, put it into the sentence:
|
|
|
|
sentence = sentence + intString(wordHandle, numlength); // thread hang error here
|
|
|
|
sentence.append(intString(wordHandle, numlength));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// finnish last sentence
|
|
|
|
// finnish last sentence
|
|
|
|
if (sentence.length() > 0) {
|
|
|
|
if (sentence.length() > 0) {
|
|
|
|
allsentencecounter++;
|
|
|
|
allsentencecounter++;
|
|
|
|
sentence = "." + sentence;
|
|
|
|
sentence.insert(0, "."); // append at beginning
|
|
|
|
if (sentences.containsKey(sentence)) {
|
|
|
|
if (sentences.containsKey(sentence)) {
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
sp.inc();
|
|
|
|
sp.inc();
|
|
|
@ -226,20 +226,24 @@ public final class plasmaCondenser {
|
|
|
|
Object[] orderedSentences = new Object[sentenceHandleCount];
|
|
|
|
Object[] orderedSentences = new Object[sentenceHandleCount];
|
|
|
|
String[] s;
|
|
|
|
String[] s;
|
|
|
|
int wc;
|
|
|
|
int wc;
|
|
|
|
|
|
|
|
Object o;
|
|
|
|
it = sentences.keySet().iterator();
|
|
|
|
it = sentences.keySet().iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
while (it.hasNext()) {
|
|
|
|
sentence = (String) it.next();
|
|
|
|
o = it.next();
|
|
|
|
wc = (sentence.length() - 1) / numlength;
|
|
|
|
if (o != null) {
|
|
|
|
s = new String[wc + 2];
|
|
|
|
sentence = (StringBuffer) o;
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
wc = (sentence.length() - 1) / numlength;
|
|
|
|
s[0] = intString(sp.count, numlength); // number of occurrences of this sentence
|
|
|
|
s = new String[wc + 2];
|
|
|
|
s[1] = sentence.substring(0,1); // the termination symbol of this sentence
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
for (int i = 0; i < wc; i++) {
|
|
|
|
s[0] = intString(sp.count, numlength); // number of occurrences of this sentence
|
|
|
|
k = sentence.substring(i * numlength + 1, (i + 1) * numlength + 1);
|
|
|
|
s[1] = sentence.substring(0,1); // the termination symbol of this sentence
|
|
|
|
s[i + 2] = k;
|
|
|
|
for (int i = 0; i < wc; i++) {
|
|
|
|
}
|
|
|
|
k = sentence.substring(i * numlength + 1, (i + 1) * numlength + 1);
|
|
|
|
orderedSentences[sp.handle] = s;
|
|
|
|
s[i + 2] = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
orderedSentences[sp.handle] = s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map.Entry entry;
|
|
|
|
Map.Entry entry;
|
|
|
|
// we search for similar words and reorganize the corresponding sentences
|
|
|
|
// we search for similar words and reorganize the corresponding sentences
|
|
|
@ -280,10 +284,12 @@ public final class plasmaCondenser {
|
|
|
|
// depending on the orderedSentences structure, we rebuild the sentence HashMap to
|
|
|
|
// depending on the orderedSentences structure, we rebuild the sentence HashMap to
|
|
|
|
// eliminate double occuring sentences
|
|
|
|
// eliminate double occuring sentences
|
|
|
|
sentences = new HashMap();
|
|
|
|
sentences = new HashMap();
|
|
|
|
|
|
|
|
int le;
|
|
|
|
for (int i = 0; i < orderedSentences.length; i++) {
|
|
|
|
for (int i = 0; i < orderedSentences.length; i++) {
|
|
|
|
sentence = "";
|
|
|
|
le = ((String[]) orderedSentences[i]).length;
|
|
|
|
for (int j = 1; j < ((String[]) orderedSentences[i]).length; j++) sentence = sentence + ((String[]) orderedSentences[i])[j];
|
|
|
|
sentence = new StringBuffer(le * 10);
|
|
|
|
if (sentences.containsKey(sentence)) {
|
|
|
|
for (int j = 1; j < le; j++) sentence.append(((String[]) orderedSentences[i])[j]);
|
|
|
|
|
|
|
|
if (sentences.containsKey(sentence)) {
|
|
|
|
// add sentence counter to counter of found sentence
|
|
|
|
// add sentence counter to counter of found sentence
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
sp.count = sp.count + Integer.parseInt(((String[]) orderedSentences[i])[0]);
|
|
|
|
sp.count = sp.count + Integer.parseInt(((String[]) orderedSentences[i])[0]);
|
|
|
@ -374,12 +380,12 @@ public final class plasmaCondenser {
|
|
|
|
Iterator it;
|
|
|
|
Iterator it;
|
|
|
|
statProp sp;
|
|
|
|
statProp sp;
|
|
|
|
String[] s;
|
|
|
|
String[] s;
|
|
|
|
String sentence;
|
|
|
|
StringBuffer sentence;
|
|
|
|
Object[] orderedSentences = new Object[sentences.size()];
|
|
|
|
Object[] orderedSentences = new Object[sentences.size()];
|
|
|
|
for (int i = 0; i < sentences.size(); i++) orderedSentences[i] = null; // this array must be initialized
|
|
|
|
for (int i = 0; i < sentences.size(); i++) orderedSentences[i] = null; // this array must be initialized
|
|
|
|
it = sentences.keySet().iterator();
|
|
|
|
it = sentences.keySet().iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
while (it.hasNext()) {
|
|
|
|
sentence = (String) it.next();
|
|
|
|
sentence = (StringBuffer) it.next();
|
|
|
|
wc = (sentence.length() - 1) / numlength;
|
|
|
|
wc = (sentence.length() - 1) / numlength;
|
|
|
|
s = new String[wc + 2];
|
|
|
|
s = new String[wc + 2];
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|
sp = (statProp) sentences.get(sentence);
|
|
|
|