mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 09:56:28 +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.
|
||||
"""
|
||||
import smart_open
|
||||
|
||||
# This logic is pretty hacky. We'd like pathy to do this probably?
|
||||
if ":/" not in str(dest):
|
||||
# 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.
|
||||
"""
|
||||
import smart_open
|
||||
|
||||
# This logic is pretty hacky. We'd like pathy to do this probably?
|
||||
if dest.exists() and not force:
|
||||
return None
|
||||
|
@ -314,15 +316,19 @@ def ensure_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():
|
||||
raise IOError("Destination of checkout must not exist")
|
||||
if not dest.parent.exists():
|
||||
raise IOError("Parent of destination of checkout must exist")
|
||||
# We're using Git and sparse checkout to only clone the files we need
|
||||
with make_tempdir() as tmp_dir:
|
||||
cmd = (f"git clone {repo} {tmp_dir} --no-checkout "
|
||||
"--depth 1 --config core.sparseCheckout=true")
|
||||
cmd = (
|
||||
f"git clone {repo} {tmp_dir} --no-checkout "
|
||||
"--depth 1 --config core.sparseCheckout=true"
|
||||
)
|
||||
if branch is not None:
|
||||
cmd = f"{cmd} -b {branch}"
|
||||
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))
|
||||
print(dest)
|
||||
print(list(dest.iterdir()))
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class PRFScore:
|
|||
def fscore(self) -> float:
|
||||
p = self.precision
|
||||
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]:
|
||||
return {"p": self.precision, "r": self.recall, "f": self.fscore}
|
||||
|
|
Loading…
Reference in New Issue
Block a user