aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--.settings/org.eclipse.jdt.core.prefs281
-rw-r--r--.settings/org.eclipse.jdt.ui.prefs2
-rw-r--r--lib/transcoder-1.2-SNAPSHOT.jarbin0 -> 95731 bytes
-rw-r--r--src/com/benlinskey/grdbc/GreekTextParser.java181
-rw-r--r--src/com/benlinskey/grdbc/LexiconCreator.java356
-rw-r--r--src/com/benlinskey/grdbc/LexiconParser.java193
-rw-r--r--src/com/benlinskey/grdbc/SyntaxCreator.java171
-rw-r--r--src/com/benlinskey/grdbc/SyntaxParser.java52
9 files changed, 857 insertions, 383 deletions
diff --git a/.gitignore b/.gitignore
index 9858e20..f58446f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,5 +6,5 @@
*.war
*.ear
-# Include SQLite JDBC library.
-!sqlite-jdbc-3.7.2.jar
+# Include libraries.
+!lib/*
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d059138
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,281 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index 83ef9d6..d61f1cf 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -1,3 +1,5 @@
eclipse.preferences.version=1
+formatter_profile=_My code style
+formatter_settings_version=12
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/* Copyright 2013 Benjamin Linskey\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http\://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author Ben Linskey\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/lib/transcoder-1.2-SNAPSHOT.jar b/lib/transcoder-1.2-SNAPSHOT.jar
new file mode 100644
index 0000000..6d3c586
--- /dev/null
+++ b/lib/transcoder-1.2-SNAPSHOT.jar
Binary files differ
diff --git a/src/com/benlinskey/grdbc/GreekTextParser.java b/src/com/benlinskey/grdbc/GreekTextParser.java
index 81cc4cb..e78e1cd 100644
--- a/src/com/benlinskey/grdbc/GreekTextParser.java
+++ b/src/com/benlinskey/grdbc/GreekTextParser.java
@@ -39,93 +39,102 @@ import org.xml.sax.SAXException;
import edu.unc.epidoc.transcoder.TransCoder;
/**
+ * An abstract class for parsing Greek text encoded in an XML document.
+ *
* @author Ben Linskey
- *
+ *
*/
public abstract class GreekTextParser {
- protected Document doc;
- protected TransCoder transcoder;
-
- /**
- * Class constructor.
- * @param xml the XML to parse
- * @throws ParserConfigurationException
- * @throws SAXException
- * @throws IOException
- */
- protected GreekTextParser(String xml)
- throws ParserConfigurationException, SAXException, IOException {
- // Parse the XML and create a Document.
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- InputSource is = new InputSource(new StringReader(xml));
- doc = db.parse(is);
-
- // Create a TransCoder for converting Beta Code to Greek characters.
- try {
- transcoder = new TransCoder("BetaCode", "UnicodeC");
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Transcodes beta code to Greek in elements with the given name.
- * @param element the name of the element to search for
- */
- protected void transcodeInElements(String element) {
- NodeList nodeList = doc.getElementsByTagName(element);
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node elementNode = nodeList.item(i);
- Node langAttr = elementNode.getAttributes().getNamedItem("lang");
- if (langAttr != null) {
- String lang = langAttr.getTextContent();
- if (lang.equals("greek")) {
- String greek = betaToGreek(elementNode.getTextContent());
- elementNode.setTextContent(greek);
- }
- }
- }
- }
-
- /**
- * Returns a string containing an XML representation of the document in its
- * current state.
- * @return a string containing an XML representation of the document in its
- * current state
- */
- protected String getUpdatedXML() {
- StringWriter writer = new StringWriter();
- try {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer = tf.newTransformer();
- DOMSource source = new DOMSource(doc);
- StreamResult result = new StreamResult(writer);
- transformer.transform(source, result);
- } catch (TransformerConfigurationException e) {
- e.printStackTrace();
- System.exit(1);
- } catch (TransformerException e) {
- e.printStackTrace();
- System.exit(1);
- }
- return writer.toString();
- }
-
- /**
- * Converts Beta Code to Greek characters.
- * @param beta the Beta Code to transcode
- * @return the Greek equivalent of the specified Beta Code
- */
- protected String betaToGreek(String beta) {
- String greek = null;
- try {
- greek = transcoder.getString(beta);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- System.exit(1);
- }
- return greek;
- }
+ protected Document doc;
+ protected TransCoder transcoder;
+
+ /**
+ * Class constructor.
+ *
+ * @param xml
+ * the XML to parse
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ protected GreekTextParser(String xml) throws ParserConfigurationException,
+ SAXException, IOException {
+ // Parse the XML and create a Document.
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ InputSource is = new InputSource(new StringReader(xml));
+ doc = db.parse(is);
+
+ // Create a TransCoder for converting Beta Code to Greek characters.
+ try {
+ transcoder = new TransCoder("BetaCode", "UnicodeC");
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Transcodes beta code to Greek in elements with the given name.
+ *
+ * @param element
+ * the name of the element to search for
+ */
+ protected void transcodeInElements(String element) {
+ NodeList nodeList = doc.getElementsByTagName(element);
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node elementNode = nodeList.item(i);
+ Node langAttr = elementNode.getAttributes().getNamedItem("lang");
+ if (langAttr != null) {
+ String lang = langAttr.getTextContent();
+ if (lang.equals("greek")) {
+ String greek = betaToGreek(elementNode.getTextContent());
+ elementNode.setTextContent(greek);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a string containing an XML representation of the document in its
+ * current state.
+ *
+ * @return a string containing an XML representation of the document in its
+ * current state
+ */
+ protected String getUpdatedXML() {
+ StringWriter writer = new StringWriter();
+ try {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(writer);
+ transformer.transform(source, result);
+ } catch (TransformerConfigurationException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (TransformerException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ return writer.toString();
+ }
+
+ /**
+ * Converts Beta Code to Greek characters.
+ *
+ * @param beta
+ * the Beta Code to transcode
+ * @return the Greek equivalent of the specified Beta Code
+ */
+ protected String betaToGreek(String beta) {
+ String greek = null;
+ try {
+ greek = transcoder.getString(beta);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ return greek;
+ }
}
diff --git a/src/com/benlinskey/grdbc/LexiconCreator.java b/src/com/benlinskey/grdbc/LexiconCreator.java
index ec3a99a..3a242ff 100644
--- a/src/com/benlinskey/grdbc/LexiconCreator.java
+++ b/src/com/benlinskey/grdbc/LexiconCreator.java
@@ -30,185 +30,187 @@ import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
/**
- * Reads in an XML file containing a Greek lexicon and stores entries in an
+ * Reads in an XML file containing a Greek lexicon and stores entries in an
* SQLite database.
+ *
* @author Ben Linskey
*/
public class LexiconCreator {
- private final static String FILE = "../xml/Perseus_text_1999.04.0058.xml";
- private final static String DB = "lexicon.db";
- private final static String TABLE_NAME = "lexicon";
- private Connection connection;
- private PreparedStatement insertStatement;
-
- /**
- * Class constructor.
- */
- public LexiconCreator() {
- // Load driver.
- try {
- Class.forName("org.sqlite.JDBC");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- System.exit(1);
- }
-
- // Connect to database.
- try {
- connection = DriverManager.getConnection("jdbc:sqlite:" + DB);
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
-
- // Use batch inserts for speed.
- try {
- connection.setAutoCommit(false);
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
-
- createDatabase();
-
- // Create a prepared statement to use when inserting entries.
- try {
- insertStatement = connection.prepareStatement("INSERT INTO "
- + TABLE_NAME + " VALUES (NULL, ?, ?, ?, ?, ?, ?)");
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Creates the lexicon database.
- */
- public void run() {
- addEntries();
- createIndex();
- try {
- insertStatement.close();
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
- System.out.println("Done.");
- }
-
- /**
- * Resets the database if it already exists and creates a new, empty
- * database.
- */
- private void createDatabase() {
- System.out.println("Creating lexicon database...");
- try {
- String dropTable = "DROP TABLE IF EXISTS " + TABLE_NAME;
- String createTable = "CREATE TABLE " + TABLE_NAME + " (" +
- "_id INTEGER PRIMARY KEY, " +
- "betaNoSymbols VARCHAR(100), " +
- "betaSymbols VARCHAR(100), " +
- "greekFullWord VARCHAR(100), " +
- "greekNoSymbols VARCHAR(100), " +
- "greekLowercase VARCHAR(100), " +
- "entry TEXT)";
- Statement statement = connection.createStatement();
- statement.executeUpdate(dropTable);
- statement.executeUpdate(createTable);
- connection.commit();
- statement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Parses the XML file, modifies the lexicon entries, and inserts the
- * modified entries into the database.
- */
- private void addEntries() {
- System.out.println("Inserting entries...");
-
- try {
- BufferedReader in = new BufferedReader(new FileReader(FILE));
- StringBuilder xml = new StringBuilder();
-
- // Extract the XML for each lexicon entry, then process it.
- while (in.ready()) {
- String line = in.readLine();
- if (line.startsWith("<entry ")) {
- xml.delete(0, xml.length()); // Reset XML.
- xml.append(line); // Add this line to new chunk of XML.
- } else if (line.startsWith("</entry>")) {
- xml.append(line);
- processEntry(xml.toString());
- } else {
- xml.append(line);
- }
- }
- in.close();
-
- insertStatement.executeBatch();
- connection.commit();
- } catch (FileNotFoundException e) {
- System.err.println("Error: Lexicon file not found.");
- System.exit(1);
- } catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Modifies the specified entry and inserts it into the database.
- * @param xml the XML containing the entry to process
- */
- private void processEntry(String xml) {
- try {
- LexiconParser parser = new LexiconParser(xml);
- insertStatement.setString(1, parser.getBetaNoSymbols());
- insertStatement.setString(2, parser.getBetaSymbols());
- insertStatement.setString(3, parser.getGreekFullWord());
- insertStatement.setString(4, parser.getGreekNoSymbols());
- insertStatement.setString(5, parser.getGreekLowercase());
- insertStatement.setString(6, parser.getEntry());
- insertStatement.addBatch();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- System.exit(1);
- } catch (SAXException e) {
- e.printStackTrace();
- System.exit(1);
- } catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
- } catch (SQLException e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Creates an index on the database to speed up searches.
- */
- private void createIndex() {
- System.out.println("Creating index...");
-
- // Create an index on the three columns matched against search queries.
- String sql = "CREATE INDEX searchIndex ON " + TABLE_NAME +
- " (betaNoSymbols, betaSymbols, greekNoSymbols)";
- try {
- Statement statement = connection.createStatement();
- statement.executeUpdate(sql);
- statement.close();
- connection.commit();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
+ private final static String FILE = "../xml/Perseus_text_1999.04.0058.xml";
+ private final static String DB = "lexicon.db";
+ private final static String TABLE_NAME = "lexicon";
+ private Connection connection;
+ private PreparedStatement insertStatement;
+
+ /**
+ * Class constructor.
+ */
+ public LexiconCreator() {
+ // Load driver.
+ try {
+ Class.forName("org.sqlite.JDBC");
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Connect to database.
+ try {
+ connection = DriverManager.getConnection("jdbc:sqlite:" + DB);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Use batch inserts for speed.
+ try {
+ connection.setAutoCommit(false);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ createDatabase();
+
+ // Create a prepared statement to use when inserting entries.
+ try {
+ insertStatement = connection.prepareStatement("INSERT INTO "
+ + TABLE_NAME + " VALUES (NULL, ?, ?, ?, ?, ?, ?)");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Creates the lexicon database.
+ */
+ public void run() {
+ addEntries();
+ createIndex();
+ try {
+ insertStatement.close();
+ connection.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ System.out.println("Done.");
+ }
+
+ /**
+ * Resets the database if it already exists and creates a new, empty
+ * database.
+ */
+ private void createDatabase() {
+ System.out.println("Creating lexicon database...");
+ try {
+ String dropTable = "DROP TABLE IF EXISTS " + TABLE_NAME;
+ String createTable = "CREATE TABLE " + TABLE_NAME + " ("
+ + "_id INTEGER PRIMARY KEY, "
+ + "betaNoSymbols VARCHAR(100), "
+ + "betaSymbols VARCHAR(100), "
+ + "greekFullWord VARCHAR(100), "
+ + "greekNoSymbols VARCHAR(100), "
+ + "greekLowercase VARCHAR(100), " + "entry TEXT)";
+ Statement statement = connection.createStatement();
+ statement.executeUpdate(dropTable);
+ statement.executeUpdate(createTable);
+ connection.commit();
+ statement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Parses the XML file, modifies the lexicon entries, and inserts the
+ * modified entries into the database.
+ */
+ private void addEntries() {
+ System.out.println("Inserting entries...");
+
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(FILE));
+ StringBuilder xml = new StringBuilder();
+
+ // Extract the XML for each lexicon entry, then process it.
+ while (in.ready()) {
+ String line = in.readLine();
+ if (line.startsWith("<entry ")) {
+ xml.delete(0, xml.length()); // Reset XML.
+ xml.append(line); // Add this line to new chunk of XML.
+ } else if (line.startsWith("</entry>")) {
+ xml.append(line);
+ processEntry(xml.toString());
+ } else {
+ xml.append(line);
+ }
+ }
+ in.close();
+
+ insertStatement.executeBatch();
+ connection.commit();
+ } catch (FileNotFoundException e) {
+ System.err.println("Error: Lexicon file not found.");
+ System.exit(1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Modifies the specified entry and inserts it into the database.
+ *
+ * @param xml
+ * the XML containing the entry to process
+ */
+ private void processEntry(String xml) {
+ try {
+ LexiconParser parser = new LexiconParser(xml);
+ insertStatement.setString(1, parser.getBetaNoSymbols());
+ insertStatement.setString(2, parser.getBetaSymbols());
+ insertStatement.setString(3, parser.getGreekFullWord());
+ insertStatement.setString(4, parser.getGreekNoSymbols());
+ insertStatement.setString(5, parser.getGreekLowercase());
+ insertStatement.setString(6, parser.getEntry());
+ insertStatement.addBatch();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (SAXException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Creates an index on the database to speed up searches.
+ */
+ private void createIndex() {
+ System.out.println("Creating index...");
+
+ // Create an index on the three columns matched against search queries.
+ String sql = "CREATE INDEX searchIndex ON " + TABLE_NAME
+ + " (betaNoSymbols, betaSymbols, greekNoSymbols)";
+ try {
+ Statement statement = connection.createStatement();
+ statement.executeUpdate(sql);
+ statement.close();
+ connection.commit();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/src/com/benlinskey/grdbc/LexiconParser.java b/src/com/benlinskey/grdbc/LexiconParser.java
index 8e9e46b..9f3e3b1 100644
--- a/src/com/benlinskey/grdbc/LexiconParser.java
+++ b/src/com/benlinskey/grdbc/LexiconParser.java
@@ -24,99 +24,108 @@ import org.xml.sax.SAXException;
/**
* This class provides methods to parse a chunk of XML containing a lexicon
- * entry, modify the data contained therein, and return data to be inserted
- * into the database.
+ * entry, modify the data contained therein, and return data to be inserted into
+ * the database.
+ *
* @author Ben Linskey
*/
public class LexiconParser extends GreekTextParser {
- /**
- * Class constructor.
- * @param xml the XML to parse
- * @throws ParserConfigurationException
- * @throws SAXException
- * @throws IOException
- */
- public LexiconParser(String xml)
- throws ParserConfigurationException, SAXException, IOException {
- super(xml);
- }
-
- /**
- * Returns a Beta Code representation of this entry's word, stripped of
- * all diacritics.
- * @return this entry's word in Beta Code without diacritics
- */
- public String getBetaNoSymbols() {
- // Get the word and replace all symbols with an empty string.
- return getBetaSymbols().replaceAll("[^a-zA-Z]", "");
- }
-
- /**
- * Returns a Beta Code representation of this entry's word.
- * @return this entry's word in Beta Code
- */
- public String getBetaSymbols() {
- // We just need the "key" attribute from the "entry" element.
- Node entry = doc.getElementsByTagName("entry").item(0);
- return entry.getAttributes().getNamedItem("key").getTextContent();
- }
-
- /**
- * Returns this entry's word in Greek characters.
- * @return this entry's word in Greek characters
- */
- public String getGreekFullWord() {
- // Use the transcoder to convert the beta code to Greek.
- return betaToGreek(getBetaSymbols());
- }
-
- /**
- * Returns this entry's word in Greek characters, stripped of all
- * diacritics.
- * @return this entry's word in Greek characters without diacritics
- */
- public String getGreekNoSymbols() {
- // Get beta code with no symbols other than the capital letter marker.
- String beta = getBetaSymbols().replaceAll("[^a-zA-Z\\*]", "");
-
- // Use the transcoder to convert the beta code to Greek.
- return betaToGreek(beta);
- }
-
- /**
- * Returns this entry's word in all lowercase Greek characters, stripped
- * of all diacritics.
- * @return this entry's word in lowercase Greek characters without
- * diacritics
- */
- public String getGreekLowercase() {
- return getGreekNoSymbols().toLowerCase();
- }
-
- /**
- * Returns the XML for this entry, with all Beta Code converted to Greek
- * characters.
- * @return the XML for this entry with all Beta Code converted to Greek
- * characters
- */
- public String getEntry() {
- transcodeEntryKey();
- transcodeInElements("orth");
- transcodeInElements("ref");
- transcodeInElements("foreign");
- transcodeInElements("note");
- return getUpdatedXML();
- }
-
- /**
- * Converts the value of the entry element's "key" attribute from Beta
- * Code to Greek.
- */
- private void transcodeEntryKey() {
- Node entryNode = doc.getElementsByTagName("entry").item(0);
- Node keyAttr = entryNode.getAttributes().getNamedItem("key");
- String beta = keyAttr.getTextContent();
- String greek = betaToGreek(beta);
- keyAttr.setTextContent(greek);
- }
+ /**
+ * Class constructor.
+ *
+ * @param xml
+ * the XML to parse
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public LexiconParser(String xml) throws ParserConfigurationException,
+ SAXException, IOException {
+ super(xml);
+ }
+
+ /**
+ * Returns a Beta Code representation of this entry's word, stripped of all
+ * diacritics.
+ *
+ * @return this entry's word in Beta Code without diacritics
+ */
+ public String getBetaNoSymbols() {
+ // Get the word and replace all symbols with an empty string.
+ return getBetaSymbols().replaceAll("[^a-zA-Z]", "");
+ }
+
+ /**
+ * Returns a Beta Code representation of this entry's word.
+ *
+ * @return this entry's word in Beta Code
+ */
+ public String getBetaSymbols() {
+ // We just need the "key" attribute from the "entry" element.
+ Node entry = doc.getElementsByTagName("entry").item(0);
+ return entry.getAttributes().getNamedItem("key").getTextContent();
+ }
+
+ /**
+ * Returns this entry's word in Greek characters.
+ *
+ * @return this entry's word in Greek characters
+ */
+ public String getGreekFullWord() {
+ // Use the transcoder to convert the beta code to Greek.
+ return betaToGreek(getBetaSymbols());
+ }
+
+ /**
+ * Returns this entry's word in Greek characters, stripped of all
+ * diacritics.
+ *
+ * @return this entry's word in Greek characters without diacritics
+ */
+ public String getGreekNoSymbols() {
+ // Get beta code with no symbols other than the capital letter marker.
+ String beta = getBetaSymbols().replaceAll("[^a-zA-Z\\*]", "");
+
+ // Use the transcoder to convert the beta code to Greek.
+ return betaToGreek(beta);
+ }
+
+ /**
+ * Returns this entry's word in all lowercase Greek characters, stripped of
+ * all diacritics.
+ *
+ * @return this entry's word in lowercase Greek characters without
+ * diacritics
+ */
+ public String getGreekLowercase() {
+ return getGreekNoSymbols().toLowerCase();
+ }
+
+ /**
+ * Returns the XML for this entry, with all Beta Code converted to Greek
+ * characters.
+ *
+ * @return the XML for this entry with all Beta Code converted to Greek
+ * characters
+ */
+ public String getEntry() {
+ transcodeEntryKey();
+ transcodeInElements("orth");
+ transcodeInElements("ref");
+ transcodeInElements("foreign");
+ transcodeInElements("note");
+ return getUpdatedXML();
+ }
+
+ /**
+ * Converts the value of the entry element's "key" attribute from Beta Code
+ * to Greek.
+ */
+ private void transcodeEntryKey() {
+ Node entryNode = doc.getElementsByTagName("entry").item(0);
+ Node keyAttr = entryNode.getAttributes().getNamedItem("key");
+ String beta = keyAttr.getTextContent();
+ String greek = betaToGreek(beta);
+ keyAttr.setTextContent(greek);
+ }
}
diff --git a/src/com/benlinskey/grdbc/SyntaxCreator.java b/src/com/benlinskey/grdbc/SyntaxCreator.java
index 10637aa..014b7ca 100644
--- a/src/com/benlinskey/grdbc/SyntaxCreator.java
+++ b/src/com/benlinskey/grdbc/SyntaxCreator.java
@@ -31,12 +31,178 @@ import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
/**
- * Reads in an XML file containing the Overview of Greek Syntax text and stores
+ * Reads in an XML file containing the Overview of Greek Syntax text and stores
* sections of the text in an SQLite database.
+<<<<<<< HEAD
+ * <p>
+ * Note that the Sources Cited section is omitted, as it is on Perseus.
+ *
+=======
+>>>>>>> master
* @author Ben Linskey
- *
+ *
*/
public class SyntaxCreator {
+<<<<<<< HEAD
+ private final static String FILE = "../xml/Perseus_text_1999.04.0052.xml";
+ private final static String DB = "syntax.db";
+ private final static String TABLE_NAME = "syntax";
+ private Connection connection;
+ private PreparedStatement insertStatement;
+
+ /**
+ * Class constructor.
+ */
+ public SyntaxCreator() {
+ // Load driver.
+ try {
+ Class.forName("org.sqlite.JDBC");
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Connect to database.
+ try {
+ connection = DriverManager.getConnection("jdbc:sqlite:" + DB);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Use batch inserts for speed.
+ try {
+ connection.setAutoCommit(false);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ createDatabase();
+
+ // Create a prepared statement to use when inserting entries.
+ try {
+ insertStatement = connection.prepareStatement("INSERT INTO "
+ + TABLE_NAME + " VALUES (NULL, ?, ?, ?)");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Creates the Overview of Greek Syntax database.
+ */
+ public void run() {
+ addSections();
+ try {
+ insertStatement.close();
+ connection.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ System.out.println("Done.");
+ }
+
+ /**
+ * Resets the database if it already exists and creates a new, empty
+ * database.
+ */
+ private void createDatabase() {
+ System.out.println("Creating lexicon database...");
+ try {
+ String dropTable = "DROP TABLE IF EXISTS " + TABLE_NAME;
+ String createTable = "CREATE TABLE " + TABLE_NAME + " ("
+ + "_ID INTEGER PRIMARY KEY, "
+ + "chapter VARCHAR(100), " + "section VARCHAR(100), "
+ + "xml TEXT)";
+ Statement statement = connection.createStatement();
+ statement.executeUpdate(dropTable);
+ statement.executeUpdate(createTable);
+ connection.commit();
+ statement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Parses the XML file, modifies the sections, and inserts the modified data
+ * into the database.
+ */
+ private void addSections() {
+ System.out.println("Inserting data...");
+
+ String chapter = null;
+ String section = null;
+ StringBuilder xml = new StringBuilder();
+ Pattern pattern = Pattern.compile("<head>(.*?)</head>");
+
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(FILE));
+ while (in.ready()) {
+ String line = in.readLine();
+ if (line.startsWith("<div1")) {
+ // Get chapter title.
+ line = in.readLine(); // Next line is "head" element with
+ // title.
+ Matcher matcher = pattern.matcher(line);
+ matcher.find();
+ chapter = matcher.group(1);
+ } else if (line.startsWith("<div2")) {
+ // Get section title.
+ line = in.readLine(); // Next line is "head" element with
+ // title.
+ Matcher matcher = pattern.matcher(line);
+ matcher.find();
+ section = matcher.group(1);
+
+ // Reset XML and add "head" element.
+ xml.delete(0, xml.length());
+ xml.append("<section>");
+ xml.append(line);
+ } else if (line.contains("</div2>")) {
+ // Get any XML before the "</div2>" tag.
+ String[] split = line.split("</div2>");
+ xml.append(split[0]);
+
+ // Add closing root tag.
+ xml.append("</section>");
+
+ SyntaxParser parser = new SyntaxParser(xml.toString());
+ String transcodedXml = parser.transcode();
+
+ // Add data to database.
+ insertStatement.setString(1, chapter);
+ insertStatement.setString(2, section);
+ insertStatement.setString(3, transcodedXml);
+ insertStatement.addBatch();
+ } else {
+ // Get next line of XML.
+ xml.append(line);
+ }
+ }
+ in.close();
+
+ insertStatement.executeBatch();
+ connection.commit();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (SAXException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+=======
private final static String FILE = "../xml/Perseus_text_1999.04.0052.xml";
private final static String DB = "syntax.db";
private final static String TABLE_NAME = "syntax";
@@ -214,4 +380,5 @@ public class SyntaxCreator {
System.exit(1);
}
}
+>>>>>>> master
}
diff --git a/src/com/benlinskey/grdbc/SyntaxParser.java b/src/com/benlinskey/grdbc/SyntaxParser.java
index 811ca2f..9745af3 100644
--- a/src/com/benlinskey/grdbc/SyntaxParser.java
+++ b/src/com/benlinskey/grdbc/SyntaxParser.java
@@ -24,31 +24,35 @@ import org.xml.sax.SAXException;
/**
* Parses XML from the Overview of Greek Syntax text and converts Beta Code to
* Greek characters.
+ *
* @author Ben Linskey
- *
+ *
*/
public class SyntaxParser extends GreekTextParser {
- /**
- * Class constructor.
- * @param xml the XML to parse
- * @throws ParserConfigurationException
- * @throws SAXException
- * @throws IOException
- */
- public SyntaxParser(String xml)
- throws ParserConfigurationException, SAXException, IOException {
- super(xml);
- }
-
- /**
- * Returns the XML for this section, with all Beta Code converted to Greek
- * characters.
- * @return the XML for this section with all Beta Code converted to Greek
- * characters
- */
- public String transcode() {
- transcodeInElements("quote");
- transcodeInElements("foreign");
- return getUpdatedXML();
- }
+ /**
+ * Class constructor.
+ *
+ * @param xml
+ * the XML to parse
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public SyntaxParser(String xml) throws ParserConfigurationException,
+ SAXException, IOException {
+ super(xml);
+ }
+
+ /**
+ * Returns the XML for this section, with all Beta Code converted to Greek
+ * characters.
+ *
+ * @return the XML for this section with all Beta Code converted to Greek
+ * characters
+ */
+ public String transcode() {
+ transcodeInElements("quote");
+ transcodeInElements("foreign");
+ return getUpdatedXML();
+ }
}