<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Index
Work
WorkOk
WorkSnowball
Forward Snowballing
Other
WorkUnrelated
WorkNoFile
WorkLang
Step1:  Work
Since this is the default class, it is used as a safety check.
No work should be stored with this class at the end of the snowballing.
If the work has this class, we did not decide yet whether the work is related or not.
Step2:  WorkOk
This class is used for related work that has not been explored with a backward snowballing yet.
Step3:  WorkSnowball
This class is used for related work that has been explored with backward snowballing.
Step4:  Forward Snowballing
Use the attribute .snowball to indicate when were performed the last snowball.
The query search WorkOk and WorkSnowball with outdated snowball attributes.
Step5:  Other
WorkUnrelated
Number of work unrelated to the snowballing
Step6:  WorkNoFile
Number of work without files
Step7:  WorkLang
Number of work in foreign languages
<ASSISTANT_TASK:>
Python Code:
import database
from datetime import datetime
from snowballing.operations import load_work, reload
from snowballing.jupyter_utils import work_button, idisplay
reload()
Explanation: Index
Work
WorkOk
WorkSnowball
Forward Snowballing
Other
WorkUnrelated
WorkNoFile
WorkLang
End of explanation
reload()
query = [idisplay(work_button(w)) for w in load_work() if w._category == "work"]
len(query)
Explanation: Work
Since this is the default class, it is used as a safety check.
No work should be stored with this class at the end of the snowballing.
If the work has this class, we did not decide yet whether the work is related or not.
End of explanation
reload()
query = [idisplay(work_button(w)) for w in load_work() if w._category == "ok"]
len(query)
Explanation: WorkOk
This class is used for related work that has not been explored with a backward snowballing yet.
End of explanation
reload()
query = [idisplay(work_button(w)) for w in load_work() if w._category == "snowball"]
len(query)
Explanation: WorkSnowball
This class is used for related work that has been explored with backward snowballing.
End of explanation
current_snowball = datetime(2017, 7, 26)
reload()
query = [
    idisplay(work_button(w))
    for w in load_work()
    if w._category in ("ok", "snowball")
    if not hasattr(w, "_snowball")
    or w._snowball < current_snowball
]
len(query)
Explanation: Forward Snowballing
Use the attribute .snowball to indicate when were performed the last snowball.
The query search WorkOk and WorkSnowball with outdated snowball attributes.
End of explanation
sum(
    1
    for w in load_work()
    if w._category == "unrelated"
)
Explanation: Other
WorkUnrelated
Number of work unrelated to the snowballing
End of explanation
sum(
    1
    for w in load_work()
    if w._category == "nofile"
)
Explanation: WorkNoFile
Number of work without files
End of explanation
sum(
    1
    for w in load_work()
    if w._category == "lang"
)
Explanation: WorkLang
Number of work in foreign languages
End of explanation
<END_TASK>