case class Lexicon(vocabularySize: Int, contextSize: Int, data: Vector[Double], speakerDefinition: (Lexicon, Int) ⇒ Lexicon = Lexicon.asBlokpoeletalSpeaker, listenerDefinition: (Lexicon, Int) ⇒ Lexicon = Lexicon.asBlokpoelEtalListener) extends Serializable with Product
A lexicon as defined in the Rational Speech Act theory (Frank & Goodman, 2012). This implementation supports both binary and graded lexicons. It also implements functions that constitute the Rational Speech Act model, i.e., to compute n-th order lexicons. The relationships between vocabulary and context are stored in a 1-dimensional vector. The following mapping:
| R1 | R2 | R3 |
|---|---|---|---|
S1 | 0.8 | 0.2 | 0.0 |
S2 | 0.0 | 0.6 | 0.4 |
Is represented in data as a concatenation of the rows or length contextSize:
Vector[Double](0.8, 0.2, 0.0, 0.0, 0.6, 0.4)
Lexicons are immutable.
- vocabularySize
The size of the vocabulary of this lexicon.
- contextSize
The size of the context of this lexicon.
- data
A 1-dimensional vector representing the relations between the vocabulary and context.
- Annotations
- @SerialVersionUID()
- Alphabetic
- By Inheritance
- Lexicon
- Product
- Equals
- Serializable
- Serializable
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Lexicon(vocabularySize: Int, contextSize: Int, data: Vector[Double], speakerDefinition: (Lexicon, Int) ⇒ Lexicon = Lexicon.asBlokpoeletalSpeaker, listenerDefinition: (Lexicon, Int) ⇒ Lexicon = Lexicon.asBlokpoelEtalListener)
- vocabularySize
The size of the vocabulary of this lexicon.
- contextSize
The size of the context of this lexicon.
- data
A 1-dimensional vector representing the relations between the vocabulary and context.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Lexicon, B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
additiveBinaryMutation(additionRate: Double): Lexicon
Returns a copy of this lexicon where, based on
additionRate, a number of positive signal-referent relations of weight 1.0 will be added to the lexicon.Returns a copy of this lexicon where, based on
additionRate, a number of positive signal-referent relations of weight 1.0 will be added to the lexicon.- additionRate
The ratio of 0-valued signal-referent mappings that will be converted to 1.0 (from 0 to 1).
-
def
apply(i: Int, j: Int): Double
Returns the relation value for signal
iand referentj.Returns the relation value for signal
iand referentj.- i
Index of the signal.
- j
Index of the referent.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asymmetryWith(that: Lexicon, similarity: Double = 0): Double
Returns the asymmetry between this lexicon and that lexicon.
Returns the asymmetry between this lexicon and that lexicon. Asymmetry is computed relative to the similarity threshold, i.e., it is the mean number of signal-referent relations that are more than similarity-value apart.
- that
The other lexicon against which asymmetry is computed.
- similarity
Optional argument specifying the threshold within which a signal-referent relation is considered 'same'.
- returns
The asymmetry between this and that.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- val contextSize: Int
- val data: Vector[Double]
-
def
dot(vector: Vector[Double]): Vector[Double]
Computes the dot product between the graded lexicon and a vector of length
contextSize.Computes the dot product between the graded lexicon and a vector of length
contextSize.- vector
A vector of length
contextSize.- returns
A vector of length
vocabularySizewith the dot product.
- Exceptions thrown
scala.IllegalArgumentExceptionwhenvector.lengthis not equal tocontextSizeof this lexicon.
-
def
dotT(vector: Vector[Double]): Vector[Double]
Computes the dot product between the transposed graded lexicon and a vector of
vocabularySize.Computes the dot product between the transposed graded lexicon and a vector of
vocabularySize.- vector
A vector of length
vocabularySize.- returns
A vector of length
contextSizewith the dot product.
- Exceptions thrown
scala.IllegalArgumentExceptionwhenvector.lengthis not equal tovocabularySizeof this lexicon.
- def ensuring(cond: (Lexicon) ⇒ Boolean, msg: ⇒ Any): Lexicon
- def ensuring(cond: (Lexicon) ⇒ Boolean): Lexicon
- def ensuring(cond: Boolean, msg: ⇒ Any): Lexicon
- def ensuring(cond: Boolean): Lexicon
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getColumn(j: Int): Vector[Double]
Returns the column for referent
j, containing all mapping values between referentjand all signals.Returns the column for referent
j, containing all mapping values between referentjand all signals. This function is of quadratic time complexity, use sparingly. -
def
getRow(i: Int): Vector[Double]
Returns the row for signal
i, containing all mapping values between signaliand all referents. - def isConsistent: Boolean
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val listenerDefinition: (Lexicon, Int) ⇒ Lexicon
-
def
meanAmbiguity(threshold: Double = 1): Double
Returns the mean ambiguity of this graded lexicon, where ambiguity is defined as the mean number of referents for which signals have a relation higher than the threshold.
Returns the mean ambiguity of this graded lexicon, where ambiguity is defined as the mean number of referents for which signals have a relation higher than the threshold.
- threshold
Optional parameter specifying the threshold within which a signal-referent relation is considered relevant.
-
def
meanAndVarianceAmbiguity(threshold: Double = 1): (Double, Double)
Returns a tuple containing the mean (._1) and variance (._2) ambiguity of this graded lexicon.
Returns a tuple containing the mean (._1) and variance (._2) ambiguity of this graded lexicon. Ambiguity is defined as the mean number of referents for which signals have a relation higher than the threshold.
- threshold
Optional parameter specifying the threshold within which a signal-referent relation is considered relevant.
-
def
mixReferents(mixRate: Double): Lexicon
Returns an immutable copy of this lexicon where, based on the
swapRate, signal-referent relations are swapped around with across the mapping's central axis.Returns an immutable copy of this lexicon where, based on the
swapRate, signal-referent relations are swapped around with across the mapping's central axis. That is, if swapped,(i)(j)and(i)(contextSize - j)are swapped.- mixRate
The rate at which referents are swapped.
- returns
A referent-swapped signal-referent mapping.
-
def
mutate(mutationRate: Double): Lexicon
Returns a mutated (but immutable) copy of this lexicon.
Returns a mutated (but immutable) copy of this lexicon. Each word-referent relationship with graded value v has probability
P(mutationRate)of flipping according toMath.abs(v-1). In binary lexicons, a 1 flips to a 0 and vice versa. In graded lexicons a 0.9 flips to a 0.1 and vice versa. This is a non-deterministic transformation.- mutationRate
The probability of a word-referent mapping flipping.
- returns
A mutated (but immutable) mapping.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
normalizeColumns(): Lexicon
Returns a normalization of this lexicon across columns (i.e., divides each cell by the sum of its column).
-
def
normalizeRows(): Lexicon
Returns a normalization of this lexicon across rows (i.e., divides each cell by the sum of its row).
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
removalBinaryMutation(removalRate: Double, threshold: Double = 1): Lexicon
Returns a copy of this lexicon where, based on
additionRate, a number signal-referent relations of weight >thresholdwill be removed to the lexicon.Returns a copy of this lexicon where, based on
additionRate, a number signal-referent relations of weight >thresholdwill be removed to the lexicon.- removalRate
The ratio of 0-valued signal-referent mappings that will be converted to 1.0 (from 0 to 1).
- threshold
Optional parameter specifying the threshold above which relations can be removed.
-
def
setOrderAsListener(n: Int): Lexicon
Returns a transformation of this lexicon corresponding to a
nth order listener as defined by the Rational Speech Act model.Returns a transformation of this lexicon corresponding to a
nth order listener as defined by the Rational Speech Act model.- n
The order of pragmatic reasoning.
-
def
setOrderAsSpeaker(n: Int): Lexicon
Returns a transformation of this lexicon corresponding to a
nth order speaker as defined by the Rational Speech Act model.Returns a transformation of this lexicon corresponding to a
nth order speaker as defined by the Rational Speech Act model.- n
The order of pragmatic reasoning.
- val speakerDefinition: (Lexicon, Int) ⇒ Lexicon
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
to2DVector: Vector[Vector[Double]]
Returns a 2-dimensional vector representation of the lexicon.
Returns a 2-dimensional vector representation of the lexicon. Inefficient function, avoid usage.
-
def
toString(): String
Returns a multi-line formatted string representation of the lexicon.
Returns a multi-line formatted string representation of the lexicon.
- Definition Classes
- Lexicon → AnyRef → Any
-
def
update(i: Int, j: Int, v: Double): Lexicon
Returns a new immutable lexicon with the relation between signal i and referent j updated to value v.
- val vocabularySize: Int
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def →[B](y: B): (Lexicon, B)
Language Agents Simulation framework
For detailed documentation on using the framework please see the README.md file at the Github repository at https://github.com/markblokpoel/lanag-core.