• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala SortedMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中scala.collection.immutable.SortedMap的典型用法代码示例。如果您正苦于以下问题:Scala SortedMap类的具体用法?Scala SortedMap怎么用?Scala SortedMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SortedMap类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: FeatureSet

//设置package包名称以及导入依赖的类
package edu.knowitall.tool.conf
import scala.collection.immutable.SortedMap


class FeatureSet[T, V](val featureMap: SortedMap[String, Feature[T, V]]) {
  def this() = this(SortedMap.empty[String, Feature[T, V]])

  def apply(name: String) = featureMap(name)

  def featureNames(): Seq[String] =
    featureMap.keys.toSeq

  def numFeatures(): Int =
    featureNames.size

  def vectorize(example: T): Seq[V] =
    featureNames.map({ name =>
      val featureFunction = featureMap(name)
      featureFunction(example)
    })(scala.collection.breakOut)
}

object FeatureSet {
  val binaryClass = true

  def apply[T, V](features: Iterable[Feature[T, V]]): FeatureSet[T, V] = {
    new FeatureSet[T, V](SortedMap.empty[String, Feature[T, V]] ++
      features.map(feature => (feature.name, feature)))
  }
} 
开发者ID:schmmd,项目名称:openie-standalone,代码行数:31,代码来源:FeatureSet.scala


示例2: RhetoricalTypes

//设置package包名称以及导入依赖的类
package au.edu.utscic.athanorserver.data

import scala.collection.immutable.SortedMap



object RhetoricalTypes {

  type LexicalNodes = SortedMap[Int,Node]
  type ConstituentTree = List[Any]
  type Dependencies = List[Dependency]

  type ParsedSentence = (LexicalNodes,ConstituentTree,Dependencies)

  case class Node(
                   id:Int,
                   POS:String,
                   surface:Option[String],
                   lemma:Option[String],
                   NER:Option[String] = None,
                   Speaker:Option[String] = None,
                   left:Option[Int] = None,
                   right:Option[Int] = None
                 )

  case class Dependency(
                         name:String,
                         governor:Int,
                         dependent:Int
                       )
} 
开发者ID:uts-cic,项目名称:athanor-server,代码行数:32,代码来源:RhetoricalTypes.scala


示例3: PStringTest

//设置package包名称以及导入依赖的类
package com.avsystem.scex
package compiler.xmlfriendly

import com.avsystem.scex.parsing.{Modification, PString, ShiftInfo}
import org.scalatest.FunSuite

import scala.collection.immutable.SortedMap


class PStringTest extends FunSuite {
  def test(name: String)(modifications: Modification*)
          (shiftMapping: (Int, ShiftInfo)*)(reverseShiftMapping: (Int, ShiftInfo)*): Unit = super.test(name) {
    val (actualShiftMapping, actualReverseShiftMapping) =
      PString.computeMapping(modifications.toList, Nil, Nil)

    assert(actualShiftMapping === SortedMap(shiftMapping: _*), "actual mapping")
    assert(actualReverseShiftMapping === SortedMap(reverseShiftMapping: _*), "reverse mapping")
  }

  test("no modifications test")()()()

  test("single add test")(
    Modification(0, 5))(
    0 -> ShiftInfo(0, 5, 0))(
    0 -> ShiftInfo(0, 0, 5))

  test("single remove test")(
    Modification(0, -5))(
    0 -> ShiftInfo(0, 0, 5))(
    0 -> ShiftInfo(0, 5, 0))

  test("remove+add replace test")(
    Modification(0, -5), Modification(0, 3))(
    0 -> ShiftInfo(0, 3, 5))(
    0 -> ShiftInfo(0, 5, 3))

  test("add+remove replace test")(
    Modification(0, 3), Modification(0, -5))(
    0 -> ShiftInfo(0, 3, 5))(
    0 -> ShiftInfo(0, 5, 3))

  test("consecutive remove and add test")(
    Modification(0, -5), Modification(5, 3))(
    0 -> ShiftInfo(0, 0, 5), 5 -> ShiftInfo(-5, 3, 0))(
    0 -> ShiftInfo(0, 5, 3))

  test("complex test")(
    Modification(2, 5), Modification(3, -4), Modification(10, -2), Modification(12, 4))(
    2 -> ShiftInfo(0, 5, 0), 3 -> ShiftInfo(5, 0, 4), 10 -> ShiftInfo(1, 0, 2), 12 -> ShiftInfo(-1, 4, 0))(
    2 -> ShiftInfo(0, 0, 5), 8 -> ShiftInfo(-5, 4, 0), 11 -> ShiftInfo(-1, 2, 4))
} 
开发者ID:AVSystem,项目名称:scex,代码行数:52,代码来源:PStringTest.scala


示例4: MapTuple

//设置package包名称以及导入依赖的类
import scala.collection.immutable.SortedMap


object MapTuple {
  def main(args: Array[String]) {
    val map = Map("book" -> 10,"gun" -> 18,"ipad" -> 1000)
    for((k,v) <- map) yield (k,v*0.9)

    val scores = scala.collection.mutable.Map("scala" -> 7,"Hadoop" -> 8, "Spark" ->10 )
    val hadoopScore = scores.getOrElse("Hadoop",0)
    scores += ("R" -> 0)
    scores -= "Hadoop"

    val sortedScore = SortedMap("SCALA" -> 7, "Hadoop" -> 8, "spark" -> 10)


    val tuple = (1,2,3.14,"Rocky","Spark")
    val third = tuple._3
    //??tuple?????first,second...
    val (first,second,thirda,fourth,fifth) = tuple
    //???
    val (f1,s1,_,_,_) = tuple

    //??????????
    "Rocky Spark".partition(_.isUpper)

    val symbols = Array("[","-","]")
    val counts = Array(2,5,2)
    //????,???????Array
    val pairs = symbols.zip(counts)
    //?? [[-----]]
    for ((x,y) <- pairs) print(x*y)
  }
} 
开发者ID:WeiLi1201,项目名称:ProgrammingNote,代码行数:35,代码来源:MapTuple.scala



注:本文中的scala.collection.immutable.SortedMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Email类代码示例发布时间:2022-05-23
下一篇:
Scala MongoConnection类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap