Skip to content

Commit

Permalink
omorfi: init at 0.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkki14 committed Jul 25, 2023
1 parent 67424e7 commit 8d34b31
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{ lib
, stdenv
, autoconf
, automake
, autoreconfHook
, cg3
, fetchFromGitHub
, hfst
, hfst-ospell
, icu
, libtool
, libvoikko
, makeWrapper
, pkg-config
, python3
, python3Packages
, zip
}:

Expand Down Expand Up @@ -42,30 +39,29 @@ stdenv.mkDerivation (finalAttrs: {
python3.pkgs.wrapPython
];

>>>>>>> 2ea2d99a91e (hfst changes):pkgs/development/libraries/omorfi/default.nix
buildInputs = [
hfst
python3.pkgs.hfst
hfst-ospell
python3Packages.hfst-python
icu
];
nativeBuildInputs = [
autoconf
automake
autoreconfHook
cg3
libtool
pkg-config
python3
libvoikko
zip
];

# Supplied pkg-config file doesn't properly expose these
propagatedBuildInputs = [
hfst
python3Packages.hfst
icu
];

# Wrap shell scripts so they find the Python scripts
# omorfi.bash inexplicably fails when wrapped
preFixup = ''
wrapPythonProgramsIn "$out/bin" "$out ${python3.pkgs.hfst}"
for i in "$out/bin"/*.{sh,bash}; do
if [ $(basename "$i") != "omorfi.bash" ]; then
wrapProgram "$i" --prefix "PATH" : "$out/bin/"
fi
done
'';

# Enable all features
configureFlags = [
"--enable-labeled-segments"
Expand All @@ -74,22 +70,12 @@ stdenv.mkDerivation (finalAttrs: {
"--enable-hyphenator"
];

# Fix for omorfi-hyphenate.sh file not found error
postInstall = ''
mv $out/share/omorfi/omorfi.hyphenate-rules.hfst $out/share/omorfi/omorfi.hyphenate.hfst
'';

src = fetchFromGitHub {
owner = "flammie";
repo = "omorfi";
rev = "refs/tags/v${version}";
hash = "sha256-UoqdwNWCNOPX6u1YBlnXUcB/fmcvcy/HXbYciVrMBOY=";
};

meta = with lib; {
description = "Analysis for Finnish text";
homepage = "https://github.com/flammie/omorfi";
license = licenses.gpl3;
maintainers = with maintainers; [ lurkki ];
# Darwin build fails due to hfst not being found
broken = stdenv.isDarwin;
};
})
32 changes: 32 additions & 0 deletions pkgs/development/python-modules/omorfi/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ buildPythonPackage
, pkgs
, lib
, stdenv
, hfst
}:

buildPythonPackage rec {
pname = "omorfi";
inherit (pkgs.omorfi) src version;

sourceRoot = "${src.name}/src/python";

propagatedBuildInputs = [
hfst
];

# Fixes some improper import paths
patches = [ ./importfix.patch ];

# Apply patch relative to source/src
patchFlags = [ "-p3" ];

meta = with lib; {
description = "Python interface for Omorfi";
homepage = "https://github.com/flammie/omorfi";
license = licenses.gpl3;
maintainers = with maintainers; [ lurkki ];
# Ofborg build error (hfst not found?)
broken = stdenv.isDarwin;
};
}
76 changes: 76 additions & 0 deletions pkgs/development/python-modules/omorfi/importfix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/src/python/omorfi/entryguessing/gradation.py b/src/python/omorfi/entryguessing/gradation.py
index 7d3ed8cb..825d7ead 100755
--- a/src/python/omorfi/entryguessing/gradation.py
+++ b/src/python/omorfi/entryguessing/gradation.py
@@ -17,8 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

-from .omorfi.error_logging import fail_guess_because
-from .omorfi.string_mangling import replace_rightmost, replace_rightmosts
+from omorfi.error_logging import fail_guess_because
+from omorfi.string_manglers import replace_rightmost, replace_rightmosts


def gradation_make_morphophonemes(wordmap):
diff --git a/src/python/omorfi/entryguessing/guess_new_class.py b/src/python/omorfi/entryguessing/guess_new_class.py
index 1884716b..3a781bfc 100755
--- a/src/python/omorfi/entryguessing/guess_new_class.py
+++ b/src/python/omorfi/entryguessing/guess_new_class.py
@@ -17,8 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

-from .error_logging import fail_guess_because
-from .string_manglers import three_syllable
+from omorfi.error_logging import fail_guess_because
+from omorfi.string_manglers import three_syllable


def guess_new_class(wordmap):
diff --git a/src/python/omorfi/entryguessing/plurale_tantum.py b/src/python/omorfi/entryguessing/plurale_tantum.py
index a8af81fb..95fc4b7b 100755
--- a/src/python/omorfi/entryguessing/plurale_tantum.py
+++ b/src/python/omorfi/entryguessing/plurale_tantum.py
@@ -17,8 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

-from .error_logging import fail_guess_because
-from .omorfi.string_manglers import replace_rightmost, replace_rightmosts
+from omorfi.error_logging import fail_guess_because
+from omorfi.string_manglers import replace_rightmost, replace_rightmosts


def plurale_tantum_get_singular_stem(wordmap):
diff --git a/src/python/omorfi/formats/experimental_xml_formatter.py b/src/python/omorfi/formats/experimental_xml_formatter.py
index abccbff5..11b0f518 100755
--- a/src/python/omorfi/formats/experimental_xml_formatter.py
+++ b/src/python/omorfi/formats/experimental_xml_formatter.py
@@ -19,9 +19,9 @@

from xml.sax.saxutils import escape as xml_escape

-from ftb3_formatter import Ftb3Formatter
+from .ftb3_formatter import Ftb3Formatter

-from .settings import version_id_easter_egg
+from omorfi.settings import version_id_easter_egg


def make_xmlid(s):
diff --git a/src/python/omorfi/formats/lexc_formatter.py b/src/python/omorfi/formats/lexc_formatter.py
index 4ec616b7..b146129f 100755
--- a/src/python/omorfi/formats/lexc_formatter.py
+++ b/src/python/omorfi/formats/lexc_formatter.py
@@ -19,8 +19,8 @@

# functions for formatting the database data to lexc

-from .settings import deriv_boundary, morph_boundary, newword_boundary, optional_hyphen, stub_boundary, word_boundary
-from .string_manglers import lexc_escape
+from omorfi.settings import deriv_boundary, morph_boundary, newword_boundary, optional_hyphen, stub_boundary, word_boundary
+from omorfi.string_manglers import lexc_escape


def format_copyright_lexc():
10 changes: 5 additions & 5 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41280,15 +41280,15 @@ with pkgs;

charasay = callPackage ../tools/misc/charasay { };

waylyrics = callPackage ../applications/audio/waylyrics { };

gitrs = callPackage ../tools/misc/gitrs { };

libvoikko = callPackage ../development/libraries/libvoikko { };

hfst = callPackage ../development/libraries/hfst { };

omorfi = callPackage ../applications/misc/omorfi { };
omorfi = callPackage ../development/libraries/omorfi { };

hfst-ospell = callPackage ../development/libraries/hfst-ospell { };

waylyrics = callPackage ../applications/audio/waylyrics { };

gitrs = callPackage ../tools/misc/gitrs { };
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7155,6 +7155,8 @@ self: super: with self; {

omnilogic = callPackage ../development/python-modules/omnilogic { };

omorfi = callPackage ../development/python-modules/omorfi { };

omrdatasettools = callPackage ../development/python-modules/omrdatasettools { };

ondilo = callPackage ../development/python-modules/ondilo { };
Expand Down

0 comments on commit 8d34b31

Please sign in to comment.