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

Scala StringUtils类代码示例

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

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



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

示例1: ItalianNameFinder

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.it

import java.util.Locale

import org.apache.commons.lang3.StringUtils
import org.pdfextractor.algorithm.candidate.{CandidateMetadata, MetaPhraseType}
import org.pdfextractor.algorithm.finder._
import org.pdfextractor.algorithm.finder.it.ItalianRegexPatterns._
import org.pdfextractor.algorithm.parser.{ParseResult, Phrase}
import org.pdfextractor.algorithm.phrase.PhraseTypesRefreshedEvent
import org.pdfextractor.algorithm.regex._
import org.pdfextractor.db.domain.dictionary.PaymentFieldType.NAME
import org.pdfextractor.db.domain.dictionary.SupportedLocales
import org.springframework.stereotype.Service

@Service
class ItalianNameFinder extends AbstractFinder(SupportedLocales.ITALY, NAME, None, None, false) {

  @org.springframework.context.event.EventListener(
    Array(classOf[PhraseTypesRefreshedEvent]))
  def refreshed(): Unit = {
    searchPattern = Some(
      ("^(?ims)" + phraseTypesStore.buildAllPhrases(SupportedLocales.ITALY,
        NAME) + "$").r)
    valuePattern = Some(("^(?ims)(.*)$").r)
  }

  def isValueAllowed(value: Any): Boolean = {
    !isVoidText(value.asInstanceOf[String]) &&
      ItNameForbiddenWordsR.findFirstIn(value.asInstanceOf[String]).isEmpty &&
      ItNameMinR.findFirstIn(value.asInstanceOf[String]).nonEmpty
  }

  def parseValue(raw: String): Any = {
    if (Option(raw).isEmpty) None
    else StringUtils.normalizeSpace(raw).split(",")(0)
  }

  override def buildProperties(phrase: Phrase, parseResult: ParseResult, params: Seq[Any]): Map[CandidateMetadata, Any] = {
    val phraseType = phraseTypesStore.findType(SupportedLocales.ITALY, NAME, phrase.text)
    Map(MetaPhraseType -> phraseType)
  }

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:45,代码来源:ItalianNameFinder.scala


示例2: EstonianNameFinder

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.et

import java.util.Locale

import org.apache.commons.lang3.StringUtils
import org.pdfextractor.algorithm.candidate.{Candidate, CandidateMetadata, HasPank, MetaPhraseType}
import org.pdfextractor.algorithm.finder.{AbstractFinder, isPankPresent}
import org.pdfextractor.algorithm.parser.{ParseResult, Phrase}
import org.pdfextractor.algorithm.phrase.PhraseTypesRefreshedEvent
import org.pdfextractor.db.domain.dictionary.PaymentFieldType.NAME
import org.pdfextractor.db.domain.dictionary.SupportedLocales
import org.springframework.stereotype.Service

@Service
class EstonianNameFinder extends AbstractFinder(SupportedLocales.ESTONIA, NAME) {

  @org.springframework.context.event.EventListener(
    Array(classOf[PhraseTypesRefreshedEvent]))
  def refreshed(): Unit = {
    searchPattern = Some(
      ("^(?m)" + phraseTypesStore
        .buildAllStarts(SupportedLocales.ESTONIA, NAME) + "$").r)
    valuePattern = Some(
      ("(?m)" + phraseTypesStore.buildAllPhrases(SupportedLocales.ESTONIA,
        NAME)).r)
  }

  override def isValueAllowed(value: Any) = true

  override def parseValue(raw: String): Any = {
    StringUtils normalizeSpace (raw
      .replaceAll("(Registrikood)(.{0,})", "")
      .split("""[\s]{3,}""")(0))
  }

  override def buildProperties(phrase: Phrase, parseResult: ParseResult, params: Seq[Any]): Map[CandidateMetadata, Any] = {
    val phraseType = phraseTypesStore.findType(SupportedLocales.ESTONIA, NAME, phrase.text)
    val pankPresent = isPankPresent(phrase.text)
    Map(MetaPhraseType -> phraseType, HasPank -> pankPresent)
  }

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:43,代码来源:EstonianNameFinder.scala


示例3: EstonianInvoiceIDFinder

//设置package包名称以及导入依赖的类
package org.pdfextractor.algorithm.finder.et

import java.util.Locale

import org.apache.commons.lang3.StringUtils
import org.pdfextractor.algorithm.finder.AbstractFinder
import org.pdfextractor.algorithm.finder.et.EstonianRegexPatterns._
import org.pdfextractor.algorithm.phrase.PhraseTypesRefreshedEvent
import org.pdfextractor.algorithm.regex._
import org.pdfextractor.db.domain.dictionary.PaymentFieldType.INVOICE_ID
import org.pdfextractor.db.domain.dictionary.SupportedLocales
import org.springframework.stereotype.Service

@Service
class EstonianInvoiceIDFinder extends AbstractFinder(SupportedLocales.ESTONIA, INVOICE_ID) {

  @org.springframework.context.event.EventListener(
    Array(classOf[PhraseTypesRefreshedEvent]))
  def refreshed(): Unit = {
    searchPattern = Some(
      ("(?ism)" + phraseTypesStore.buildAllPhrases(SupportedLocales.ESTONIA,
        INVOICE_ID)).r)
    valuePattern = Some(("(?ism)" + phraseTypesStore.buildAllPhrases(
      SupportedLocales.ESTONIA,
      INVOICE_ID) +
      """([.]{0,1})([\s]{0,})([:]{0,1})([\s]{0,})([^\s]{1,})""").r)
  }

  override def isValueAllowed(value: Any): Boolean = {
    EstIBANCorrectR
      .findFirstIn(value.asInstanceOf[String])
      .isEmpty &&
      TwoOrMoreDigitsR
        .findFirstIn(value.asInstanceOf[String])
        .nonEmpty
  }

  override def parseValue(raw: String): Any = StringUtils.normalizeSpace(raw)

} 
开发者ID:kveskimae,项目名称:pdfalg,代码行数:41,代码来源:EstonianInvoiceIDFinder.scala


示例4: Playlist

//设置package包名称以及导入依赖的类
package model

import org.apache.commons.lang3.StringUtils

case class Playlist (name: String, id: Option[String] = None, songs: Seq[Song] = Seq.empty) {
  def hasSong(songId: String): Boolean = {
    !songId.isEmpty && songs.exists( _.id.getOrElse("") == songId)
  }
  def hasSong(song: Song): Boolean = {
    songs.exists{ s =>
      val titleRank = StringUtils.getJaroWinklerDistance(song.title, s.title)
      val artistRank = StringUtils.getJaroWinklerDistance(song.artist, s.artist)
      titleRank >= 0.75 && artistRank >= 0.75
    }
  }
} 
开发者ID:DenF923,项目名称:radio-playlist-service,代码行数:17,代码来源:Playlist.scala


示例5: UtilsTest

//设置package包名称以及导入依赖的类
package org.mentha.tools.xsd

import org.apache.commons.lang3.StringUtils
import org.scalatest._


class UtilsTest extends FlatSpec with Matchers {

  private def testFlatExtend(values: String*) = {
    def id(el: String): Int = el.hashCode
    Utils.flatExtend[String, Int](
      stream = Stream(values:_*),
      visited = Set(),
      extend = (el, v) => Option(StringUtils.trimToNull(el))
        .map { el => StringUtils.trimToNull(el.substring(1)) }
        .filter { el => !v.contains(id(el)) }
        .toSeq,
      id = id
    )
  }

  behavior of "flatExtend method"

  it should "add next level to both `result` and `visited`" in {
    val (n, v) = testFlatExtend("00", "01", "02")
    v should contain theSameElementsAs {
      Seq("0", "1", "2") map { x => x.hashCode }
    }
    n should contain theSameElementsAs {
      Seq("0", "1", "2")
    }
  }

  it should "keep the original stream order for flat source" in {
    val (n, _) = testFlatExtend("00", "01", "02")
    n should contain inOrder("0", "1", "2")
  }

  it should "keep the original stream order for repetitive source" in {
    val (n, _) = testFlatExtend("00", "01", "10", "20")
    n should contain inOrder("0", "1")
  }


  behavior of "filter method"

  it should "keep" in {

  }



} 
开发者ID:zhuj,项目名称:mentha-xsd-graphml,代码行数:54,代码来源:UtilsTest.scala


示例6: HumanPhenotypesToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.human

import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab
import org.phenoscape.kb.ingest.util.Vocab._
import org.phenoscape.kb.ingest.util.OBOUtil
import org.phenoscape.kb.ingest.util.OntUtil
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary

object HumanPhenotypesToOWL {

  val factory = OWLManager.getOWLDataFactory
  val rdfsLabel = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI)
  val human = factory.getOWLNamedIndividual(Vocab.HUMAN)

  def convert(phenotypeData: Source): Set[OWLAxiom] = phenotypeData.getLines.drop(1).flatMap(translate).toSet[OWLAxiom]

  def translate(phenotypeLine: String): Set[OWLAxiom] = {
    val items = phenotypeLine.split("\t")
    val axioms = mutable.Set.empty[OWLAxiom]
    val phenotype = OntUtil.nextIndividual()
    axioms.add(phenotype Type AnnotatedPhenotype)
    axioms.add(Declaration(phenotype))
    val phenotypeID = StringUtils.stripToNull(items(3))
    val phenotypeClass = Class(OBOUtil.iriForTermID(phenotypeID))
    axioms.add(phenotype Type phenotypeClass)
    val geneIRI = IRI.create("http://www.ncbi.nlm.nih.gov/gene/" + StringUtils.stripToNull(items(0)))
    val geneSymbol = StringUtils.stripToNull(items(1))
    axioms.add(geneIRI Annotation (rdfsLabel, geneSymbol))
    val gene = Individual(geneIRI)
    axioms.add(gene Type Gene)
    axioms.add(Declaration(gene))
    axioms.add(phenotype Fact (associated_with_gene, gene))
    axioms.add(phenotype Fact (associated_with_taxon, human))
    axioms.toSet
  }
}

//  object test extends App{
//    println("test");
//  } 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:50,代码来源:HumanPhenotypesToOWL.scala


示例7: ZFINGeneticMarkersToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.zfin

import scala.collection.JavaConversions._
import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab._
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary

object ZFINGeneticMarkersToOWL {

  val factory = OWLManager.getOWLDataFactory
  val rdfsLabel = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI)
  val hasExactSynonym = factory.getOWLAnnotationProperty(HAS_EXACT_SYNONYM)

  def convert(markersData: Source): Set[OWLAxiom] = markersData.getLines.flatMap(translate).toSet[OWLAxiom]

  def translate(line: String): Set[OWLAxiom] = {
    val items = line.split("\t")
    if (items(3) != "GENE") {
      Set.empty
    } else {
      val axioms = mutable.Set.empty[OWLAxiom]
      val geneID = StringUtils.stripToNull(items(0))
      val geneSymbol = StringUtils.stripToNull(items(1))
      val geneFullName = StringUtils.stripToNull(items(2))
      val geneIRI = IRI.create("http://zfin.org/" + geneID)
      val gene = Individual(geneIRI)
      axioms.add(Declaration(gene))
      axioms.add(gene Type Gene)
      axioms.add(geneIRI Annotation (rdfsLabel, geneSymbol))
      axioms.add(geneIRI Annotation (hasExactSynonym, geneFullName))
      axioms.toSet
    }
  }

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:44,代码来源:ZFINGeneticMarkersToOWL.scala


示例8: ZFINPreviousGeneNamesToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.zfin

import scala.collection.JavaConversions._
import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom

object ZFINPreviousGeneNamesToOWL {

  val factory = OWLManager.getOWLDataFactory
  val hasRelatedSynonym = factory.getOWLAnnotationProperty(Vocab.HAS_RELATED_SYNONYM)

  def convert(data: Source): Set[OWLAxiom] = data.getLines.flatMap(translate).toSet

  def translate(line: String): Set[OWLAxiom] = {
    val items = line.split("\t")
    if (!items(0).startsWith("ZDB-GENE")) {
      Set.empty
    } else {
      val axioms = mutable.Set.empty[OWLAxiom]
      val geneID = StringUtils.stripToNull(items(0))
      val previousName = StringUtils.stripToNull(items(3))
      val geneIRI = IRI.create("http://zfin.org/" + geneID)
      val gene = Individual(geneIRI)
      axioms.add(Declaration(gene))
      axioms.add(geneIRI Annotation (hasRelatedSynonym, previousName))
      axioms.toSet
    }
  }

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:39,代码来源:ZFINPreviousGeneNamesToOWL.scala


示例9: MGIExpressionToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.mgi

import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab
import org.phenoscape.kb.ingest.util.Vocab._
import org.phenoscape.kb.ingest.util.OBOUtil
import org.phenoscape.kb.ingest.util.OntUtil
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.OWLAxiom

object MGIExpressionToOWL {

  val factory = OWLManager.getOWLDataFactory
  val mouse = Individual(Vocab.MOUSE)
  val rdfsLabel = factory.getRDFSLabel

  def convert(expressionData: Source): Set[OWLAxiom] =
    expressionData.getLines.drop(1).flatMap(translate).toSet[OWLAxiom] +
      (mouse Annotation (rdfsLabel, "Mus musculus"))

  def translate(expressionLine: String): Set[OWLAxiom] = {
    val items = expressionLine.split("\t", -1)
    if (StringUtils.stripToNull(items(5)) == "Absent") {
      Set.empty
    } else {
      val axioms = mutable.Set.empty[OWLAxiom]
      val expression = OntUtil.nextIndividual()
      axioms.add(Declaration(expression))
      axioms.add(expression Type GeneExpression)
      val structureID = StringUtils.stripToNull(items(4))
      val structureType = Class(OBOUtil.mgiAnatomyIRI(structureID))
      val punnedStructure = Individual(structureType.getIRI)
      axioms.add(Declaration(punnedStructure))
      axioms.add(expression Fact (occurs_in, punnedStructure))
      val geneIRI = MGIGeneticMarkersToOWL.getGeneIRI(StringUtils.stripToNull(items(1)))
      val gene = Individual(geneIRI)
      axioms.add(Declaration(gene))
      axioms.add(expression Fact (associated_with_gene, gene))
      axioms.add(expression Fact (associated_with_taxon, mouse))
      val publicationID = StringUtils.stripToNull(items(10))
      val publication = Individual(OBOUtil.mgiReferenceIRI(publicationID))
      axioms.add(expression Fact (dcSource, publication))
      axioms.toSet
    }
  }

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:53,代码来源:MGIExpressionToOWL.scala


示例10: MGIPhenotypesToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.mgi

import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab
import org.phenoscape.kb.ingest.util.Vocab._
import org.phenoscape.kb.ingest.util.OBOUtil
import org.phenoscape.kb.ingest.util.OntUtil
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.model.OWLAxiom

object MGIPhenotypesToOWL {

  val mouse = Individual(Vocab.MOUSE)

  def convert(phenotypeData: Source): Set[OWLAxiom] = phenotypeData.getLines.drop(1).flatMap(translate).toSet[OWLAxiom]

  def translate(expressionLine: String): Set[OWLAxiom] = {
    val items = expressionLine.split("\t", -1)
    val axioms = mutable.Set.empty[OWLAxiom]
    val phenotype = OntUtil.nextIndividual()
    axioms.add(phenotype Type AnnotatedPhenotype)
    axioms.add(Declaration(phenotype))
    val phenotypeID = StringUtils.stripToNull(items(10))
    val phenotypeClass = Class(OBOUtil.iriForTermID(phenotypeID))
    axioms.add(phenotype Type phenotypeClass)
    val geneIRI = MGIGeneticMarkersToOWL.getGeneIRI(StringUtils.stripToNull(items(0)))
    val gene = Individual(geneIRI)
    axioms.add(Declaration(gene))
    axioms.add(phenotype Fact (associated_with_gene, gene))
    axioms.add(phenotype Fact (associated_with_taxon, mouse))
    val publicationID = StringUtils.stripToNull(items(11))
    val publication = Individual(OBOUtil.mgiReferenceIRI(publicationID))
    axioms.add(phenotype Fact (dcSource, publication))
    axioms.toSet
  }

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:42,代码来源:MGIPhenotypesToOWL.scala


示例11: MGIAnatomyBridgeToEMAPA

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.mgi

import java.io.File

import scala.collection.JavaConversions._
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.OBOUtil
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.model.OWLOntology

object MGIAnatomyBridgeToEMAPA {

  val ontologyName = "http://purl.org/phenoscape/mgi/anatomy.owl"
  val manager = OWLManager.createOWLOntologyManager()

  def convert(mappings: Source): OWLOntology = {
    val axioms = mappings.getLines.map(translate(_)).flatten.toSet[OWLAxiom]
    manager.createOntology(axioms, IRI.create(ontologyName))
  }

  def translate(mapping: String): Set[OWLAxiom] = {
    val items = mapping.split("\t", -1)
    val mgiTerm = Class(OBOUtil.mgiAnatomyIRI(StringUtils.stripToNull(items(0))))
    val emapaTerm = Class(OBOUtil.iriForTermID(StringUtils.stripToNull(items(1))))
    Set(
      Declaration(mgiTerm),
      Declaration(emapaTerm),
      mgiTerm SubClassOf emapaTerm)
  }

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:38,代码来源:MGIAnatomyBridgeToEMAPA.scala


示例12: MGIGeneticMarkersToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.mgi

import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab._
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary

object MGIGeneticMarkersToOWL {

  val factory = OWLManager.getOWLDataFactory
  val rdfsLabel = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI)
  val hasExactSynonym = factory.getOWLAnnotationProperty(HAS_EXACT_SYNONYM)
  val hasRelatedSynonym = factory.getOWLAnnotationProperty(HAS_RELATED_SYNONYM)

  def convert(markersData: Source): Set[OWLAxiom] = markersData.getLines.flatMap(translate).toSet[OWLAxiom]

  def translate(line: String): Set[OWLAxiom] = {
    val items = line.split("\t")
    if (items(9) != "Gene") {
      Set.empty
    } else {
      val axioms = mutable.Set.empty[OWLAxiom]
      val geneID = StringUtils.stripToNull(items(0))
      val geneSymbol = StringUtils.stripToNull(items(6))
      val geneFullName = StringUtils.stripToNull(items(8))
      val geneIRI = getGeneIRI(geneID)
      val gene = Individual(geneIRI)
      axioms.add(Declaration(gene))
      axioms.add(gene Type Gene)
      axioms.add(geneIRI Annotation (rdfsLabel, geneSymbol))
      axioms.add(geneIRI Annotation (hasExactSynonym, geneFullName))
      if (items.size > 11) {
        val synonymsField = StringUtils.stripToEmpty(items(11))
        synonymsField.split("\\|").foreach(synonym => axioms.add(geneIRI Annotation (hasRelatedSynonym, synonym)))
      }
      axioms.toSet
    }
  }

  def getGeneIRI(geneID: String): IRI = IRI.create("http://www.informatics.jax.org/marker/" + geneID)

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:50,代码来源:MGIGeneticMarkersToOWL.scala


示例13: XenbaseGenesToOWL

//设置package包名称以及导入依赖的类
package org.phenoscape.kb.ingest.xenbase

import scala.collection.mutable
import scala.io.Source

import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.Vocab._
import org.phenoscape.scowl.Functional._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary

object XenbaseGenesToOWL {

  val factory = OWLManager.getOWLDataFactory
  val rdfsLabel = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI())
  val hasExactSynonym = factory.getOWLAnnotationProperty(HAS_EXACT_SYNONYM)
  val hasRelatedSynonym = factory.getOWLAnnotationProperty(HAS_RELATED_SYNONYM)

  def convert(markersData: Source): Set[OWLAxiom] = markersData.getLines.flatMap(translate).toSet[OWLAxiom]

  def translate(line: String): Set[OWLAxiom] = {
    val items = line.split("\t")
    val axioms = mutable.Set[OWLAxiom]()
    val geneID = StringUtils.stripToNull(items(0))
    val geneSymbol = StringUtils.stripToNull(items(1))
    val geneFullName = StringUtils.stripToNull(items(2))
    val geneIRI = getGeneIRI(geneID)
    val gene = Individual(geneIRI)
    axioms.add(Declaration(gene))
    axioms.add(gene Type Gene)
    axioms.add(geneIRI Annotation (rdfsLabel, geneSymbol))
    axioms.add(geneIRI Annotation (hasExactSynonym, geneFullName))
    if (items.size > 4) {
      val synonymsField = StringUtils.stripToEmpty(items(4))
      synonymsField.split("\\|").foreach(synonym => axioms.add(geneIRI Annotation (hasRelatedSynonym, synonym)))
    }
    axioms.toSet
  }

  def getGeneIRI(geneID: String): IRI = IRI.create("http://xenbase.org/" + geneID)

} 
开发者ID:phenoscape,项目名称:phenoscape-kb-ingest,代码行数:46,代码来源:XenbaseGenesToOWL.scala


示例14: EmptinessProfiler

//设置package包名称以及导入依赖的类
package io.gzet.profilers.field

import io.gzet.profilers.Utils
import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.Dataset

import scalaz.Scalaz._

case class EmptinessProfiler() {

  def profile(df: Dataset[Array[String]]): Dataset[EmptinessReport] = {

    import df.sparkSession.implicits._

    val features = Utils.buildColumns(df)

    features.map(f => (f.idx, StringUtils.isNotEmpty(f.value))).groupByKey({ case (column, isNotEmpty) =>
      (column, isNotEmpty)
    }).count().map({ case ((column, isNotEmpty), count) =>
      (column, Map(isNotEmpty -> count))
    }).groupByKey({ case (column, map) =>
      column
    }).reduceGroups({ (v1, v2) =>
      (v1._1, v1._2 |+| v2._2)
    }).map({ case (col, (_, map)) =>
      val emptiness = map.getOrElse(false, 0L) / (map.getOrElse(true, 0L) + map.getOrElse(false, 0L)).toDouble
      EmptinessReport(
        col,
        emptiness
      )
    })

  }

}

case class EmptinessReport(
                            field: Int,
                            metricValue: Double
                          ) 
开发者ID:PacktPublishing,项目名称:Mastering-Spark-for-Data-Science,代码行数:41,代码来源:EmptinessProfiler.scala


示例15: CustomAuthorizer

//设置package包名称以及导入依赖的类
package controllers.auth

import org.apache.commons.lang3.StringUtils
import org.pac4j.core.authorization.authorizer.ProfileAuthorizer
import org.pac4j.core.context.WebContext
import org.pac4j.core.profile.CommonProfile

class CustomAuthorizer extends ProfileAuthorizer[CommonProfile] {

  def isAuthorized(context: WebContext, profiles: java.util.List[CommonProfile]): Boolean = {
    return isAnyAuthorized(context, profiles)
  }

  def isProfileAuthorized(context: WebContext, profile: CommonProfile): Boolean = {
    if (profile == null) {
      false
    } else {
      StringUtils.startsWith (profile.getUsername, "jle")
    }
  }
} 
开发者ID:kristiankime,项目名称:play-pac4j-slick,代码行数:22,代码来源:CustomAuthorizer.scala


示例16: ValidationUtils

//设置package包名称以及导入依赖的类
package utils

import java.time.LocalDate

import models.DateComponents
import org.apache.commons.lang3.StringUtils
import play.api.data.format.Formatter
import play.api.data.validation.{Constraint, Invalid, Valid, ValidationError}
import play.api.data.{FieldMapping, FormError, Forms}

import scala.util.{Failure, Success}

object ValidationUtils {

  implicit val mandatoryBooleanFormatter = new Formatter[Boolean] {

    def bind(key: String, data: Map[String, String]) = {
      Right(data.getOrElse(key, "")).right.flatMap {
        case "true" => Right(true)
        case "false" => Right(false)
        case _ => Left(Seq(FormError(key, s"$key.error.boolean", Nil)))
      }
    }

    def unbind(key: String, value: Boolean) = Map(key -> value.toString)
  }

  val mandatoryBoolean: FieldMapping[Boolean] = Forms.of[Boolean]
  val notBlank: (String) => Boolean = StringUtils.isNotBlank

  def unconstrained[T] = Constraint[T] { (t: T) => Valid }

  def inRange[T](minValue: T, maxValue: T, errorCode: String = "")(implicit ordering: scala.math.Ordering[T]): Constraint[T] =
    Constraint[T] { (t: T) =>
      assert(ordering.compare(minValue, maxValue) < 0, "min bound must be less than max bound")
      (ordering.compare(t, minValue).signum, ordering.compare(t, maxValue).signum) match {
        case (1, -1) | (0, _) | (_, 0) => Valid
        case (_, 1) => Invalid(ValidationError(s"error$errorCode.range.above", maxValue))
        case (-1, _) => Invalid(ValidationError(s"error$errorCode.range.below", minValue))
      }
    }

  def validDate(constraint: Constraint[LocalDate] = unconstrained) = Constraint[DateComponents] {
    (dcs: DateComponents) =>
      DateComponents.toLocalDate(dcs) match {
        case Failure(_) => Invalid(ValidationError("error.date.invalid", dcs))
        case Success(localDate) => constraint(localDate)
      }
  }

  def optionallyMatchingPattern(regex: String): Constraint[String] =
    Constraint[String] { s: String =>
      Option(s) match {
        case None | Some("") => Valid
        case _ if s.matches(regex) => Valid
        case _ => Invalid(ValidationError("error.string.pattern", s))
      }
    }

} 
开发者ID:PeterPerhac,项目名称:pocs,代码行数:61,代码来源:ValidationUtils.scala


示例17: Driver

//设置package包名称以及导入依赖的类
package rnrb.driver

import java.util.concurrent.TimeUnit

import org.apache.commons.lang3.StringUtils
import org.openqa.selenium.WebDriver
import rnrb.driver.Browser._

import scala.util.Try

object Driver extends Driver

class Driver {
  val systemProperties = System.getProperties

  val webDriver: WebDriver = {
    sys addShutdownHook {
      Try(webDriver.quit())
    }

    val selectedDriver = if (!StringUtils.isEmpty(System.getProperty("browser"))) {
      val targetBrowser = systemProperties.getProperty("browser").toLowerCase
      targetBrowser match {

        case "firefox"                  => createFirefoxDriver()
        case "chrome"                   => createChromeDriver()
        case "phantomjs"                => createPhantomJsDriver()
        case "gecko"                    => createGeckoDriver()
        case _                          => throw new IllegalArgumentException(s"Browser type not recognised")
      }
    }
    else {
      createFirefoxDriver()
    }
    selectedDriver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS)
    selectedDriver
  }
} 
开发者ID:hmrc,项目名称:inheritance-tax-residence-nil-rate-band-calculator-acceptance-tests,代码行数:39,代码来源:Driver.scala


示例18: ElasticDownloadUrlUtils

//设置package包名称以及导入依赖的类
package io.grhodes.sbt.elasticsearch

import java.net.{MalformedURLException, URL}

import org.apache.commons.lang3.StringUtils

private[elasticsearch] object ElasticDownloadUrlUtils {

  private val URLS = Map(
    "1." -> "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-{VERSION}.zip",
    "2." -> "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/{VERSION}/elasticsearch-{VERSION}.zip",
    "5." -> "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{VERSION}.zip"
  )

  def urlFromVersion(elasticVersion: String) = {
    val elsDownloadUrl = URLS.collectFirst {
      case (prefix, url) if elasticVersion.startsWith(prefix) => url
    }.getOrElse {
      throw new IllegalArgumentException("Invalid version: " + elasticVersion)
    }

    try {
      new URL(StringUtils.replace(elsDownloadUrl, "{VERSION}", elasticVersion))
    } catch {
      case e: MalformedURLException => throw new RuntimeException(e)
    }
  }

} 
开发者ID:grahamar,项目名称:sbt-elasticsearch,代码行数:30,代码来源:ElasticDownloadUrlUtils.scala


示例19: ConfigurationHelper

//设置package包名称以及导入依赖的类
package com.blackducksoftware.integration.scala

import sbt._
import org.apache.commons.lang3.StringUtils

class ConfigurationHelper (logger : ScalaLogger, includedConfigurations : String) {
    
    def getRequestedConfigurations() : Set[String] = {
        logger.info(s"User includedConfigurations : $includedConfigurations")
        var requestedConfigurations : Set[String] = Set()
        if(includedConfigurations.contains(",")){
          includedConfigurations.split(",").foreach(configuration => requestedConfigurations += configuration.toUpperCase())
        } else {
          requestedConfigurations += includedConfigurations.toUpperCase()
        }
        requestedConfigurations
    }
    
    def shouldIncludeConfiguration(configuration : String, requestedConfigurations : Set[String]) : Boolean = {
        // include all scopes if none were requested
        if (requestedConfigurations == null || requestedConfigurations.isEmpty) {
            return true;
        }
        if (StringUtils.isBlank(configuration)) {
            return false;
        }
        requestedConfigurations.contains(configuration.toUpperCase())
    }
    
} 
开发者ID:blackducksoftware,项目名称:hub-sbt-plugin,代码行数:31,代码来源:ConfigurationHelper.scala


示例20: RegexSelector

//设置package包名称以及导入依赖的类
package haishu.crawler.selector

import java.util.regex.{Pattern, PatternSyntaxException}

import org.apache.commons.lang3.StringUtils

class RegexSelector(pattern: Pattern, group: Int = 1) extends Selector {

  override def select(text: String): String = selectGroup(text).get(group)

  override def selectSeq(text: String): Seq[String] = {
    selectGroupSeq(text).map(_.get(group))
  }

  def selectGroup(text: String): RegexResult = {
    val matcher = pattern.matcher(text)
    if (matcher.find()) {
      val groups = Array.tabulate(matcher.groupCount() + 1)(matcher.group)
      RegexResult(groups)
    } else RegexResult.empty
  }

  def selectGroupSeq(text: String): Seq[RegexResult] = {
    val matcher = pattern.matcher(text)
    var resultSeq: Seq[RegexResult] = Vector()
    while (matcher.find()) {
      val groups = Array.tabulate(matcher.groupCount() + 1)(matcher.group)
      resultSeq :+= RegexResult(groups)
    }
    resultSeq
  }
}

object RegexSelector {

  def apply(expr: String, group: Int): RegexSelector = new RegexSelector(compileRegex(expr), group)

  def apply(expr: String): RegexSelector = {
    val p = compileRegex(expr)
    val group = if (p.matcher("").groupCount() == 0) 0 else 1
    new RegexSelector(p, group)
  }

  private def compileRegex(expr: String): Pattern = {
    if (StringUtils.isBlank(expr)) throw new IllegalArgumentException("regex must not be empty")

    try {
      Pattern.compile(expr, Pattern.DOTALL | Pattern.CASE_INSENSITIVE)
    } catch {
      case e: PatternSyntaxException =>
        throw new IllegalArgumentException("invalid regex " + expr, e)
    }
  }

} 
开发者ID:hualongdata,项目名称:hl-crawler,代码行数:56,代码来源:RegexSelector.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Serializable类代码示例发布时间:2022-05-23
下一篇:
Scala StaticRoutesGenerator类代码示例发布时间: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