commit 3c5cd937a88dff81ae572ed2288e4bc7758c615d Author: h7x4 Date: Mon Mar 27 09:30:23 2023 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcfc4a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result* diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0e72312 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1679710833, + "narHash": "sha256-9yKVvGX1oAnlc8vTVvN2lRH35q6ETudQbM1w9ragMRU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "83607dae4e05e1de755bbc7d7949b33fc1cfbbb9", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e3aa81c --- /dev/null +++ b/flake.nix @@ -0,0 +1,30 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-22.11"; + }; + + outputs = { self, nixpkgs }: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + packages.${system} = { + unidic = pkgs.callPackage ./nix/unidic.nix pkgs.python3Packages; + }; + + devShells.${system}.default = pkgs.mkShell { + packages = with pkgs; [ + mecab + ] ++ (with pkgs.python3Packages; [ + # flask + # flask-cors + mecab-python3 + nltk + pandas + # pip + python + scikit-learn + spacy + ]); + }; + }; +} diff --git a/nix/unidic.nix b/nix/unidic.nix new file mode 100644 index 0000000..085854e --- /dev/null +++ b/nix/unidic.nix @@ -0,0 +1,43 @@ +{ lib +, buildPythonPackage +, fetchPypi +, requests +, tqdm +, wasabi +, plac +, ... +# , mecab +# , swig +# , setuptools-scm +}: + +buildPythonPackage rec { + pname = "unidic"; + version = "1.1.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "CrkcBd40LITSpjFJAf06+5Bh7NdTTdSgQx3Mu4fZIbc="; + }; + + nativeBuildInputs = [ + requests + tqdm + wasabi + plac + # mecab # for mecab-config + # swig + # setuptools-scm + ]; + + # buildInputs = [ mecab ]; + + # doCheck = false; + + # meta = with lib; { + # description = "A python wrapper for mecab: Morphological Analysis engine"; + # homepage = "https://github.com/SamuraiT/mecab-python3"; + # license = with licenses; [ gpl2 lgpl21 bsd3 ]; # any of the three + # maintainers = with maintainers; [ ixxie ]; + # }; +} diff --git a/src/lmao.txt b/src/lmao.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..801704b --- /dev/null +++ b/src/main.py @@ -0,0 +1,11 @@ +import MeCab +tagger = MeCab.Tagger() + +parsed = tagger.parse("pythonが大好きです") +print(parsed.split()) + +parsed = parsed.encode('utf-16').decode('unicode-escape') + +# with open("lmao.txt", "w") as file: + # file.write(parsed) +print(parsed)