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

crfsuite 0.12 (new formula) #122035

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Formula/crfsuite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Crfsuite < Formula
desc "Fast implementation of conditional random fields"
homepage "https://www.chokkan.org/software/crfsuite/"
url "https://github.com/downloads/chokkan/crfsuite/crfsuite-0.12.tar.gz"
Copy link
Member

Choose a reason for hiding this comment

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

Wow, I didn't know there's such links like https://github.com/downloads/...

I'd suggest switching it to the format we usually use:

Suggested change
url "https://github.com/downloads/chokkan/crfsuite/crfsuite-0.12.tar.gz"
url "https://github.com/chokkan/crfsuite/archive/refs/tags/0.12.tar.gz"

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. This is borrowing from an existing formula in the homebrew-science (legacy) tap.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, these two tarballs don't have the same contents. The original one I had includes a pre-generated configure file. The /archive tarball doesn't have it.

It seems there are other formulae in core tap that use this kind of link, e.g. apktool, jadx.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, wow, old stuff!
TIL there was a downloads API that was replaced with releases like 10 years ago.

Source: https://stackoverflow.com/questions/63292793/how-can-i-upload-files-to-https-github-com-downloads-user-repo

sha256 "e7fc2d88353b1f4de799245f777d90f3c89a9d9744ba9fbde8c7553fa78a1ea1"
license "BSD-3-Clause"

depends_on "liblbfgs"

uses_from_macos "python" => :test

resource "homebrew-conll2000-training-data" do
url "https://www.cnts.ua.ac.be/conll2000/chunking/train.txt.gz"
sha256 "bcbbe17c487d0939d48c2d694622303edb3637ca9c4944776628cd1815c5cb34"
end

def install
args = std_configure_args
args << "--disable-sse2" if Hardware::CPU.arm?

system "./configure", *args
system "make", "install"

pkgshare.install "example"
end

test do
resource("homebrew-conll2000-training-data").stage testpath

# Use spawn instead of {shell,pipe}_output to directly read and write
# from files. The data is too big to read into memory and then pass to
# the command for this test to complete within the alloted timeout.
command = ["python3", pkgshare/"example/chunking.py"]
pid = spawn(*command, in: "train.txt", out: "train.crfsuite.txt")
Process.wait(pid)

system bin/"crfsuite", "learn", "--model", "CoNLL2000.model", "train.crfsuite.txt"
assert_predicate testpath/"CoNLL2000.model", :exist?
end
end