Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yaoguangluo
committed
Oct 14, 2018
1 parent
c61771a
commit 7378b8d
Showing
10 changed files
with
202 additions
and
36 deletions.
There are no files selected for viewing
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
10 changes: 7 additions & 3 deletions
10
main/src/org/tinos/engine/analysis/CogsBinaryForestAnalyzer.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,6 +1,10 @@ | ||
package org.tinos.engine.analysis; | ||
|
||
public interface CogsBinaryForestAnalyzer extends BinaryForestAnalyzer { | ||
} | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.tinos.view.obj.WordFrequency; | ||
|
||
|
||
public interface CogsBinaryForestAnalyzer extends BinaryForestAnalyzer { | ||
List<WordFrequency> getWordFrequency(List<String> sets) throws IOException; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
main/src/org/tinos/engine/linerScience/Quick6DLuoYaoguangSort.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.tinos.engine.linerScience; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.tinos.view.obj.WordFrequency; | ||
|
||
public interface Quick6DLuoYaoguangSort { | ||
|
||
void quick6DLuoYaoGuangSortWordFrequency(List<WordFrequency> list, int leftPosition, int rightPosition); | ||
|
||
int partition(List<WordFrequency> list, int leftPosition, int rightPosition); | ||
|
||
List<WordFrequency> frequencyWordMapToList(Map<String, WordFrequency> map); | ||
} |
70 changes: 70 additions & 0 deletions
70
main/src/org/tinos/engine/linerScience/imp/Quick6DLuoYaoguangSortImp.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.tinos.engine.linerScience.imp; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.tinos.view.obj.WordFrequency; | ||
import org.tinos.view.stable.StableData; | ||
import org.tinos.engine.linerScience.Quick6DLuoYaoguangSort; | ||
|
||
public class Quick6DLuoYaoguangSortImp implements Quick6DLuoYaoguangSort { | ||
public void quick6DLuoYaoGuangSortWordFrequency(List<WordFrequency> list, int leftPosition, int rightPosition) { | ||
if (leftPosition < rightPosition) { | ||
int c = rightPosition - leftPosition + StableData.INT_ONE; | ||
if (c < StableData.INT_SEVEN) { | ||
int j; | ||
for (int i = StableData.INT_ONE + leftPosition; i < leftPosition + c; i++) { | ||
j = i; | ||
while (j >= StableData.INT_ONE + leftPosition) { | ||
if (list.get(j).getFrequency() < list.get(j - StableData.INT_ONE).getFrequency()) { | ||
WordFrequency wordFrequency = list.get(j); | ||
list.set(j, list.get(j - StableData.INT_ONE)); | ||
list.set(j - StableData.INT_ONE, wordFrequency); | ||
} | ||
j--; | ||
} | ||
} | ||
} else { | ||
int pos = partition(list, leftPosition, rightPosition); | ||
quick6DLuoYaoGuangSortWordFrequency(list, leftPosition, pos - StableData.INT_ONE); | ||
quick6DLuoYaoGuangSortWordFrequency(list, pos + StableData.INT_ONE, rightPosition); | ||
} | ||
} | ||
} | ||
|
||
public int partition(List<WordFrequency> list, int leftPosition, int rightPosition) { | ||
int rightPositionNew = rightPosition; | ||
int leftPositionNew = leftPosition; | ||
WordFrequency wordFrequencyX = list.get(leftPosition); | ||
WordFrequency wordFrequencyY = list.get(rightPosition); | ||
if (wordFrequencyX.getFrequency() <= wordFrequencyY.getFrequency()) { | ||
wordFrequencyY = wordFrequencyX; | ||
} | ||
while (leftPositionNew < rightPositionNew) { | ||
while ((list.get(leftPositionNew).getFrequency() <= wordFrequencyY.getFrequency()) | ||
&& (leftPositionNew < rightPositionNew)) leftPositionNew++; | ||
while (list.get(rightPositionNew).getFrequency() > wordFrequencyY.getFrequency()) rightPositionNew--; | ||
if (leftPositionNew < rightPositionNew) { | ||
WordFrequency wordFrequency = list.get(rightPositionNew); | ||
list.set(rightPositionNew, list.get(leftPositionNew)); | ||
list.set(leftPositionNew, wordFrequency); | ||
} | ||
} | ||
list.set(leftPosition, list.get(rightPositionNew)); | ||
list.set(rightPositionNew, wordFrequencyY); | ||
return rightPositionNew; | ||
} | ||
|
||
@SuppressWarnings(StableData.RAW_TYPES) | ||
public List<WordFrequency> frequencyWordMapToList(Map<String, WordFrequency> map) { | ||
List<WordFrequency> list = new ArrayList<>(); | ||
Iterator iterator = map.keySet().iterator(); | ||
while (iterator.hasNext()) { | ||
list.add(map.get(iterator.next())); | ||
} | ||
return list; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.tinos.view.obj; | ||
|
||
public class WordFrequency { | ||
public String getPOS() { | ||
return POS; | ||
} | ||
|
||
public void setPOS(String POS) { | ||
this.POS = POS; | ||
} | ||
|
||
public String getWord() { | ||
return word; | ||
} | ||
|
||
public void setWord(String word) { | ||
this.word = word; | ||
} | ||
|
||
public int getFrequency() { | ||
return frequency; | ||
} | ||
|
||
public void setFrequency(int frequency) { | ||
this.frequency = frequency; | ||
} | ||
|
||
public WordFrequency getLeft() { | ||
return left; | ||
} | ||
|
||
public void setLeft(WordFrequency left) { | ||
this.left = left; | ||
} | ||
|
||
public WordFrequency getRight() { | ||
return right; | ||
} | ||
|
||
public void setRight(WordFrequency right) { | ||
this.right = right; | ||
} | ||
|
||
private String word; | ||
private String POS; | ||
private int frequency; | ||
private WordFrequency left; | ||
private WordFrequency right; | ||
} |
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