diff --git a/jgibblda/.classpath b/jgibblda/.classpath index 03f79961c13cd63e03ca08883e00ccda4e98765c..c8482de2d76dcf7fea414c4888a460cf24ddcf59 100644 --- a/jgibblda/.classpath +++ b/jgibblda/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <attributes> <attribute name="maven.pomderived" value="true"/> diff --git a/jgibblda/.settings/org.eclipse.jdt.core.prefs b/jgibblda/.settings/org.eclipse.jdt.core.prefs index 71aa314cccdc8c5610bda147357512c5a43a4d3f..92f8042339f69fb00c768e5ed3c83ebd89f2efb9 100644 --- a/jgibblda/.settings/org.eclipse.jdt.core.prefs +++ b/jgibblda/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,4 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 @@ -13,89 +7,291 @@ org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=ignore org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=ignore -org.eclipse.jdt.core.compiler.problem.deadCode=ignore -org.eclipse.jdt.core.compiler.problem.deprecation=ignore -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=ignore -org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=ignore -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=ignore -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=ignore -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=ignore -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=ignore -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=ignore -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=ignore -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=ignore -org.eclipse.jdt.core.compiler.problem.unusedLabel=ignore -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=ignore org.eclipse.jdt.core.compiler.source=1.7 +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=48 +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=49 +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=48 +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_lambda_body=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=true +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=true +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_after_type_annotation=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=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not 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_lambda_arrow=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_lambda_arrow=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=120 +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=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +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 +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/jgibblda/.settings/org.eclipse.jdt.ui.prefs b/jgibblda/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000000000000000000000000000000000..5713c654549b40f76104760ab2f6cd031d71f011 --- /dev/null +++ b/jgibblda/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +formatter_profile=_vipra +formatter_settings_version=12 diff --git a/jgibblda/pom.xml b/jgibblda/pom.xml index 321ed5c26cb8a7c82edd5a980787899e3621d4e2..52b1475e13f9c4d5b7e7c6275a50cfd998a7d775 100644 --- a/jgibblda/pom.xml +++ b/jgibblda/pom.xml @@ -4,16 +4,36 @@ <groupId>JGibbLDA</groupId> <artifactId>JGibbLDA</artifactId> <version>0.0.1-SNAPSHOT</version> + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.source>1.7</maven.compiler.source> + <log4jVersion>2.4.1</log4jVersion> </properties> + <dependencies> <dependency> <groupId>args4j</groupId> <artifactId>args4j</artifactId> <version>2.0.6</version> </dependency> + + <!-- Logging --> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>${log4jVersion}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4jVersion}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4jVersion}</version> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/jgibblda/src/jgibblda/Constants.java b/jgibblda/src/jgibblda/Constants.java deleted file mode 100644 index c65e53a8cd51d4ea405acdbdccd52f467195b272..0000000000000000000000000000000000000000 --- a/jgibblda/src/jgibblda/Constants.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University - * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -public class Constants { - public static final long BUFFER_SIZE_LONG = 1000000; - public static final short BUFFER_SIZE_SHORT = 512; - - public static final int MODEL_STATUS_UNKNOWN = 0; - public static final int MODEL_STATUS_EST = 1; - public static final int MODEL_STATUS_ESTC = 2; - public static final int MODEL_STATUS_INF = 3; -} diff --git a/jgibblda/src/jgibblda/Conversion.java b/jgibblda/src/jgibblda/Conversion.java deleted file mode 100644 index 5834e771b429b6f240e6bf64817c6008e49cd5c7..0000000000000000000000000000000000000000 --- a/jgibblda/src/jgibblda/Conversion.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University - * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -public class Conversion { - public static String ZeroPad(int number, int width) { - StringBuffer result = new StringBuffer(""); - for (int i = 0; i < width - Integer.toString(number).length(); i++) - result.append("0"); - result.append(Integer.toString(number)); - - return result.toString(); - } -} diff --git a/jgibblda/src/jgibblda/LDA.java b/jgibblda/src/jgibblda/LDA.java deleted file mode 100644 index cd950a21f259a71e626926d021b688dc68e586dd..0000000000000000000000000000000000000000 --- a/jgibblda/src/jgibblda/LDA.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University - * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -import org.kohsuke.args4j.*; - -public class LDA { - - public static void main(String args[]) { - LDACmdOption option = new LDACmdOption(); - CmdLineParser parser = new CmdLineParser(option); - - try { - if (args.length == 0) { - showHelp(parser); - return; - } - - parser.parseArgument(args); - - if (option.est || option.estc) { - Estimator estimator = new Estimator(); - estimator.init(option); - estimator.estimate(); - } else if (option.inf) { - Inferencer inferencer = new Inferencer(); - inferencer.init(option); - - Model newModel = inferencer.inference(); - - for (int i = 0; i < newModel.phi.length; ++i) { - // phi: K * V - System.out.println("-----------------------\ntopic" + i + " : "); - for (int j = 0; j < 10; ++j) { - System.out.println(inferencer.globalDict.id2word.get(j) + "\t" + newModel.phi[i][j]); - } - } - } - } catch (CmdLineException cle) { - System.out.println("Command line error: " + cle.getMessage()); - showHelp(parser); - return; - } catch (Exception e) { - System.out.println("Error in main: " + e.getMessage()); - e.printStackTrace(); - return; - } - } - - public static void showHelp(CmdLineParser parser) { - System.out.println("LDA [options ...] [arguments...]"); - parser.printUsage(System.out); - } - -} diff --git a/jgibblda/src/jgibblda/Pair.java b/jgibblda/src/jgibblda/Pair.java deleted file mode 100644 index 6eef0aa292cbc788947c3baa98c907f1024215db..0000000000000000000000000000000000000000 --- a/jgibblda/src/jgibblda/Pair.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University - * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -import java.util.Comparator; - -public class Pair implements Comparable<Pair> { - public Object first; - public Comparable second; - public static boolean naturalOrder = false; - - public Pair(Object k, Comparable v) { - first = k; - second = v; - } - - public Pair(Object k, Comparable v, boolean naturalOrder) { - first = k; - second = v; - Pair.naturalOrder = naturalOrder; - } - - public int compareTo(Pair p) { - if (naturalOrder) - return this.second.compareTo(p.second); - else - return -this.second.compareTo(p.second); - } -} diff --git a/jgibblda/src/main/java/jgibblda/Constants.java b/jgibblda/src/main/java/jgibblda/Constants.java new file mode 100644 index 0000000000000000000000000000000000000000..6d1b558ac9fd8a86ade375aa48e27063934a3a31 --- /dev/null +++ b/jgibblda/src/main/java/jgibblda/Constants.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2007 by + * + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University + * + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi + * + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package jgibblda; + +public class Constants { + public static final long BUFFER_SIZE_LONG = 1000000; + public static final short BUFFER_SIZE_SHORT = 512; + + public static final int MODEL_STATUS_UNKNOWN = 0; + public static final int MODEL_STATUS_EST = 1; + public static final int MODEL_STATUS_ESTC = 2; + public static final int MODEL_STATUS_INF = 3; +} diff --git a/jgibblda/src/main/java/jgibblda/Conversion.java b/jgibblda/src/main/java/jgibblda/Conversion.java new file mode 100644 index 0000000000000000000000000000000000000000..c2bd1d7c39969459e0810d42d2b6f00380c69f3a --- /dev/null +++ b/jgibblda/src/main/java/jgibblda/Conversion.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007 by + * + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University + * + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi + * + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package jgibblda; + +public class Conversion { + public static String ZeroPad(int number, int width) { + StringBuffer result = new StringBuffer(""); + for (int i = 0; i < width - Integer.toString(number).length(); i++) + result.append("0"); + result.append(Integer.toString(number)); + + return result.toString(); + } +} diff --git a/jgibblda/src/jgibblda/Dictionary.java b/jgibblda/src/main/java/jgibblda/Dictionary.java similarity index 74% rename from jgibblda/src/jgibblda/Dictionary.java rename to jgibblda/src/main/java/jgibblda/Dictionary.java index f8550fdf87649a9cca2c7b506f725b181f239a9c..90972c93b834008a6f5817d0baf39b8bec7949fe 100644 --- a/jgibblda/src/jgibblda/Dictionary.java +++ b/jgibblda/src/main/java/jgibblda/Dictionary.java @@ -1,29 +1,24 @@ /* * Copyright (C) 2007 by * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package jgibblda; @@ -38,7 +33,13 @@ import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class Dictionary { + + public static final Logger log = LoggerFactory.getLogger(Dictionary.class); + public Map<String, Integer> word2id; public Map<Integer, String> id2word; @@ -130,7 +131,7 @@ public class Dictionary { reader.close(); return true; } catch (Exception e) { - System.out.println("Error while reading dictionary:" + e.getMessage()); + log.error("Error while reading dictionary:" + e.getMessage()); e.printStackTrace(); return false; } @@ -156,7 +157,7 @@ public class Dictionary { writer.close(); return true; } catch (Exception e) { - System.out.println("Error while writing word map " + e.getMessage()); + log.error("Error while writing word map " + e.getMessage()); e.printStackTrace(); return false; } diff --git a/jgibblda/src/jgibblda/Document.java b/jgibblda/src/main/java/jgibblda/Document.java similarity index 65% rename from jgibblda/src/jgibblda/Document.java rename to jgibblda/src/main/java/jgibblda/Document.java index c9faf020f3fff5b48802a265e11c98c2557c2aa9..bc5ce78c4473cc6309c996bea9e8467b2f23780e 100644 --- a/jgibblda/src/jgibblda/Document.java +++ b/jgibblda/src/main/java/jgibblda/Document.java @@ -1,29 +1,24 @@ /* * Copyright (C) 2007 by * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package jgibblda; diff --git a/jgibblda/src/jgibblda/Estimator.java b/jgibblda/src/main/java/jgibblda/Estimator.java similarity index 69% rename from jgibblda/src/jgibblda/Estimator.java rename to jgibblda/src/main/java/jgibblda/Estimator.java index c26a3ecdeb36a677098c46ac4824afa21ff562f7..b59b77a02c2637a93c5645b6f7e9ce53f9538bfe 100644 --- a/jgibblda/src/jgibblda/Estimator.java +++ b/jgibblda/src/main/java/jgibblda/Estimator.java @@ -1,38 +1,37 @@ /* * Copyright (C) 2007 by * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package jgibblda; import java.io.File; -import java.util.Vector; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Estimator { + public static final Logger log = LoggerFactory.getLogger(Estimator.class); + // output model protected Model trnModel; LDACmdOption option; @@ -54,11 +53,11 @@ public class Estimator { } public void estimate() { - System.out.println("Sampling " + trnModel.niters + " iteration!"); + log.info("Sampling " + trnModel.niters + " iteration!"); int lastIter = trnModel.liter; for (trnModel.liter = lastIter + 1; trnModel.liter < trnModel.niters + lastIter; trnModel.liter++) { - System.out.println("Iteration " + trnModel.liter + " ..."); + log.info("Iteration " + trnModel.liter + " ..."); // for all z_i for (int m = 0; m < trnModel.M; m++) { @@ -72,20 +71,20 @@ public class Estimator { if (option.savestep > 0) { if (trnModel.liter % option.savestep == 0) { - System.out.println("Saving the model at iteration " + trnModel.liter + " ..."); + log.info("Saving the model at iteration " + trnModel.liter + " ..."); computeTheta(); computePhi(); - trnModel.saveModel("model-" + Conversion.ZeroPad(trnModel.liter, 5)); + trnModel.saveModel(option.modelName + "-" + Conversion.ZeroPad(trnModel.liter, 5)); } } } // end iterations - System.out.println("Gibbs sampling completed!\n"); - System.out.println("Saving the final model!\n"); + log.info("Gibbs sampling completed"); + log.info("Saving the final model"); computeTheta(); computePhi(); trnModel.liter--; - trnModel.saveModel("model-final"); + trnModel.saveModel(option.modelName); } /** diff --git a/jgibblda/src/jgibblda/Inferencer.java b/jgibblda/src/main/java/jgibblda/Inferencer.java similarity index 73% rename from jgibblda/src/jgibblda/Inferencer.java rename to jgibblda/src/main/java/jgibblda/Inferencer.java index 3811c582e7f1db4bf50671a8e89beb5334a233a0..25bfa07fd0abb543ea31fdc23d4d85c33c63a076 100644 --- a/jgibblda/src/jgibblda/Inferencer.java +++ b/jgibblda/src/main/java/jgibblda/Inferencer.java @@ -1,41 +1,35 @@ /* * Copyright (C) 2007 by * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package jgibblda; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.util.StringTokenizer; -import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Inferencer { + + public static final Logger log = LoggerFactory.getLogger(Inferencer.class); + // Train model public Model trnModel; public Dictionary globalDict; @@ -63,15 +57,14 @@ public class Inferencer { // inference new model ~ getting data from a specified dataset public Model inference(LDADataset newData) { - System.out.println("init new model"); + log.info("init new model"); Model newModel = new Model(); newModel.initNewModel(option, newData, trnModel); this.newModel = newModel; - System.out.println("Sampling " + niters + " iteration for inference!"); + log.info("Sampling " + niters + " iteration for inference!"); for (newModel.liter = 1; newModel.liter <= niters; newModel.liter++) { - // System.out.println("Iteration " + newModel.liter + " ..."); // for all newz_i for (int m = 0; m < newModel.M; ++m) { @@ -85,7 +78,7 @@ public class Inferencer { } // end iterations - System.out.println("Gibbs sampling for inference completed!"); + log.info("Gibbs sampling for inference completed!"); computeNewTheta(); computeNewPhi(); @@ -94,27 +87,20 @@ public class Inferencer { } public Model inference(String[] strs) { - // System.out.println("inference"); - Model newModel = new Model(); - - // System.out.println("read dataset"); LDADataset dataset = LDADataset.readDataSet(strs, globalDict); - return inference(dataset); } // inference new model ~ getting dataset from file specified in option public Model inference() { - // System.out.println("inference"); newModel = new Model(); if (!newModel.initNewModel(option, trnModel)) return null; - System.out.println("Sampling " + niters + " iteration for inference!"); + log.info("Sampling " + niters + " iteration for inference!"); for (newModel.liter = 1; newModel.liter <= niters; newModel.liter++) { - // System.out.println("Iteration " + newModel.liter + " ..."); // for all newz_i for (int m = 0; m < newModel.M; ++m) { @@ -128,8 +114,8 @@ public class Inferencer { } // end iterations - System.out.println("Gibbs sampling for inference completed!"); - System.out.println("Saving the inference outputs!"); + log.info("Gibbs sampling for inference completed!"); + log.info("Saving the inference outputs!"); computeNewTheta(); computeNewPhi(); diff --git a/jgibblda/src/main/java/jgibblda/LDA.java b/jgibblda/src/main/java/jgibblda/LDA.java new file mode 100644 index 0000000000000000000000000000000000000000..808b7e27d168f42b429f76ebf3f41636062c3da3 --- /dev/null +++ b/jgibblda/src/main/java/jgibblda/LDA.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2007 by + * + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University + * + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi + * + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package jgibblda; + +import org.kohsuke.args4j.CmdLineException; +import org.kohsuke.args4j.CmdLineParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LDA { + + public static final Logger log = LoggerFactory.getLogger(LDA.class); + + public static void main(String args[]) { + LDACmdOption option = new LDACmdOption(); + CmdLineParser parser = new CmdLineParser(option); + + try { + if (args.length == 0) { + showHelp(parser); + return; + } + + parser.parseArgument(args); + + if (option.est || option.estc) { + Estimator estimator = new Estimator(); + estimator.init(option); + estimator.estimate(); + } else if (option.inf) { + Inferencer inferencer = new Inferencer(); + inferencer.init(option); + + Model newModel = inferencer.inference(); + + for (int i = 0; i < newModel.phi.length; ++i) { + // phi: K * V + log.info("-----------------------\ntopic" + i + " : "); + for (int j = 0; j < 10; ++j) { + log.info(inferencer.globalDict.id2word.get(j) + "\t" + newModel.phi[i][j]); + } + } + } + } catch (CmdLineException cle) { + log.info("Command line error: " + cle.getMessage()); + showHelp(parser); + return; + } catch (Exception e) { + log.info("Error in main: " + e.getMessage()); + e.printStackTrace(); + return; + } + } + + public static void showHelp(CmdLineParser parser) { + log.info("LDA [options ...] [arguments...]"); + parser.printUsage(System.out); + } + +} diff --git a/jgibblda/src/jgibblda/LDACmdOption.java b/jgibblda/src/main/java/jgibblda/LDACmdOption.java similarity index 94% rename from jgibblda/src/jgibblda/LDACmdOption.java rename to jgibblda/src/main/java/jgibblda/LDACmdOption.java index 6d29a5e572cc61b454a21d084fac9c95cb6c3294..79c548a7fbf4648938ba936522be774dbf6aad28 100644 --- a/jgibblda/src/jgibblda/LDACmdOption.java +++ b/jgibblda/src/main/java/jgibblda/LDACmdOption.java @@ -1,6 +1,6 @@ package jgibblda; -import org.kohsuke.args4j.*; +import org.kohsuke.args4j.Option; public class LDACmdOption { diff --git a/jgibblda/src/jgibblda/LDADataset.java b/jgibblda/src/main/java/jgibblda/LDADataset.java similarity index 74% rename from jgibblda/src/jgibblda/LDADataset.java rename to jgibblda/src/main/java/jgibblda/LDADataset.java index d820974505abade6554247324afeabbc28fb967e..7b11caa8595207884c2033ceee3b995b1a579436 100644 --- a/jgibblda/src/jgibblda/LDADataset.java +++ b/jgibblda/src/main/java/jgibblda/LDADataset.java @@ -1,40 +1,43 @@ /* * Copyright (C) 2007 by * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package jgibblda; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class LDADataset { + + public static final Logger log = LoggerFactory.getLogger(LDADataset.class); + // --------------------------------------------------------------- // Instance Variables // --------------------------------------------------------------- @@ -127,7 +130,6 @@ public class LDADataset { if (globalDict != null) { // get the global id Integer id = globalDict.getID(word); - // System.out.println(id); if (id != null) { localDict.addWord(word); @@ -166,7 +168,7 @@ public class LDADataset { reader.close(); return data; } catch (Exception e) { - System.out.println("Read Dataset Error: " + e.getMessage()); + log.error("Read Dataset Error: " + e.getMessage()); e.printStackTrace(); return null; } @@ -189,7 +191,7 @@ public class LDADataset { reader.close(); return data; } catch (Exception e) { - System.out.println("Read Dataset Error: " + e.getMessage()); + log.error("Read Dataset Error: " + e.getMessage()); e.printStackTrace(); return null; } @@ -201,25 +203,7 @@ public class LDADataset { * @return dataset if success and null otherwise */ public static LDADataset readDataSet(BufferedReader reader) { - try { - // read number of document - String line; - line = reader.readLine(); - int M = Integer.parseInt(line); - - LDADataset data = new LDADataset(M); - for (int i = 0; i < M; ++i) { - line = reader.readLine(); - - data.setDoc(line, i); - } - - return data; - } catch (Exception e) { - System.out.println("Read Dataset Error: " + e.getMessage()); - e.printStackTrace(); - return null; - } + return readDataSet(reader, null); } /** @@ -233,22 +217,22 @@ public class LDADataset { */ public static LDADataset readDataSet(BufferedReader reader, Dictionary dict) { try { - // read number of document + List<String> lines = new ArrayList<>(); + String line; - line = reader.readLine(); - int M = Integer.parseInt(line); - System.out.println("NewM:" + M); + while ((line = reader.readLine()) != null) { + lines.add(line); + } - LDADataset data = new LDADataset(M, dict); - for (int i = 0; i < M; ++i) { - line = reader.readLine(); + LDADataset data = new LDADataset(lines.size(), dict); - data.setDoc(line, i); + for (int i = 0; i < lines.size(); i++) { + data.setDoc(lines.get(i), i); } return data; } catch (Exception e) { - System.out.println("Read Dataset Error: " + e.getMessage()); + log.error("Read Dataset Error: " + e.getMessage()); e.printStackTrace(); return null; } @@ -282,11 +266,9 @@ public class LDADataset { * @return dataset if success and null otherwise */ public static LDADataset readDataSet(String[] strs, Dictionary dict) { - // System.out.println("readDataset..."); LDADataset data = new LDADataset(strs.length, dict); for (int i = 0; i < strs.length; ++i) { - // System.out.println("set doc " + i); data.setDoc(strs[i], i); } return data; diff --git a/jgibblda/src/jgibblda/Model.java b/jgibblda/src/main/java/jgibblda/Model.java similarity index 84% rename from jgibblda/src/jgibblda/Model.java rename to jgibblda/src/main/java/jgibblda/Model.java index b8669df055afabd7e3ab7b97f8a53b93caafce10..4303d74a33855a18a67352801b6804397f51b752 100644 --- a/jgibblda/src/jgibblda/Model.java +++ b/jgibblda/src/main/java/jgibblda/Model.java @@ -1,29 +1,24 @@ /* * Copyright (C) 2007 by * - * Xuan-Hieu Phan - * hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com - * Graduate School of Information Sciences - * Tohoku University + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University * - * Cam-Tu Nguyen - * ncamtu@gmail.com - * College of Technology - * Vietnam National University, Hanoi + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi * - * JGibbsLDA is a free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. * - * JGibbsLDA is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with JGibbsLDA; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package jgibblda; @@ -34,17 +29,22 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.StringTokenizer; import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class Model { + public static final Logger log = LoggerFactory.getLogger(Model.class); + // --------------------------------------------------------------- // Class Variables // --------------------------------------------------------------- @@ -184,18 +184,19 @@ public class Model { reader.close(); } catch (Exception e) { - System.out.println("Error while reading other file:" + e.getMessage()); + log.error("Error while reading other file:" + e.getMessage()); e.printStackTrace(); return false; } return true; } + @SuppressWarnings("unchecked") protected boolean readTAssignFile(String tassignFile) { + BufferedReader reader = null; try { int i, j; - BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(tassignFile), "UTF-8")); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(tassignFile), "UTF-8")); String line; z = new Vector[M]; @@ -215,7 +216,7 @@ public class Model { StringTokenizer tknr2 = new StringTokenizer(token, ":"); if (tknr2.countTokens() != 2) { - System.out.println("Invalid word-topic assignment line\n"); + log.warn("Invalid word-topic assignment line\n"); return false; } @@ -234,12 +235,15 @@ public class Model { } } // end for each doc - - reader.close(); } catch (Exception e) { - System.out.println("Error while loading model: " + e.getMessage()); + log.error("Error while loading model: " + e.getMessage()); e.printStackTrace(); return false; + } finally { + if (reader != null) + try { + reader.close(); + } catch (IOException e) {} } return true; } @@ -283,7 +287,7 @@ public class Model { writer.close(); } catch (Exception e) { - System.out.println("Error while saving model tassign: " + e.getMessage()); + log.error("Error while saving model tassign: " + e.getMessage()); e.printStackTrace(); return false; } @@ -304,7 +308,7 @@ public class Model { } writer.close(); } catch (Exception e) { - System.out.println("Error while saving topic distribution file for this model: " + e.getMessage()); + log.error("Error while saving topic distribution file for this model: " + e.getMessage()); e.printStackTrace(); return false; } @@ -327,7 +331,7 @@ public class Model { } writer.close(); } catch (Exception e) { - System.out.println("Error while saving word-topic distribution:" + e.getMessage()); + log.error("Error while saving word-topic distribution:" + e.getMessage()); e.printStackTrace(); return false; } @@ -350,7 +354,7 @@ public class Model { writer.close(); } catch (Exception e) { - System.out.println("Error while saving model others:" + e.getMessage()); + log.error("Error while saving model others:" + e.getMessage()); e.printStackTrace(); return false; } @@ -391,7 +395,7 @@ public class Model { writer.close(); } catch (Exception e) { - System.out.println("Error while saving model twords: " + e.getMessage()); + log.error("Error while saving model twords: " + e.getMessage()); e.printStackTrace(); return false; } @@ -461,6 +465,7 @@ public class Model { /** * Init parameters for estimation */ + @SuppressWarnings("unchecked") public boolean initNewModel(LDACmdOption option) { if (!init(option)) return false; @@ -470,7 +475,7 @@ public class Model { data = LDADataset.readDataSet(dir + File.separator + dfile); if (data == null) { - System.out.println("Fail to read training data!\n"); + log.error("Fail to read training data!\n"); return false; } @@ -541,6 +546,7 @@ public class Model { * @param newData * DataSet for which we do inference */ + @SuppressWarnings("unchecked") public boolean initNewModel(LDACmdOption option, LDADataset newData, Model trnModel) { if (!init(option)) return false; @@ -552,7 +558,7 @@ public class Model { beta = trnModel.beta; p = new double[K]; - System.out.println("K:" + K); + log.info("K:" + K); data = newData; @@ -561,8 +567,8 @@ public class Model { V = data.V; dir = option.dir; savestep = option.savestep; - System.out.println("M:" + M); - System.out.println("V:" + V); + log.info("M:" + M); + log.info("V:" + V); // K: from command line or default value // alpha, beta: from command line or default values @@ -628,7 +634,7 @@ public class Model { LDADataset dataset = LDADataset.readDataSet(dir + File.separator + dfile, trnModel.data.localDict); if (dataset == null) { - System.out.println("Fail to read dataset!\n"); + log.error("Fail to read dataset!\n"); return false; } @@ -648,15 +654,15 @@ public class Model { // load model, i.e., read z and trndata if (!loadModel()) { - System.out.println("Fail to load word-topic assignment file of the model!\n"); + log.error("Fail to load word-topic assignment file of the model!\n"); return false; } - System.out.println("Model loaded:"); - System.out.println("\talpha:" + alpha); - System.out.println("\tbeta:" + beta); - System.out.println("\tM:" + M); - System.out.println("\tV:" + V); + log.info("Model loaded:"); + log.info("\talpha:" + alpha); + log.info("\tbeta:" + beta); + log.info("\tM:" + M); + log.info("\tV:" + V); nw = new int[V][K]; for (w = 0; w < V; w++) { diff --git a/jgibblda/src/main/java/jgibblda/Pair.java b/jgibblda/src/main/java/jgibblda/Pair.java new file mode 100644 index 0000000000000000000000000000000000000000..7753f6597a558e474ba44defc33ebb0705154a9e --- /dev/null +++ b/jgibblda/src/main/java/jgibblda/Pair.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2007 by + * + * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School + * of Information Sciences Tohoku University + * + * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National + * University, Hanoi + * + * JGibbsLDA is a free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package jgibblda; + +@SuppressWarnings("rawtypes") +public class Pair implements Comparable<Pair> { + public Object first; + public Comparable second; + public static boolean naturalOrder = false; + + public Pair(Object k, Comparable v) { + first = k; + second = v; + } + + public Pair(Object k, Comparable v, boolean naturalOrder) { + first = k; + second = v; + Pair.naturalOrder = naturalOrder; + } + + @SuppressWarnings("unchecked") + public int compareTo(Pair p) { + if (naturalOrder) + return this.second.compareTo(p.second); + else + return -this.second.compareTo(p.second); + } +} diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java b/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java index 320290eccea12b7ab706b9712fc0ca8587be5be6..02dcda7b2cc00e2b780f5f956086a81324729cc8 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java @@ -13,28 +13,29 @@ import de.vipra.util.ex.ConfigException; public abstract class Filebase implements Closeable { - private final File dataDir; - private final File dataFile; + private final File modelDir; + private final File modelFile; private final FilebaseIndex index; private final FilebaseVocabulary vocab; - public Filebase(File dataDir, String fileName) throws FilebaseException { - this.dataDir = dataDir; + public Filebase(File dataDir, String modelName) throws FilebaseException { + this.modelDir = new File(dataDir, modelName); + if (!modelDir.exists()) { + if (!modelDir.mkdirs()) { + throw new FilebaseException("could not create model directory: " + modelDir.getAbsolutePath()); + } + } try { - this.dataFile = new File(dataDir, fileName); - this.index = new FilebaseIndex(new File(dataDir, Constants.INDEX_FILE)); - this.vocab = new FilebaseVocabulary(new File(dataDir, Constants.VOCAB_FILE)); + this.modelFile = new File(modelDir, modelName); + this.index = new FilebaseIndex(new File(modelDir, Constants.INDEX_FILE)); + this.vocab = new FilebaseVocabulary(new File(modelDir, Constants.VOCAB_FILE)); } catch (IOException e) { throw new FilebaseException("could not read index: " + e.getMessage()); } } - public File getDataDir() { - return dataDir; - } - - public File getDataFile() { - return dataFile; + public File getModelFile() { + return modelFile; } public FilebaseIndex getIndex() { diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java b/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java index 18f6a5d5b96133fd871dc72bb1501c888876bddd..b92fcf9a1d1ada9daf0251a7b50f75b36bd7441e 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java @@ -8,19 +8,18 @@ import java.util.List; import de.vipra.cmd.ex.FilebaseException; import de.vipra.cmd.model.Article; -import de.vipra.util.StringUtils; import de.vipra.util.ex.NotImplementedException; public class JGibbFilebase extends Filebase { - private final File dataFile; + private final File modelFile; private final FilebaseIndex index; private final FilebaseVocabulary vocab; private final List<Article> articles; public JGibbFilebase(File dataDir) throws FilebaseException { super(dataDir, "jgibb"); - this.dataFile = getDataFile(); + this.modelFile = getModelFile(); this.index = getIndex(); this.vocab = getVocab(); this.articles = new ArrayList<>(); @@ -41,28 +40,16 @@ public class JGibbFilebase extends Filebase { @Override public void write() throws IOException { - boolean exists = dataFile.exists(); - - RandomAccessFile raf = new RandomAccessFile(dataFile, "rw"); - - // read count if exists - int articleCount = 0; - if (exists) { - byte[] count = new byte[10]; - raf.read(count); - articleCount = Integer.parseInt(new String(count)); - } - - // write count - // count is padded to allow replacement with bigger numbers - articleCount += articles.size(); - raf.seek(0); - raf.writeBytes(StringUtils.padNumber(articleCount)); + boolean linesep = modelFile.exists(); + RandomAccessFile raf = new RandomAccessFile(modelFile, "rw"); // write articles raf.seek(raf.length()); for (Article a : articles) { - raf.writeBytes(System.lineSeparator()); + if (linesep) + raf.writeBytes(System.lineSeparator()); + else + linesep = true; raf.writeBytes(a.getProcessedText().getText()); } diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbLDAAnalyzer.java b/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbLDAAnalyzer.java index 1d1f3e9a00ba76d0aeaa27b67995a2a9f38981ad..4ba727279719b170efaa826dea86fa06482316bc 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbLDAAnalyzer.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbLDAAnalyzer.java @@ -1,38 +1,71 @@ package de.vipra.cmd.lda; +import java.io.File; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import de.vipra.cmd.ex.LDAAnalyzerException; import de.vipra.util.Config; +import de.vipra.util.ex.ConfigException; +import jgibblda.Estimator; import jgibblda.Inferencer; import jgibblda.LDACmdOption; +import jgibblda.Model; public class JGibbLDAAnalyzer extends LDAAnalyzer { public static final Logger log = LoggerFactory.getLogger(JGibbLDAAnalyzer.class); - private final LDACmdOption ldaOption; - private final Inferencer inferencer; + private File dataDir; + private File modelDir; + private File modelFile; + private LDACmdOption options; protected JGibbLDAAnalyzer() { super("JGibb Analyzer"); - this.ldaOption = new LDACmdOption(); - this.inferencer = new Inferencer(); } @Override public void init(Config config) throws LDAAnalyzerException { - try { + options = new LDACmdOption(); - } catch (Exception e) { + try { + dataDir = config.getDataDirectory(); + } catch (ConfigException e) { throw new LDAAnalyzerException(e); } + + modelDir = new File(dataDir, "jgibb"); + options.dir = modelDir.getAbsolutePath(); + options.estc = new File(modelDir, "model-final.tassign").exists(); + options.est = !options.estc; + + modelFile = new File(modelDir, "jgibb"); + options.dfile = modelFile.getName(); + + options.modelName = "jgibb"; } @Override public void analyze() throws LDAAnalyzerException { + if (!modelFile.exists()) { + throw new LDAAnalyzerException("model file does not exist: " + modelFile.getAbsolutePath()); + } + estimate(); + inference(); + } + + private void estimate() { + Estimator estimator = new Estimator(); + estimator.init(options); + estimator.estimate(); + } + private void inference() { + Inferencer inferencer = new Inferencer(); + inferencer.init(options); + Model newModel = inferencer.inference(); } } diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java b/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java index f6b20130aed5c92e0c0205b318a371f0c9b2e14d..34869e1b4fa2684b49dab0f01aacd80748707239 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/option/ImportCommand.java @@ -146,7 +146,7 @@ public class ImportCommand implements Command { preprocessor = Processor.getPreprocessor(config); analyzer = LDAAnalyzer.getAnalyzer(config); - out.info("using data directory: " + filebase.getDataDir().getAbsolutePath()); + out.info("using data directory: " + config.getDataDirectory().getAbsolutePath()); out.info("using preprocessor: " + preprocessor.getName()); out.info("using analyzer: " + analyzer.getName()); @@ -160,14 +160,14 @@ public class ImportCommand implements Command { } long durImport = timer.lap(); - // do topic modeling - analyzer.analyze(); - long durAnalyze = timer.lap(); - // write filebase filebase.close(); long durIndex = timer.lap(); + // do topic modeling + analyzer.analyze(); + long durAnalyze = timer.lap(); + out.info("imported " + articles.size() + " " + (articles.size() == 1 ? "article" : "articles")); out.info("import: " + StringUtils.timeString(durImport) + ", analyze: " + StringUtils.timeString(durAnalyze) + ", reindex: " + StringUtils.timeString(durIndex)); diff --git a/vipra-rest/.settings/org.eclipse.jdt.ui.prefs b/vipra-rest/.settings/org.eclipse.jdt.ui.prefs index a7f8de8ef5b0d043d6e4ba0446e4ea440514af27..fe89f28bca5900b59ebe3dc0ed0745189fa9e153 100644 --- a/vipra-rest/.settings/org.eclipse.jdt.ui.prefs +++ b/vipra-rest/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,2 @@ eclipse.preferences.version=1 -formatter_profile=_Vipra formatter_settings_version=12