-
Notifications
You must be signed in to change notification settings - Fork 0
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
DDred
committed
Oct 10, 2011
1 parent
d36a92f
commit f5a16f7
Showing
40 changed files
with
556 additions
and
58 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
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
48 changes: 48 additions & 0 deletions
48
src/libiada/FastChainAlgorithms/FastChain/Calculators/FastAverageWordLength.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,48 @@ | ||
package libiada.FastChainAlgorithms.FastChain.Calculators; | ||
|
||
import libiada.FastChainAlgorithms.FastChain.FastChain; | ||
import libiada.FastChainAlgorithms.FastChain.FastUniformChain; | ||
import libiada.IntervalAnalysis.LinkUp; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 10.10.11 | ||
* Time: 2:03 | ||
*/ | ||
public class FastAverageWordLength extends FastCalculatorBase { | ||
@Override | ||
public double getValue(FastChain chain, LinkUp linkUp) throws Exception { | ||
double result = 0; | ||
for (int i = 0; i < chain.length(); i++) { | ||
result += chain.get(i).length(); | ||
} | ||
return result / chain.length(); | ||
} | ||
|
||
@Override | ||
public double getValue(FastUniformChain chain, LinkUp linkUp) throws Exception { | ||
double result = 0; | ||
for (int i = 0; i < chain.length(); i++) { | ||
if (chain.get(i) == "-") | ||
continue; | ||
result += chain.get(i).length(); | ||
} | ||
return result / chain.length(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "L_avegare" + super.getName(); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return "double"; | ||
} | ||
|
||
@Override | ||
public String getGroup() { | ||
return "Common"; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tChain/Interfaces/FastCalculatorBase.java → ...Chain/Calculators/FastCalculatorBase.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
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
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
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
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,32 @@ | ||
package libiada.Segmentation.Criteria; | ||
|
||
import libiada.FastChainAlgorithms.FastChain.FastChain; | ||
import libiada.Segmentation.SegmentationModel; | ||
import libiada.Segmentation.SimpleSegmentator; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 09.10.11 | ||
* Time: 17:09 | ||
*/ | ||
public abstract class Criteria { | ||
private SegmentationModel bestModel = null; | ||
|
||
public SegmentationModel getBest(FastChain chain, ArrayList<SegmentationModel> models) throws Exception { | ||
for (int i = 0; i < models.size(); i++) { | ||
SimpleSegmentator segmentator = new SimpleSegmentator(); | ||
FastChain current = segmentator.segment(chain, models.get(i)); | ||
if (isBetter(current, chain)) | ||
bestModel = models.get(i); | ||
} | ||
clear(); | ||
return bestModel; | ||
} | ||
|
||
protected abstract void clear(); | ||
|
||
protected abstract boolean isBetter(FastChain segmentedChain, FastChain rootChain) throws Exception; | ||
} |
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,35 @@ | ||
package libiada.Segmentation.Criteria; | ||
|
||
import libiada.FastChainAlgorithms.FastChain.Calculators.FastCalculatorFactory; | ||
import libiada.FastChainAlgorithms.FastChain.FastChain; | ||
import libiada.IntervalAnalysis.LinkUp; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 09.10.11 | ||
* Time: 17:07 | ||
*/ | ||
public class MaxG extends Criteria { | ||
private LinkUp linkUp; | ||
private double maxG = 0; | ||
|
||
public MaxG(LinkUp linkUp) { | ||
this.linkUp = linkUp; | ||
} | ||
|
||
@Override | ||
protected void clear() { | ||
maxG = 0; | ||
} | ||
|
||
@Override | ||
protected boolean isBetter(FastChain segmentedChain, FastChain rootChain) throws Exception { | ||
double g = FastCalculatorFactory.getAverageRemoteness().getValue(segmentedChain, linkUp); | ||
if (g >= maxG) { | ||
maxG = g; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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,40 @@ | ||
package libiada.Segmentation.Criteria; | ||
|
||
import libiada.FastChainAlgorithms.FastChain.Calculators.FastCalculatorFactory; | ||
import libiada.FastChainAlgorithms.FastChain.FastChain; | ||
import libiada.IntervalAnalysis.LinkUp; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 10.10.11 | ||
* Time: 1:55 | ||
*/ | ||
public class ShenonFenoCriteria extends Criteria { | ||
private LinkUp linkUp; | ||
private double minValue = Double.MAX_VALUE; | ||
private double epsilon = 0; | ||
|
||
public ShenonFenoCriteria(LinkUp linkUp, double epsilon) { | ||
this.linkUp = linkUp; | ||
this.epsilon = epsilon; | ||
} | ||
|
||
@Override | ||
protected void clear() { | ||
minValue = Double.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
protected boolean isBetter(FastChain segmentedChain, FastChain rootChain) throws Exception { | ||
double g_M = FastCalculatorFactory.getAverageRemoteness().getValue(segmentedChain, linkUp); | ||
double g_m = FastCalculatorFactory.getAverageRemoteness().getValue(rootChain, linkUp); | ||
double L_av = FastCalculatorFactory.getAverageWordLength().getValue(segmentedChain, linkUp); | ||
double value = Math.abs((segmentedChain.length() * g_M) / (rootChain.length() * g_m) - L_av) - epsilon; | ||
if (value < minValue) { | ||
minValue = value; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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,30 @@ | ||
package libiada.Segmentation.Cutters; | ||
|
||
import libiada.FastChainAlgorithms.FastChain.FastChain; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: Alex | ||
* Date: 09.10.11 | ||
* Time: 15:43 | ||
*/ | ||
public class ChainCutter { | ||
public ArrayList<FastChain> cut(FastChain chain, int leftChainLength) throws Exception { | ||
if (leftChainLength > chain.length()) | ||
throw new IndexOutOfBoundsException("Граница обрезания за пределами длинны строки"); | ||
ArrayList<FastChain> result = new ArrayList<FastChain>(); | ||
FastChain left = new FastChain(); | ||
for (int i = 0; i < leftChainLength; i++) { | ||
left.add(chain.get(i)); | ||
} | ||
FastChain right = new FastChain(); | ||
for (int i = leftChainLength; i < chain.length(); i++) { | ||
right.add(chain.get(i)); | ||
} | ||
result.add(left); | ||
result.add(right); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.