public class CasCompare extends Object
Constructor and Description |
---|
CasCompare(CASImpl c1,
CASImpl c2)
Make an instance of this class to set up a compare operation,
and optionally use to configure the compare.
|
Modifier and Type | Method and Description |
---|---|
void |
addStringCongruenceSet(String typeName,
String featureBaseName,
String[] set_of_strings_that_are_equivalent,
int index)
Add a set of strings that should be considered equal when doing string comparisons.
|
void |
applyToBoth(Consumer<CASImpl> c)
Many times some customation needs to be applied to both CASs being compared.
|
void |
applyToTypeFeature(String typeName,
String featureBaseName,
org.apache.uima.internal.util.function.Consumer2<TOP,Feature> c)
Before comparing, you can adjust specific features of specific types, arbitrarily.
|
void |
canonicalizeString(String typeName,
String featureBaseName,
String[] items_to_change,
String canonical_value)
Before comparing, you can, for a selected type and feature which has a string value belonging
to one of a set of strings, change the value to another (fixed) string which will of course
compare equal.
|
void |
compareAll(boolean v)
Continues the comparison after a miscompare (or not).
|
boolean |
compareCASes()
This does the actual comparison operation of the previously specified CASes
|
static boolean |
compareCASes(CASImpl c1,
CASImpl c2)
Compare 2 CASes, with perhaps different type systems.
|
void |
compareIds(boolean v)
Normally, compares ignore the Feature Structure ID when comparing.
|
static StringBuilder |
compareNumberOfFSsByType(CAS cas1,
CAS cas2)
Counts and compares the number of Feature Structures, by type, and generates a report
|
void |
excludeCollectionsTypesFromIndexes()
The compare can find FeatureStructures to compare either from
- being in some index in some view, or
- being referenced through some chain which starts with the above.
|
void |
excludeListTypesFromIndexes()
The compare can find FeatureStructures to compare either from
- being in some index in some view, or
- being referenced through some chain which starts with the above.
|
void |
excludeRootTypesFromIndexes(Set<String> excluded_typeNames)
The compare can find FeatureStructures to compare either from
- being in some index in some view, or
- being referenced through some chain which starts with the above.
|
void |
includeOnlyTheseTypesFromIndexes(List<String> includedTypeNames)
The compare can find FeatureStructures to compare either from
- being in some index in some view, or
- being referenced through some chain which starts with the above.
|
static void |
showProgress()
call this to show progress of the compare - useful for long compares
|
List<Runnable> |
sort_dedup_FSArray(String typeName,
String featureBaseName) |
Runnable |
sort_dedup_FSArray(TOP fs,
Feature feat)
This is an optional pre-compare operation.
|
Runnable |
sortFSArray(FSArray<?> fsArray)
This is an optional pre-compare operation.
|
List<Runnable> |
sortFSArray(String typeName,
String featureBaseName) |
Runnable |
sortStringArray(StringArray stringArray)
This is an optional pre-compare operation.
|
List<Runnable> |
sortStringArray(String typeName,
String featureBaseName) |
List<Runnable> |
type_feature_to_runnable(String typeName,
String featureBaseName,
BiFunction<TOP,Feature,Runnable> c)
Before comparing, you can create pending values for specific types / features, and return
a list of runnables, which when run, plug in those pending values.
|
public static boolean compareCASes(CASImpl c1, CASImpl c2)
c1
- CAS to comparec2
- CAS to comparepublic void compareAll(boolean v)
v
- defaults to false, set to true to continue the comparison after a miscomparepublic void compareIds(boolean v)
v
- defaults to false, set to true to include the Feature Structure ID in the compare.public void applyToBoth(Consumer<CASImpl> c)
c
- the customization to be applied to both CASspublic void applyToTypeFeature(String typeName, String featureBaseName, org.apache.uima.internal.util.function.Consumer2<TOP,Feature> c)
typeName
- the fully qualified name of the typefeatureBaseName
- the short feature name to adjustc
- a function to do the adjustmentpublic List<Runnable> type_feature_to_runnable(String typeName, String featureBaseName, BiFunction<TOP,Feature,Runnable> c)
typeName
- the typefeatureBaseName
- the feature of the typec
- the code to run for this type and featurepublic void canonicalizeString(String typeName, String featureBaseName, String[] items_to_change, String canonical_value)
typeName
- the fully qualified type namefeatureBaseName
- the featureitems_to_change
- an array of strings to change if matched to one of thesecanonical_value
- the new valuepublic List<Runnable> sort_dedup_FSArray(String typeName, String featureBaseName)
public void excludeRootTypesFromIndexes(Set<String> excluded_typeNames)
excluded_typeNames
- type names to excludepublic void excludeCollectionsTypesFromIndexes()
public void excludeListTypesFromIndexes()
public void includeOnlyTheseTypesFromIndexes(List<String> includedTypeNames)
includedTypeNames
- fully qualified type names to include
when finding Feature Structures to compare via the indexes.public void addStringCongruenceSet(String typeName, String featureBaseName, String[] set_of_strings_that_are_equivalent, int index)
typeName
- the fully qualified type namefeatureBaseName
- the feature short nameset_of_strings_that_are_equivalent
- a set of strings that should compare equal, if testing the type / featureindex
- if the item being compared is a reference to a string array, which index should be compared.
Use -1 if not applicable.public static void showProgress()
public boolean compareCASes()
public Runnable sortFSArray(FSArray<?> fsArray)
fsArray
- the array to be sortedpublic Runnable sort_dedup_FSArray(TOP fs, Feature feat)
fs
- the feature structure having the fsarray featurefeat
- the feature having the fsarraypublic Runnable sortStringArray(StringArray stringArray)
stringArray
- the array to be sortedpublic static StringBuilder compareNumberOfFSsByType(CAS cas1, CAS cas2)
cas1
- first CAS to comparecas2
- second CAS to compareCopyright © 2006–2021 The Apache Software Foundation. All rights reserved.