-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ParallelTreeBank and moved getName and setName methods from Par…
…seTreeDrawable.
- Loading branch information
Olcay Taner YILDIZ
committed
May 17, 2022
1 parent
f7b8e6c
commit ed8547c
Showing
8 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Olcay Taner YILDIZ on 17.05.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
open class ParallelTreeBank{ | ||
|
||
public var fromTreeBank, toTreeBank : TreeBank | ||
|
||
init(folder1: String, folder2: String){ | ||
fromTreeBank = TreeBank(folder: folder1) | ||
toTreeBank = TreeBank(folder: folder2) | ||
removeDifferentTrees() | ||
} | ||
|
||
init(folder1: String, folder2: String, pattern: String){ | ||
fromTreeBank = TreeBank(folder: folder1, pattern: pattern) | ||
toTreeBank = TreeBank(folder: folder2, pattern: pattern) | ||
removeDifferentTrees() | ||
} | ||
|
||
public func removeDifferentTrees(){ | ||
var i : Int = 0 | ||
var j : Int = 0 | ||
while (i < fromTreeBank.size() && j < toTreeBank.size()){ | ||
if fromTreeBank.get(index: i).getName() < toTreeBank.get(index: j).getName(){ | ||
fromTreeBank.removeTree(index: i); | ||
} else { | ||
if toTreeBank.get(index: j).getName() > fromTreeBank.get(index: i).getName(){ | ||
toTreeBank.removeTree(index: j); | ||
} else { | ||
i = i + 1 | ||
j = j + 1 | ||
} | ||
} | ||
} | ||
while (i < fromTreeBank.size()){ | ||
fromTreeBank.removeTree(index: i); | ||
} | ||
while (j < toTreeBank.size()){ | ||
toTreeBank.removeTree(index: j); | ||
} | ||
} | ||
|
||
public func size() -> Int{ | ||
return fromTreeBank.size() | ||
} | ||
|
||
public func fromTree(index: Int) -> ParseTree{ | ||
return fromTreeBank.get(index: index) | ||
} | ||
|
||
public func toTree(index: Int) -> ParseTree{ | ||
return toTreeBank.get(index: index) | ||
} | ||
|
||
public func getFromTreeBank() -> TreeBank{ | ||
return fromTreeBank | ||
} | ||
|
||
public func getToTreeBank() -> TreeBank{ | ||
return toTreeBank | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import XCTest | ||
@testable import ParseTree | ||
import ParseTree | ||
|
||
final class ParallelTreeBankTest: XCTestCase { | ||
|
||
func testSize() { | ||
let thisSourceFile = URL(fileURLWithPath: #file) | ||
let thisDirectory = thisSourceFile.deletingLastPathComponent() | ||
let treeBank1 = ParallelTreeBank(folder1: thisDirectory.appendingPathComponent("trees").path, folder2: thisDirectory.appendingPathComponent("trees2").path) | ||
XCTAssertEqual(3, treeBank1.size()) | ||
} | ||
|
||
static var allTests = [ | ||
("testExample1", testSize), | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
( (S (NP-SBJ (DT The) (NNP Ways) (CC and) (NNP Means) (NNP Committee)) (VP (MD will) (VP (VB hold) (NP (NP (DT a) (NN hearing)) (PP (IN on) (NP (DT the) (NN bill)) ) ) (NP-TMP (IN next) (NNP Tuesday)) ) ) (. .)) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
( (S (NP-SBJ-1 (PRP We)) (VP (VBP 're) (VP (IN about) (S (NP-SBJ (-NONE- *-1)) (VP (TO to) (VP (VB see) (SBAR (IN if) (S (NP-SBJ (NN advertising)) (VP (VBZ works))) ) ) ) ) ) ) (. .)) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
( (NP (NN Ad) (NNS Notes) (: ...) (. .)) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
( (NP-HLN (NNP ARNOLD) (NNP ADVERTISING) (: :)) ) |