Skip to content

Commit b542146

Browse files
author
David Blackman
committed
why did I ever decide to use tabs?
1 parent 4b61d07 commit b542146

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

data/custom/name-deletes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
2147714|Syd
33
1273294|New Delhi
44
5106834|Albania
5+
5117472|Flushing

indexer/src/main/scala/importers/geonames/GeonamesParser.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,13 @@ class GeonamesParser(
571571
val lines = scala.io.Source.fromFile(new File(filename)).getLines
572572

573573
lines.foreach(line => {
574-
val parts = line.split("\t").toList
574+
val parts = line.split("[\t ]").toList
575+
575576
for {
576577
gid <- parts.lift(0)
577-
lang <- parts.lift(1).flatMap(_.split("\\|").lift(0))
578-
name <- parts.lift(1).flatMap(_.split("\\|").lift(1))
578+
val rest = parts.drop(1).mkString(" ")
579+
lang <- rest.split("\\|").lift(0)
580+
name <- rest.split("\\|").lift(1)
579581
} {
580582
val records = store.getById(GeonamesId(gid.toLong)).toList
581583
records match {
@@ -586,9 +588,11 @@ class GeonamesParser(
586588
if (dn.lang == lang) {
587589
if (dn.name == name) {
588590
foundName = true
589-
DisplayName(dn.lang, dn.name, dn.flags | FeatureNameFlags.PREFERRED.getValue())
591+
val newName = DisplayName(dn.lang, dn.name, dn.flags | FeatureNameFlags.PREFERRED.getValue())
592+
newName
590593
} else {
591-
DisplayName(dn.lang, dn.name, dn.flags ^ FeatureNameFlags.PREFERRED.getValue())
594+
val newName = DisplayName(dn.lang, dn.name, dn.flags ^ FeatureNameFlags.PREFERRED.getValue())
595+
newName
592596
}
593597
} else {
594598
dn

0 commit comments

Comments
 (0)