<commit_before>package de.htwg.zeta.parser.shape.parser

import de.htwg.zeta.parser.shape.parsetree.EdgeAttributes.{Placing, Target}
import de.htwg.zeta.parser.{Collector, UniteParsers, UnorderedParser}
import de.htwg.zeta.parser.shape.parsetree.EdgeParseTree
import de.htwg.zeta.parser.shape.parsetree.GeoModelAttributes.{Position, Style}
import de.htwg.zeta.parser.shape.parsetree.GeoModelParseTrees.GeoModelParseTree
import de.htwg.zeta.server.generator.parser.CommonParserMethods

object EdgeParser extends CommonParserMethods with UniteParsers with UnorderedParser {

  def edge: Parser[EdgeParseTree] = {
    val attributes = unordered(once(target), min(1, placing))
    ("edge" ~> ident) ~ ("for" ~> conceptConnection) ~ (leftBrace ~> attributes <~ rightBrace) ^^ { parseResult =>
      val edge ~ conceptConnection ~ attributes = parseResult
      val attrs = Collector(attributes)
      EdgeParseTree(edge,
        conceptConnection,
        attrs.![Target],
        attrs.*[Placing])
    }
  }

  private def target: Parser[Target] = {
    "target" ~> colon ~> ident ^^ {
      Target
    }
  }

  private def placing: Parser[Placing] = {
    val attributes = unordered(optional(style), once(position), once(geoModel))
    "placing" ~> leftBrace ~> attributes <~ rightBrace ^^ { parseResult =>
      val attrs = Collector(parseResult)
      Placing(
        attrs.?[Style],
        attrs.![Position],
        attrs.![GeoModelParseTree]
      )
    }
  }

  private def style = include(GeoModelAttributeParser.style)

  private def position = include(GeoModelAttributeParser.position)

  private def geoModel = include(GeoModelParser.geoModel)

  // Concept connections can be addressed with java / scala object syntax
  // e.g.: Knoten.hatKind
  private def conceptConnection = "\\w+(.\\w+)*".r

}<commit_msg>#75 adjust regex<commit_after>package de.htwg.zeta.parser.shape.parser

import de.htwg.zeta.parser.shape.parsetree.EdgeAttributes.{Placing, Target}
import de.htwg.zeta.parser.{Collector, UniteParsers, UnorderedParser}
import de.htwg.zeta.parser.shape.parsetree.EdgeParseTree
import de.htwg.zeta.parser.shape.parsetree.GeoModelAttributes.{Position, Style}
import de.htwg.zeta.parser.shape.parsetree.GeoModelParseTrees.GeoModelParseTree
import de.htwg.zeta.server.generator.parser.CommonParserMethods

object EdgeParser extends CommonParserMethods with UniteParsers with UnorderedParser {

  def edge: Parser[EdgeParseTree] = {
    val attributes = unordered(once(target), min(1, placing))
    ("edge" ~> ident) ~ ("for" ~> conceptConnection) ~ (leftBrace ~> attributes <~ rightBrace) ^^ { parseResult =>
      val edge ~ conceptConnection ~ attributes = parseResult
      val attrs = Collector(attributes)
      EdgeParseTree(edge,
        conceptConnection,
        attrs.![Target],
        attrs.*[Placing])
    }
  }

  private def target: Parser[Target] = {
    "target" ~> colon ~> ident ^^ {
      Target
    }
  }

  private def placing: Parser[Placing] = {
    val attributes = unordered(optional(style), once(position), once(geoModel))
    "placing" ~> leftBrace ~> attributes <~ rightBrace ^^ { parseResult =>
      val attrs = Collector(parseResult)
      Placing(
        attrs.?[Style],
        attrs.![Position],
        attrs.![GeoModelParseTree]
      )
    }
  }

  private def style = include(GeoModelAttributeParser.style)

  private def position = include(GeoModelAttributeParser.position)

  private def geoModel = include(GeoModelParser.geoModel)

  // Concept connections can be addressed with java / scala object syntax
  // e.g.: Knoten.hatKind
  private def conceptConnection = "\\w+.\\w+".r

}
{'fraction_non_alphanumeric': 0.11929631665750412, 'fraction_numerical': 0.0010995052226498076, 'mean_word_length': 3.794466403162055, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5453913', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1110, 'n_words': 224}