Skip to content

Commit

Permalink
Upadate Readme and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petertretyakov committed Jul 16, 2020
1 parent e5b46e3 commit efcccbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -83,7 +83,7 @@ You can create your own schema JSON file with the following structure:
}
}
```
- `name` (*Optional*) — used inly to define your schema.
- `name` (*Optional*) — readable title for schema. "Custom" by default.
- `mapping` (**Required**) — Dictionary<Cyrillic letter, Latin representation>. Only one character per key allowed, keys with more than one character will be ommited during transliteration. To define custom transliteration logic for sequence of characters use `prev_mapping`, `next_mapping` and `ending_mapping`.
- `prev_mapping` (*Optional*) — Dictionary<1 or 2 cyrillic letters, Latin representation>. Mapping for letters with respect to previous sibling. One letter used for transliteration in beginning of words. According to this schema any `е` character in beginning of word or after `а` character will be transliterated to `ye`.
- `next_mapping` (*Optional*) — Dictionary<2 cyrillic letters, Latin representation>. Mapping for letters with respect to next sibling. According to this schema any `ъ` character before `а` and `и` characters will be transliterated to `y`.
Expand All @@ -102,7 +102,7 @@ For example, if you want to transliterate sequence of two cyrillic characters in
}
```

To use your schema with `Iuliia` initialize in with schema URL
To use your schema with `Iuliia` initialize it with schema URL

```swift
let iuliia = try! Iuliia(schemaURL: /path/to/your/custom/schema.json)
Expand Down
12 changes: 6 additions & 6 deletions Tests/IuliiaTests/IuliiaTests.swift
Expand Up @@ -12,15 +12,15 @@ import XCTest
final class IuliiaTests: XCTestCase {
func testSamples() throws {
for name in Schema.Name.allCases {
let iuliia = try Iuliia(schema: name)
let iuliia = try Iuliia(name: name)

let url = Bundle.module.url(forResource: name.rawValue, withExtension: "json")!
let data = try Data(contentsOf: url, options: .mappedIfSafe)
let decoder = JSONDecoder()
let samples = try decoder.decode(Samples.self, from: data)

for item in samples.items {
let result = iuliia.transliterate(item.source)
let result = iuliia.translate(item.source)

print("SCHEMA : \(iuliia.schema.name)")
print("SOURCE : \(item.source)")
Expand All @@ -34,13 +34,13 @@ final class IuliiaTests: XCTestCase {
}

func testSingleUppercasedLetter() throws {
let iuliia = try Iuliia(schema: .gost52290)
XCTAssertTrue(iuliia.transliterate("Ё КРЁ МЯКОЁ123") == "YO KRYE MYAKOYO123")
let iuliia = try Iuliia(name: .gost52290)
XCTAssertTrue(iuliia.translate("Ё КРЁ МЯКОЁ123") == "YO KRYE MYAKOYO123")
}

func testTabsAndNewlines() throws {
let iuliia = try Iuliia(schema: .mosmetro)
XCTAssertTrue(iuliia.transliterate("\n\tМосметро\tОдин\n\t") == "\n\tMosmetro\tOdin\n\t")
let iuliia = try Iuliia(name: .mosmetro)
XCTAssertTrue(iuliia.translate("\n\tМосметро\tОдин\n\t") == "\n\tMosmetro\tOdin\n\t")
}

static var allTests = [
Expand Down

0 comments on commit efcccbf

Please sign in to comment.