当前位置: 首页>>代码示例>>Scala>>正文


Scala StringUtils类代码示例

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


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


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