• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JohnSnowLabs / spark-nlp / 4677451251

pending completion
4677451251

push

github

Maziyar Panahi
Release Spark NLP 4.3.2 on Conda [skip test]

8590 of 12937 relevant lines covered (66.4%)

0.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/scala/com/johnsnowlabs/nlp/AnnotationAudio.scala
1
/*
2
 * Copyright 2017-2022 John Snow Labs
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *    http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.johnsnowlabs.nlp
18

19
import org.apache.spark.sql.Row
20
import org.apache.spark.sql.types._
21

22
import scala.collection.Map
23

24
/** Represents [[AudioAssembler]]'s output parts and their details. */
25
case class AnnotationAudio(
26
    annotatorType: String,
27
    result: Array[Float],
28
    metadata: Map[String, String])
29
    extends IAnnotation {
30

31
  override def equals(obj: Any): Boolean = {
32
    obj match {
33
      case annotation: AnnotationAudio =>
34
        this.annotatorType == annotation.annotatorType &&
×
35
        this.result.sameElements(annotation.result) &&
×
36
        this.metadata == annotation.metadata
×
37
      case _ => false
×
38
    }
39
  }
40

41
  def getAnnotatorType: String = {
42
    annotatorType
×
43
  }
44

45
  def getMetadata: Map[String, String] = {
46
    metadata
×
47
  }
48

49
}
50

51
object AnnotationAudio {
52

53
  case class AnnotationContainer(__annotation: Array[AnnotationAudio])
54

55
  /** This is spark type of an annotation representing its metadata shape */
56
  val dataType = new StructType(
×
57
    Array(
×
58
      StructField("annotatorType", StringType, nullable = true),
×
59
      StructField("result", ArrayType(FloatType, containsNull = false), nullable = true),
×
60
      StructField("metadata", MapType(StringType, StringType), nullable = true)))
×
61

62
  val arrayType = new ArrayType(dataType, true)
×
63

64
  case class AudioFields(result: Array[Float])
65

66
  def apply(row: Row): AnnotationAudio = {
67
    AnnotationAudio(row.getString(0), row.getSeq[Float](1).toArray, row.getMap[String, String](2))
×
68
  }
69

70
  def apply(audio: AudioFields): AnnotationAudio =
71
    AnnotationAudio(
×
72
      AnnotatorType.AUDIO,
×
73
      result = Array.emptyFloatArray,
×
74
      Map.empty[String, String])
×
75

76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc