Class FullMarkovModel
java.lang.Object
com.github.szgabsz91.morpher.languagehandlers.hunmorph.impl.markov.FullMarkovModel
- All Implemented Interfaces:
com.github.szgabsz91.morpher.core.io.IConvertable<MarkovModelMessage>,IMarkovModel
IMarkovModel implementation that stores every single transition route.-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface com.github.szgabsz91.morpher.languagehandlers.hunmorph.impl.markov.IMarkovModel
END, START -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given list of affix type to the Markov model.voidAdds the given list of affix types to the Markov model, and sets the last relative frequency to the provided value.com.github.szgabsz91.morpher.languagehandlers.api.model.AffixTypeChaincalculateProbabilities(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes) Creates a newAffixTypeChaincontaining the given affix types.doublecalculateProbability(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes) Calculates the probability of the affix type chain given with its list ofAffixTypes.voidfromMessage(MarkovModelMessage message) Loads the state from the givenMarkovModelMessage.voidfromMessage(com.google.protobuf.Any message) Loads the state from the given message.List<com.github.szgabsz91.morpher.languagehandlers.api.model.ProbabilisticAffixType> getCandidates(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes) Returns the list of candidates that can come after the given list of affix types.com.github.szgabsz91.morpher.languagehandlers.api.model.ProbabilisticAffixTypegetProbabilityOfPOS(com.github.szgabsz91.morpher.core.model.AffixType pos) Returns the affix type with its probability for the given part of speech tag.Returns all the routes in this Markov model, with the relative frequency of the last node.booleanisAffixTypeChainValid(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypeChain) Returns if the affix type chain is valid or not.reverse()Reverses thisFullMarkovModel.List<com.github.szgabsz91.morpher.languagehandlers.api.model.AffixTypeChain> sortAffixTypes(Set<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes, Predicate<com.github.szgabsz91.morpher.core.model.AffixType> posPredicate) Returns an ordered list ofAffixTypeChainobjects.Converts this Markov model to aMarkovModelMessage.toString()Returns the hierarchical string representation of this Markov model.
-
Constructor Details
-
FullMarkovModel
public FullMarkovModel()Default constructor.
-
-
Method Details
-
add
Adds the given list of affix type to the Markov model.- Specified by:
addin interfaceIMarkovModel- Parameters:
affixTypes- the list of affix types
-
add
public void add(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes, long relativeFrequency) Adds the given list of affix types to the Markov model, and sets the last relative frequency to the provided value.- Parameters:
affixTypes- the list of affix typesrelativeFrequency- the last relative frequency
-
isAffixTypeChainValid
public boolean isAffixTypeChainValid(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypeChain) Returns if the affix type chain is valid or not. Returns if the given affix type chain is valid or not.- Specified by:
isAffixTypeChainValidin interfaceIMarkovModel- Parameters:
affixTypeChain- the affix type chain to check- Returns:
- true if the affix type chain is valid, false otherwise
-
sortAffixTypes
public List<com.github.szgabsz91.morpher.languagehandlers.api.model.AffixTypeChain> sortAffixTypes(Set<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes, Predicate<com.github.szgabsz91.morpher.core.model.AffixType> posPredicate) Returns an ordered list ofAffixTypeChainobjects. Tries to sort the given set of affix types, and returns a list ofAffixTypeChainobjects.- Specified by:
sortAffixTypesin interfaceIMarkovModel- Parameters:
affixTypes- the set of affix typesposPredicate- predicate that returns if a given affix type is a part-of-speech tag or not- Returns:
- the list of
AffixTypeChainobjects
-
calculateProbabilities
public com.github.szgabsz91.morpher.languagehandlers.api.model.AffixTypeChain calculateProbabilities(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes) Creates a newAffixTypeChaincontaining the given affix types. Creates a newAffixTypeChaincontaining the appropriate part of speech tag and the given list of affix types, with the calculated local probabilities.- Specified by:
calculateProbabilitiesin interfaceIMarkovModel- Parameters:
affixTypes- the affix types on the chain- Returns:
- the created
AffixTypeChain
-
calculateProbability
public double calculateProbability(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes) Calculates the probability of the affix type chain given with its list ofAffixTypes. Calculates the probability of the affix type chain given with its list ofAffixTypes.- Specified by:
calculateProbabilityin interfaceIMarkovModel- Parameters:
affixTypes- the list ofAffixTypes on the affix type chain- Returns:
- the probability of the affix type chain
-
getProbabilityOfPOS
public com.github.szgabsz91.morpher.languagehandlers.api.model.ProbabilisticAffixType getProbabilityOfPOS(com.github.szgabsz91.morpher.core.model.AffixType pos) Returns the affix type with its probability for the given part of speech tag. Returns the affix type with its probability for the given part of speech tag.- Specified by:
getProbabilityOfPOSin interfaceIMarkovModel- Parameters:
pos- the part of speech tag- Returns:
- the
ProbabilisticAffixTypeinstance
-
getCandidates
public List<com.github.szgabsz91.morpher.languagehandlers.api.model.ProbabilisticAffixType> getCandidates(List<com.github.szgabsz91.morpher.core.model.AffixType> affixTypes) Returns the list of candidates that can come after the given list of affix types. Returns the candidates after the given list of affix types.- Specified by:
getCandidatesin interfaceIMarkovModel- Parameters:
affixTypes- the already processed list of affix types- Returns:
- the list of candidates, sorted by relative frequencies, in descending order
-
reverse
Reverses thisFullMarkovModel.- Specified by:
reversein interfaceIMarkovModel- Returns:
- the reversed
FullMarkovModel
-
toMessage
Converts this Markov model to aMarkovModelMessage.- Specified by:
toMessagein interfacecom.github.szgabsz91.morpher.core.io.IConvertable<MarkovModelMessage>- Returns:
- the
MarkovModelMessage
-
fromMessage
Loads the state from the givenMarkovModelMessage.- Specified by:
fromMessagein interfacecom.github.szgabsz91.morpher.core.io.IConvertable<MarkovModelMessage>- Parameters:
message- theMarkovModelMessage
-
fromMessage
public void fromMessage(com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Loads the state from the given message.- Specified by:
fromMessagein interfacecom.github.szgabsz91.morpher.core.io.IConvertable<MarkovModelMessage>- Parameters:
message- the message- Throws:
com.google.protobuf.InvalidProtocolBufferException- if the given message is not aMarkovModelMessage
-
getRoutes
Returns all the routes in this Markov model, with the relative frequency of the last node.- Returns:
- all the routes associated with the relative frequency of the last node
-
toString
Returns the hierarchical string representation of this Markov model.
-