-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from amir-zeldes/dev
V2.2.0
- Loading branch information
Showing
8 changed files
with
135 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
scikit-learn | ||
joblib | ||
scikit-learn==1.3.2 | ||
joblib==1.3.2 | ||
numpy | ||
pandas | ||
xgboost==0.81 | ||
pandas==2.1.2 | ||
xgboost==2.0.3 | ||
hyperopt | ||
flair==0.6.1 | ||
flair==0.13.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
Simple utility to convert conllu files to tab-separated files with segments | ||
""" | ||
|
||
import io, os, sys, re | ||
from glob import glob | ||
|
||
def get_segs(conllu): | ||
super_length = 0 | ||
limit = 10 # Maximum bound group length in units, discard sentences with longer groups | ||
sents = [] | ||
words = [] | ||
labels = [] | ||
word = [] | ||
max_len = 0 | ||
lines = conllu.split("\n") | ||
for l, line in enumerate(lines): | ||
if "\t" in line: | ||
fields = line.split("\t") | ||
if "-" in fields[0]: | ||
start, end = fields[0].split("-") | ||
super_length = int(end) - int(start) + 1 | ||
else: | ||
if super_length > 0: | ||
word.append(fields[1]) | ||
super_length -= 1 | ||
if super_length == 0: | ||
words.append("".join(word)) | ||
labels.append("|".join(word)) | ||
if len(word) > max_len: | ||
max_len = len(word) | ||
word = [] | ||
else: | ||
if "SpaceAfter=No" in line and ("ADP\t" in line or "DET\t" in line): | ||
done = False | ||
word.append(fields[1]) | ||
counter = 1 | ||
while not done: | ||
if "SpaceAfter" in lines[l+counter] and not ("\t,\t" in lines[l+counter+1] or "\t.\t" in lines[l+counter+1]): | ||
super_length += 1 | ||
counter += 1 | ||
else: | ||
super_length += 1 | ||
done = True | ||
if super_length > 10: | ||
print(l) | ||
quit() | ||
else: | ||
words.append(fields[1]) | ||
labels.append(fields[1]) | ||
elif len(line) == 0 and len(words) > 0: | ||
if max_len > limit or " " in "".join(words): # Reject sentence | ||
max_len = 0 | ||
else: | ||
sents.append("\n".join([w + "\t" + l for w, l, in zip(words, labels)])) | ||
words = [] | ||
labels = [] | ||
return "\n".join(sents) | ||
|
||
files = glob("*.conllu") | ||
|
||
for file_ in files: | ||
seg_data = get_segs(io.open(file_).read()) | ||
with io.open(os.path.basename(file_) + ".tab",'w',encoding="utf8",newline="\n") as f: | ||
f.write(seg_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,15 @@ | |
setup( | ||
name = 'rftokenizer', | ||
packages = find_packages(), | ||
version = '2.0.1', | ||
version = '2.2.0', | ||
description = 'A character-wise tokenizer for morphologically rich languages', | ||
author = 'Amir Zeldes', | ||
author_email = '[email protected]', | ||
package_data = {'':['README.md','LICENSE.md','requirements.txt'],'rftokenizer':['data/*','pred/*','models/*']}, | ||
url = 'https://github.com/amir-zeldes/RFTokenizer', | ||
install_requires=["scikit-learn","numpy","pandas","xgboost==0.81","hyperopt","joblib"], | ||
install_requires=["scikit-learn","numpy","pandas","xgboost==2.0.3","hyperopt","joblib"], | ||
license='Apache License, Version 2.0', | ||
download_url = 'https://github.com/amir-zeldes/RFTokenizer/releases/tag/v2.0.1', | ||
download_url = 'https://github.com/amir-zeldes/RFTokenizer/releases/tag/v2.2.0', | ||
keywords = ['NLP', 'tokenization', 'segmentation', 'morphology', 'morphological', 'Hebrew', 'Arabic', 'Coptic', 'word', 'splitting'], | ||
classifiers = ['Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
|