Packages

package units

Provides classes representing information units (structured and textual units) and meta information (like tf vectors and type mentions).

Overview

Information units (implementing the trait InformationUnit) represent paragraphs in a given document, which can be narrative text (NaturalLanguageTaggedUnit) or structured fragments (CodeTaggedUnit). Each information unit exports a set of meta-information (implementing the MetaInformation trait), which are ready made semantic data for simple analyses. This version of StORMeD provides the following meta-information:

In the case a meta information is not provided for a unit, a AbsentMetaInformation object can be also provided.

Tutorial

Suppose you want to get all the types mentioned in a question. First, you retrieve all its information units:

scala> val questionUnits = question.units
questionUnits: Seq[ch.usi.inf.reveal.parsing.units.InformationUnit] = ...

Instead of using the visitor to on all the HASTs, you can exploit the ready made data provided by the meta information. For example, to get all the meta information for units, you can use flatMap:

scala> import ch.usi.inf.reveal.parsing.units._
import ch.usi.inf.reveal.parsing.units._

scala> val questionMetaInfos = questionUnits.flatMap { _.metaInformation }
questionMetaInfos: Seq[ch.usi.inf.reveal.parsing.units.MetaInformation] = List(...)

You need now to filter to get only the CodeTypesMetaInformation, and then you can get, for example, the mentioned qualified Types:

scala> val codeTypesMetaInfos = questionMetaInfos.filter { _.isInstanceOf[CodeTypesMetaInformation] }.asInstanceOf[Seq[CodeTypesMetaInformation]]
codeTypesMetaInfos: Seq[ch.usi.inf.reveal.parsing.units.CodeTypesMetaInformation] = List(...)

scala> val types = codeTypesMetaInfos.flatMap { _.qualifiedTypes }.distinct
types: Seq[ch.usi.inf.reveal.parsing.model.java.ReferenceTypeNode] = List(...)
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. units
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class AbsentMetaInformation () extends MetaInformation[AbsentMetaInformation] with Product with Serializable

    A special meta information object that represents the absence of a given meta information.

  2. case class CodeIdentifiersMetaInformation (identifiers: List[IdentifierNode]) extends MetaInformation[CodeIdentifiersMetaInformation] with Product with Serializable

    The meta information representing identifiers.

    The meta information representing identifiers.

    identifiers

    a list of identifier nodes.

  3. case class CodeIdentifiersMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[CodeIdentifiersMetaInformation] with Product with Serializable
  4. case class CodeInvocationMetaInformation (invocations: List[MethodInvocationNode]) extends MetaInformation[CodeInvocationMetaInformation] with Product with Serializable

    The meta information representing code invocations.

    The meta information representing code invocations.

    invocations

    a list of method invocation nodes.

  5. case class CodeInvocationMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[CodeInvocationMetaInformation] with Product with Serializable
  6. case class CodeMethodDeclarationsMetaInformation (declarations: List[MethodDeclarationNode]) extends MetaInformation[CodeMethodDeclarationsMetaInformation] with Product with Serializable

    The meta information representing method declarations.

    The meta information representing method declarations.

    declarations

    a list of method declarations.

  7. case class CodeMethodDeclarationsMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[CodeMethodDeclarationsMetaInformation] with Product with Serializable
  8. case class CodeReadabilityMetaInformation (grade: Double, underlyingNumberOfUnits: Double = 1.0) extends MetaInformation[CodeReadabilityMetaInformation] with Product with Serializable
  9. case class CodeReadabilityMetaInformationBuilder (unit: CodeTaggedUnit) extends MetaInformationBuilder[CodeReadabilityMetaInformation] with Product with Serializable
  10. case class CodeTaggedUnit (id: String, astNode: HASTNodeSequence, rawText: String, source: SourceInfo, metaInformation: Seq[MetaInformation[_]] = Seq()) extends InformationUnit with Product with Serializable

    An information unit representing a paragraph mainly containing code.

    An information unit representing a paragraph mainly containing code.

    astNode

    a sequence of HAST nodes representing the HAST of the unit.

  11. case class CodeTypeDeclarationsMetaInformation (classes: List[ClassDeclarationNode], interfaces: List[InterfaceDeclarationNode], enums: List[EnumDeclarationNode]) extends MetaInformation[CodeTypeDeclarationsMetaInformation] with Product with Serializable

    The meta information representing code type declarations.

    The meta information representing code type declarations.

    classes

    a list of class declarations.

    interfaces

    a list of interface declarations.

    enums

    a list of enums.

  12. case class CodeTypeDeclarationsMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[CodeTypeDeclarationsMetaInformation] with Product with Serializable
  13. case class CodeTypesMetaInformation (qualifiedTypes: List[ReferenceTypeNode], simpleTypes: List[ReferenceTypeNode], basicTypes: List[PrimitiveTypeNode], arrayTypes: List[ArrayTypeNode]) extends MetaInformation[CodeTypesMetaInformation] with Product with Serializable

    Contains all the declared and used types in an information unit.

    Contains all the declared and used types in an information unit.

    The code types metainformation represents all the declared and used types in an information unit. For simplicity, this metainformation splits the types into qualified, simple, basic, and array types.

    qualifiedTypes

    a list of qualified reference type nodes.

    simpleTypes

    a list of simple types.

    basicTypes

    a list of primitive types.

    arrayTypes

    a list of array types.

  14. case class CodeTypesMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[CodeTypesMetaInformation] with Product with Serializable

    Builds the code type metainformation.

    Builds the code type metainformation.

    The code type metainformation builder collects all the declared and used types in an information unit. In the case of array types, which can be only used and not declared, the contained is also collected separately, as a qualified or simple type. In the case of generic types, the raw types are *not* collected. Generic classes and interfaces are present with type arguments corresponding to the same type parameters used in the declaration, and not with the corresponding erased or raw types.

  15. case class CodeVariablesMetaInformation (variables: List[VariableDeclarationNode]) extends MetaInformation[CodeVariablesMetaInformation] with Product with Serializable

    The meta information representing the code variable declarations.

    The meta information representing the code variable declarations.

    variables

    the variable declarations in the information unit.

  16. case class CodeVariablesMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[CodeVariablesMetaInformation] with Product with Serializable
  17. sealed trait InformationUnit extends JsonSerializable

    A generic trait for information units.

  18. case class JsonMembersMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[JsonMetaInformation] with Product with Serializable
  19. case class JsonMetaInformation (members: List[JsonMemberNode]) extends MetaInformation[JsonMetaInformation] with Product with Serializable
  20. trait MetaInformation [T <: MetaInformation[T]] extends JsonSerializable

    Common trait for meta information.

  21. trait MetaInformationBuilder [T <: MetaInformation[T]] extends AnyRef
  22. case class MetaInformationBuilderParameters (luceneIndex: LuceneIndex) extends Product with Serializable
  23. case class NaturalLanguageMetaInformation (tfMap: Map[String, Int]) extends MetaInformation[NaturalLanguageMetaInformation] with Product with Serializable

    The meta information for natural language, containing the term frequency map.

    The meta information for natural language, containing the term frequency map.

    tfMap

    the term frequency map for the natural language component of the information unit.

  24. case class NaturalLanguageMetaInformationBuilder (rawText: String) extends MetaInformationBuilder[NaturalLanguageMetaInformation] with Product with Serializable
  25. case class NaturalLanguageTaggedUnit (id: String, astNode: HASTNodeSequence, rawText: String, source: SourceInfo, metaInformation: Seq[MetaInformation[_]] = Seq()) extends InformationUnit with Product with Serializable

    An information unit representing a paragraph mainly containing natural language.

    An information unit representing a paragraph mainly containing natural language.

    astNode

    a sequence of HAST nodes representing the HAST of the unit.

  26. case class SentimentAnalysisMetaInformation (averageLevel: nlp.SentimentLevel.Value, underlyingNumberOfUnits: Double = 1.0) extends MetaInformation[SentimentAnalysisMetaInformation] with Product with Serializable
  27. case class SentimentAnalysisMetaInformationBuilder (unit: NaturalLanguageTaggedUnit) extends MetaInformationBuilder[SentimentAnalysisMetaInformation] with Product with Serializable
  28. case class TextReadabilityMetaInformation (fleshReadingEaseScore: Double, fleshKincaidGradeLevel: Double, automatedReadingIndex: Double, gunningFogIndex: Double, smogIndex: Double, colemanLiauIndex: Double, underlyingNumberOfUnits: Double = 1.0) extends MetaInformation[TextReadabilityMetaInformation] with Product with Serializable
  29. case class TextReadabilityMetaInformationBuilder (unit: NaturalLanguageTaggedUnit) extends MetaInformationBuilder[TextReadabilityMetaInformation] with Product with Serializable
  30. case class XmlTagsMetaInformation (composed: List[XmlComposedNode], single: List[XmlSingleNode]) extends MetaInformation[XmlTagsMetaInformation] with Product with Serializable
  31. case class XmlTagsMetaInformationBuilder (parsedCode: HASTNode) extends MetaInformationBuilder[XmlTagsMetaInformation] with Product with Serializable

Value Members

  1. object InformationUnit

    Companion object with utility methods for information units.

  2. object InformationUnit2MetaInformationBuilder

    A builder for meta information.

Inherited from AnyRef

Inherited from Any

Ungrouped