Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Strack
committed
Jul 28, 2019
1 parent
e27f28d
commit 51db6f1
Showing
14 changed files
with
17,669 additions
and
6,498 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,76 @@ | ||
package eldarin.parser; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStreamWriter; | ||
import java.io.PrintWriter; | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class TranslationParser { | ||
|
||
public static void main(String[] args) throws Exception { | ||
List<List<String>> baseList = readFile("/Users/pfstrack/Desktop/base-polish.txt"); | ||
Map<String, List<String>> baseMap = new HashMap<String, List<String>>(); | ||
for (List<String> row : baseList) { | ||
baseMap.put(row.get(0), row); | ||
} | ||
List<List<String>> export = readFile("/Users/pfstrack/Desktop/export-polish.txt"); | ||
for (List<String> row : export) { | ||
List<String> baseRow = baseMap.get(row.get(0)); | ||
if (baseRow != null) { | ||
row.add(baseRow.get(5)); | ||
if (!row.get(4).equals(baseRow.get(4))) { | ||
row.add("English Updated"); | ||
} | ||
} | ||
} | ||
PrintWriter writer = openWriter("/Users/pfstrack/Desktop/output.txt"); | ||
for (List<String> row : export) { | ||
StringBuilder text = new StringBuilder(); | ||
for (String cell : row) { | ||
text.append(cell).append('\t'); | ||
} | ||
writer.println(text.toString()); | ||
} | ||
writer.close(); | ||
} | ||
|
||
private static List<List<String>> readFile(String file) | ||
throws FileNotFoundException, UnsupportedEncodingException, | ||
IOException { | ||
BufferedReader br = openReader(file); | ||
List<List<String>> data = new ArrayList<List<String>>(); | ||
String line = br.readLine(); | ||
while (line != null) { | ||
List<String> cells = Arrays.asList(line.split("\t")); | ||
List<String> row = new ArrayList<String>(); | ||
row.addAll(cells); | ||
data.add(row); | ||
line = br.readLine(); | ||
} | ||
return data; | ||
} | ||
|
||
private static BufferedReader openReader(String path) | ||
throws FileNotFoundException, UnsupportedEncodingException { | ||
FileInputStream fis = new FileInputStream(path); | ||
InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); | ||
return new BufferedReader(isr); | ||
} | ||
|
||
private static PrintWriter openWriter(String path) | ||
throws FileNotFoundException, UnsupportedEncodingException { | ||
FileOutputStream fos = new FileOutputStream(path); | ||
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); | ||
return new PrintWriter(osw); | ||
} | ||
} |
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
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
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,21 @@ | ||
import module namespace c = "common.xq" at "common.xq"; | ||
|
||
<html> | ||
<body> | ||
<table> { | ||
let $words := //word[@l=('ns', 's', 'n', 'en', 'g')][not(see)] | ||
[not(contains(@mark, '-'))][not(contains(@mark, '|'))] | ||
[c:is-word(.)][not(@gloss='[unglossed]')][not(c:get-gloss(.) = '‽')][not(@cat)] | ||
for $word in $words | ||
let $cat := //cat[@id=$word/@cat] | ||
order by c:normalize-for-sort($word/@v), $word/@l, xs:decimal($cat/@num) | ||
return | ||
<tr> | ||
<td>{ c:get-lang($word) }</td> | ||
<td>{ $word/@v/string() }</td> | ||
<td>{ c:get-speech($word) }</td> | ||
<td>{ c:get-gloss($word) }</td> | ||
</tr> | ||
} </table> | ||
</body> | ||
</html> |
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
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