mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 10:46:29 +03:00
Format
This commit is contained in:
parent
0fffee749e
commit
eb3f6a4cb5
|
@ -262,6 +262,7 @@ def upload_file(src: Path, dest: Union[str, "Pathy"]) -> None:
|
||||||
url (str): The destination URL to upload to.
|
url (str): The destination URL to upload to.
|
||||||
"""
|
"""
|
||||||
import smart_open
|
import smart_open
|
||||||
|
|
||||||
# This logic is pretty hacky. We'd like pathy to do this probably?
|
# This logic is pretty hacky. We'd like pathy to do this probably?
|
||||||
if ":/" not in str(dest):
|
if ":/" not in str(dest):
|
||||||
# Local path
|
# Local path
|
||||||
|
@ -288,6 +289,7 @@ def download_file(src: Union[str, "Pathy"], dest: Path, *, force: bool = False)
|
||||||
If False, the download will be skipped.
|
If False, the download will be skipped.
|
||||||
"""
|
"""
|
||||||
import smart_open
|
import smart_open
|
||||||
|
|
||||||
# This logic is pretty hacky. We'd like pathy to do this probably?
|
# This logic is pretty hacky. We'd like pathy to do this probably?
|
||||||
if dest.exists() and not force:
|
if dest.exists() and not force:
|
||||||
return None
|
return None
|
||||||
|
@ -314,15 +316,19 @@ def ensure_pathy(path):
|
||||||
return Pathy(path)
|
return Pathy(path)
|
||||||
|
|
||||||
|
|
||||||
def git_sparse_checkout(repo: str, subpath: str, dest: Path, *, branch: Optional[str]=None):
|
def git_sparse_checkout(
|
||||||
|
repo: str, subpath: str, dest: Path, *, branch: Optional[str] = None
|
||||||
|
):
|
||||||
if dest.exists():
|
if dest.exists():
|
||||||
raise IOError("Destination of checkout must not exist")
|
raise IOError("Destination of checkout must not exist")
|
||||||
if not dest.parent.exists():
|
if not dest.parent.exists():
|
||||||
raise IOError("Parent of destination of checkout must exist")
|
raise IOError("Parent of destination of checkout must exist")
|
||||||
# We're using Git and sparse checkout to only clone the files we need
|
# We're using Git and sparse checkout to only clone the files we need
|
||||||
with make_tempdir() as tmp_dir:
|
with make_tempdir() as tmp_dir:
|
||||||
cmd = (f"git clone {repo} {tmp_dir} --no-checkout "
|
cmd = (
|
||||||
"--depth 1 --config core.sparseCheckout=true")
|
f"git clone {repo} {tmp_dir} --no-checkout "
|
||||||
|
"--depth 1 --config core.sparseCheckout=true"
|
||||||
|
)
|
||||||
if branch is not None:
|
if branch is not None:
|
||||||
cmd = f"{cmd} -b {branch}"
|
cmd = f"{cmd} -b {branch}"
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
@ -334,5 +340,3 @@ def git_sparse_checkout(repo: str, subpath: str, dest: Path, *, branch: Optional
|
||||||
shutil.move(str(tmp_dir / Path(subpath)), str(dest))
|
shutil.move(str(tmp_dir / Path(subpath)), str(dest))
|
||||||
print(dest)
|
print(dest)
|
||||||
print(list(dest.iterdir()))
|
print(list(dest.iterdir()))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ def convert(
|
||||||
converter: str = "auto",
|
converter: str = "auto",
|
||||||
ner_map: Optional[Path] = None,
|
ner_map: Optional[Path] = None,
|
||||||
lang: Optional[str] = None,
|
lang: Optional[str] = None,
|
||||||
concatenate: bool=False,
|
concatenate: bool = False,
|
||||||
silent: bool = True,
|
silent: bool = True,
|
||||||
msg: Optional[Printer],
|
msg: Optional[Printer],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -40,7 +40,7 @@ class PRFScore:
|
||||||
def fscore(self) -> float:
|
def fscore(self) -> float:
|
||||||
p = self.precision
|
p = self.precision
|
||||||
r = self.recall
|
r = self.recall
|
||||||
return (2 * ((p * r) / (p + r + 1e-100)))
|
return 2 * ((p * r) / (p + r + 1e-100))
|
||||||
|
|
||||||
def to_dict(self) -> Dict[str, float]:
|
def to_dict(self) -> Dict[str, float]:
|
||||||
return {"p": self.precision, "r": self.recall, "f": self.fscore}
|
return {"p": self.precision, "r": self.recall, "f": self.fscore}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user