Class FeatureMatrix

java.lang.Object
ca.phon.ipa.features.FeatureMatrix

public class FeatureMatrix extends Object
Holds all defined feature set for IPA characters. This information is held in the data/features.xml file.
  • Constructor Details

    • FeatureMatrix

      public FeatureMatrix(String fmFile)
      Create a new instance of the FeatureMatrix
    • FeatureMatrix

      public FeatureMatrix(InputStream stream)
  • Method Details

    • getInstance

      public static FeatureMatrix getInstance()
      Returns the shared instance of the FeatureMatrix
    • saveAsXML

      public void saveAsXML(String filename) throws IOException
      Throws:
      IOException
    • saveAsXML

      public void saveAsXML(File filename) throws IOException
      Throws:
      IOException
    • saveAsXML

      public void saveAsXML(OutputStream stream) throws IOException
      Throws:
      IOException
    • getNumberOfFeatures

      public int getNumberOfFeatures()
      Returns the number of features.
    • getFeatureSet

      public FeatureSet getFeatureSet(char ipaChar)
      Return the feature set described by the given ipaChar, or null if nonexistent.
      Parameters:
      ipaChar - IPA character describing the desired feature set
      Returns:
      the desired feature set
    • removeFeatureSet

      public void removeFeatureSet(char ipaChar)
      Remove the feature set from the matrix if it exists, do nothing otherwise.
      Parameters:
      ipaChar - IPA character representing the feature set to remove
    • putFeatureSet

      public void putFeatureSet(char ipaChar, FeatureSet newFeatureSet)
      Set the given feature set for the given IPA character. If that character already has feature set defined, replace that set with the given feature set. Any given feature or feature set that doesn't exist already is created.
      Parameters:
      ipaChar - IPA character to put the feature set with
      newFeatureSet - feature set to put in
    • getFeatures

      public Set<String> getFeatures()
      Returns a hash set of the names of all the features in the matrix as strings. If there are no features, returns an empty hash set.
      Returns:
      a hash set of the feature names
    • getFeature

      public Feature getFeature(String featureName)
      Returns the Feature object for the given feature name (or synonym.)
      Parameters:
      featureName -
      Returns:
      the Feature or null if not found
    • getNamedFeatureSets

      public Map<String,FeatureSet> getNamedFeatureSets()
      Return all named feature sets.
      Returns:
      map of named feature sets
    • putNamedFeatureSet

      public void putNamedFeatureSet(String name, FeatureSet featureSet)
      Set the value of a named FeatureSet
      Parameters:
      name -
      featureSet -
    • getNamedFeatureSet

      public FeatureSet getNamedFeatureSet(String name)
      Return the value of a named FeatureSet
      Parameters:
      name -
      Returns:
      featureSet for given name or null
    • getFeatureSets

      public Map<Character,FeatureSet> getFeatureSets()
      Returns a hash map with all of the feature sets in the matrix as values. Each feature set has its character as its matching key. If not feature sets exist, returns an empty hash map.
      Returns:
      a hash map of characters to feature sets
    • getFeatureSetForFeature

      public FeatureSet getFeatureSetForFeature(String feature)
      Returns the feature set for the name feature.
      Parameters:
      feature - the feature to look up
      Returns:
      the featureset for the give feature or an empty set if the feature was not found
    • getCharactersWithFeature

      public Collection<Character> getCharactersWithFeature(String featureName)
      Returns a collection of all characters that have the given feature.
      Parameters:
      featureName - the name of the feature to search by
      Returns:
      collection of all characters that match featureName
    • getCharacterSet

      public Set<Character> getCharacterSet()
      Returns the character set supported by this feature matrix
      Returns:
      set of characters
    • getFeaturePrimaryFamily

      public String getFeaturePrimaryFamily(String featureName)
      Returns the name of the primary family for the given feature. null if the feature does not have a primary family.
      Parameters:
      featureName - name of feature
      Returns:
      name of feature's primary family
    • getFeatureForIndex

      public String getFeatureForIndex(int idx)
      Returns the feature name for the given index.
    • putFeaturePrimaryFamily

      public boolean putFeaturePrimaryFamily(String featureName, String familyName)
      Sets the primary family for the given feature. If family doesn't exist, it is created. Returns true if successful, false if not. Put will be unsuccessful if feature doesn't exist.
      Parameters:
      featureName - name of feature
      familyName - name of primary family to put with feature
      Returns:
      true if successful, false if not
    • getFeatureSecondaryFamily

      public String getFeatureSecondaryFamily(String featureName)
      Returns the secondary families for the given feature. Null if the feature does not have any secondary families.
      Parameters:
      featureName - name of the feature
      Returns:
      name of the feature's secondary family
    • putFeatureSecondaryFamily

      public boolean putFeatureSecondaryFamily(String featureName, String familyName)
      Sets the secondary family for the given feature. If family doesn't exist, it is created. Returns true if successful, false if not. Put will be unsuccessful if feature doesn't exist.
      Parameters:
      featureName - name of feature
      familyName - name of secondary family to put with feature
      Returns:
      true if successful, false if not
    • getFeaturesWithPrimaryFamily

      public Collection<String> getFeaturesWithPrimaryFamily(String familyName)
    • getFeatureData

      public Feature[] getFeatureData()