-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36abb01
commit 8f4f474
Showing
14 changed files
with
104 additions
and
91 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,6 +1,12 @@ | ||
!!! Note "" | ||
|
||
دقت تجزیهگر سطحی در نسخهٔ حاضر {{chunker_evaluation_value | to_persian_numeral}} درصد است. | ||
|
||
::: hazm.chunker | ||
handler: python | ||
options: | ||
members: - Chunker - tree2brackets | ||
show_root_heading: false | ||
show_source: false | ||
handler: python | ||
options: | ||
members: | ||
- Chunker | ||
- tree2brackets | ||
show_root_heading: false | ||
show_source: false |
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 +1,6 @@ | ||
!!! note "" | ||
|
||
دقت لماتایزر در نسخهٔ حاضر {{lemmatizer_evaluation_value | to_persian_numeral}} درصد است. | ||
|
||
|
||
::: hazm.lemmatizer |
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
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
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
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
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,52 @@ | ||
import toml | ||
from packaging import version | ||
import re | ||
|
||
def get_evaluation_values(): | ||
with open("README.md", "r", encoding="utf-8") as f: | ||
content = f.read() | ||
|
||
table = re.search(r"(?<=## Evaluation\n\n)[\s\S]*",content).group(0) | ||
|
||
pattern = r"\|(\s*[\w\s]+)\s*\|\s*\*\*(\d+\.\d+)\%\*\*\s*\|" | ||
matches = re.findall(pattern, table) | ||
|
||
evaluation_values = {module.strip(): float(value) for module, value in matches} | ||
|
||
return evaluation_values | ||
|
||
|
||
def define_env(env): | ||
env.variables.pretrained_models="https://github.com/roshan-research/hazm#pretrained-models" | ||
env.variables.lemmatizer_evaluation_value = get_evaluation_values()["Lemmatizer"] | ||
env.variables.posTagger_evaluation_value = get_evaluation_values()["POSTagger"] | ||
env.variables.dependency_parser_evaluation_value = get_evaluation_values()["DependencyParser"] | ||
env.variables.chunker_evaluation_value = get_evaluation_values()["Chunker"] | ||
|
||
|
||
@env.filter | ||
def to_persian_numeral(number): | ||
english_to_persian = {'0': '۰', '1': '۱', '2': '۲', '3': '۳', '4': '۴', '5': '۵', '6': '۶', '7': '۷', '8': '۸', '9': '۹'} | ||
return ''.join(english_to_persian.get(digit, digit) for digit in str(number)) | ||
|
||
@env.macro | ||
def needed_python_version(): | ||
with open('pyproject.toml', 'r') as f: | ||
toml_data = toml.load(f) | ||
|
||
python_reqs = toml_data.get('tool', {}).get('poetry', {}).get('dependencies', {}).get('python', '') | ||
|
||
versions = [version.parse(c.split('>=')[1]) for c in python_reqs.split(',') if c.startswith('>=')] | ||
min_version = "+"+str(min(versions)) if versions else '' | ||
|
||
return min_version | ||
|
||
@env.macro | ||
def hazm_code_example(): | ||
with open("README.md", 'r', encoding='utf-8') as file: | ||
markdown_content = file.read() | ||
|
||
pattern = r"(?<=## Usage\n\n)```python[\s\S]*```" | ||
|
||
return re.search(pattern, markdown_content).group(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