Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tree-similarity] add new port of tree-similarity to measure tree edit distance #30901

Merged
merged 15 commits into from
May 4, 2023

Conversation

remz1337
Copy link
Contributor

@remz1337 remz1337 commented Apr 16, 2023

  • Changes comply with the maintainer guide
  • The name of the port matches an existing name for this component on https://repology.org/ if possible, and/or is strongly associated with that component on search engines.
  • Optional dependencies are resolved in exactly one way. For example, if the component is built with CMake, all find_package calls are REQUIRED, are satisfied by vcpkg.json's declared dependencies, or disabled with CMAKE_DISABLE_FIND_PACKAGE_Xxx
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is accurate. See adding-usage for context.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is in the new port's versions file.
  • Only one version is added to each modified port's versions file.

@remz1337 remz1337 marked this pull request as ready for review April 16, 2023 04:58
@remz1337 remz1337 changed the title Add port of tree-similarity to measure tree edit distance [tree-similarity] Add port of tree-similarity to measure tree edit distance Apr 16, 2023
@remz1337 remz1337 changed the title [tree-similarity] Add port of tree-similarity to measure tree edit distance [tree-similarity] add new port of tree-similarity to measure tree edit distance Apr 16, 2023
@MonicaLiu0311 MonicaLiu0311 added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Apr 17, 2023
ports/tree-similarity/vcpkg.json Outdated Show resolved Hide resolved
ports/tree-similarity/vcpkg.json Show resolved Hide resolved
versions/t-/tree-similarity.json Outdated Show resolved Hide resolved
@remz1337
Copy link
Contributor Author

@MonicaLiu0311 Should be good now

Comment on lines 12 to 13
#vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/tree-similarity)
#file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the comment #...

@MonicaLiu0311
Copy link
Contributor

Please provide the correct Usage.

tree-similarity is header-only and can be used from CMake via:

    find_path(TREE_SIMILARITY_INCLUDE_DIRS "tree-similiarity/CMakeLists.txt")
    target_include_directories(main PRIVATE ${TREE_SIMILARITY_INCLUDE_DIRS})

@MonicaLiu0311
Copy link
Contributor

Only header files can be placed in the include/ directory.
image

@MonicaLiu0311 MonicaLiu0311 removed the depends:upstream-changes Waiting on a change to the upstream project label Apr 28, 2023
MonicaLiu0311
MonicaLiu0311 previously approved these changes Apr 28, 2023
@remz1337
Copy link
Contributor Author

remz1337 commented Apr 28, 2023

Please provide the correct Usage.

tree-similarity is header-only and can be used from CMake via:

    find_path(TREE_SIMILARITY_INCLUDE_DIRS "tree-similiarity/CMakeLists.txt")
    target_include_directories(main PRIVATE ${TREE_SIMILARITY_INCLUDE_DIRS})

I've been trying to fix this for a few hours now but can't figure out. I have removed the command_line folder from the installation, and now I have this usage message:

find_path(TREE_SIMILARITY_INCLUDE_DIRS "tree-similiarity/cost_model/unit_cost_model.h")
target_include_directories(main PRIVATE ${TREE_SIMILARITY_INCLUDE_DIRS})

Since this library is built with multiple header files, should the usage be the following?

find_path(TREE_SIMILARITY_INCLUDE_DIRS "tree-similiarity")
target_include_directories(main PRIVATE ${TREE_SIMILARITY_INCLUDE_DIRS})

In all cases, it still works fine though, so I'm wondering how much of an issue this is. Please advise
Thanks

For reference, this is a simple program that uses the library:

#include <iostream>
#include "tree-similiarity/node/node.h"
#include "tree-similiarity/label/string_label.h"
#include "tree-similiarity/cost_model/unit_cost_model.h"
#include "tree-similiarity/parser/bracket_notation_parser.h"
#include "tree-similiarity/ted_ub/lgm_tree_index.h"

int main() {
    using Label = label::StringLabel;
    using CostModelLD = cost_model::UnitCostModelLD<Label>;
    using LabelDictionary = label::LabelDictionary<Label>;

    std::string source_tree_string = "{x{b}{c{x}{y}}}";
    std::string dest_tree_string = "{x{a}}";

    parser::BracketNotationParser<Label> bnp;
    // Verify the input format before parsing.
    if (!bnp.validate_input(source_tree_string)) {
        std::cerr << "Incorrect format of source tree. Is the number of opening and closing brackets equal?" << std::endl;
        return -1;
    }
    const node::Node<Label> source_tree = bnp.parse_single(source_tree_string);

    if (!bnp.validate_input(dest_tree_string)) {
        std::cerr << "Incorrect format of destination tree. Is the number of opening and closing brackets equal?" << std::endl;
        return -1;
    }
    const node::Node<Label> destination_tree = bnp.parse_single(dest_tree_string);

    std::cout << "Size of source tree:" << source_tree.get_tree_size() << std::endl;
    std::cout << "Size of destination tree:" << destination_tree.get_tree_size() << std::endl;

    LabelDictionary ld;
    CostModelLD ucm(ld);
    ted_ub::LGMTreeIndex<CostModelLD, node::TreeIndexLGM> lgm_algorithm(ucm);
    node::TreeIndexLGM ti1;
    node::TreeIndexLGM ti2;
    node::index_tree(ti1, source_tree, ld, ucm);
    node::index_tree(ti2, destination_tree, ld, ucm);
    lgm_algorithm.init(ti2);
    std::cout << "Distance TED_K:" << lgm_algorithm.ted_k(ti1, ti2, 1) << std::endl;
    std::cout << "Distance TED:" << lgm_algorithm.ted(ti1, ti2) << std::endl;

    std::cout << "Number of subproblems:" << lgm_algorithm.get_subproblem_count() << std::endl;

    return 0;
}

@MonicaLiu0311
Copy link
Contributor

The usage test passed (header files found):

find_path(TREE_SIMILARITY_INCLUDE_DIRS "tree-similiarity")
target_include_directories(main PRIVATE ${TREE_SIMILARITY_INCLUDE_DIRS})

Please provide the Usage file and install it in the share/ directory. Example: vcpkg/idyntree

@remz1337
Copy link
Contributor Author

remz1337 commented May 3, 2023

It should be good to merge now. Thank you @MonicaLiu0311

@MonicaLiu0311 MonicaLiu0311 added the info:reviewed Pull Request changes follow basic guidelines label May 4, 2023
@JavierMatosD JavierMatosD merged commit e4e9eb9 into microsoft:master May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR! info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants