Initial commit

This commit is contained in:
Oystein Kristoffer Tveit 2023-03-27 09:30:23 +02:00
commit 3c5cd937a8
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
6 changed files with 111 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result*

26
flake.lock Normal file
View File

@ -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
}

30
flake.nix Normal file
View File

@ -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
]);
};
};
}

43
nix/unidic.nix Normal file
View File

@ -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 ];
# };
}

0
src/lmao.txt Normal file
View File

11
src/main.py Normal file
View File

@ -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)