Created
March 30, 2019 14:56
-
-
Save twmobius/22488ef62abad89fa98c123baeebdff8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from sklearn.feature_extraction.text import TfidfVectorizer | |
| from sklearn.linear_model import SGDClassifier | |
| corpus = ( | |
| "In the circumstances of your case, I propose to convicted you of the offence of aggravated burglary and sentence you to a term of imprisonment of 18 months.", | |
| "Sentence: 10 months imprisonment (302 days PSD) to be followed by a CCO of 2 years duration with unpaid community work, rehabilitative and supervision conditions.", | |
| "The total overall sentence is therefore 11 months' imprisonment to be followed by a two year CCO, and I will go back over the conditions shortly.", | |
| "I fix no minimum period so you will be required to serve 18 months.", | |
| "Overall I have concluded the most appropriate sentence to punish you is a Community Correction Order and not an immediate term of imprisonment to be served, as sought by the Crown.", | |
| "Your plea of guilty and co-operation. Your letter to the court expresses remorse. I accept that you are remorseful.", | |
| "Your personal history and circumstances. Your early life was unusually and markedly deprived. It was damaging to you. It is relevant to your sentence. As I have said, your intoxication on the days of offending offers no mitigation; however, your early life made you vulnerable to drug use and you began to abuse drugs when young and vulnerable. Your drug dependence should also be seen in that sympathetic light.", | |
| "Your letter expresses the wish to rehabilitate. I accept that you are genuine. No-one could wish for a return to the situation you experienced leading to the offences. However, it would be naïve not to be guarded about what will happen when you leave prison I do not utterly discount your prospects for rehabilitation, at 36. You will of course depend on abstinence from drugs. You will need assistance for that and I would say, pro-social accommodation if and when paroled. I do not seek to crush your hopes for such rehabilitation.", | |
| "I must apply the principles of totality. I shall order partial cumulation between the individual sentences in order to do that. However, there must also be some significant cumulation in order to reflect the individual circumstances and, for example, the individual impact on the victims.", | |
| "I take these moderating factors into account and I have attempted to give them proper weight, balanced against the serious and adverse considerations I have earlier identified. Ultimately, there must be a sentence which reflects the serious criminality of what you did.", | |
| "I propose sentencing now. Do you want to raise anything about ‑ ‑ ‑", | |
| "Mr Skonis, this offending is serious. You inappropriately took matters into your own hands. As I stated earlier when I was discussing the matter with counsel, I do not view this as being the most serious example of this very serious offence of aggravated burglary, nonetheless it was wrong for you to have gone around to the unit and entered the premises and assaulted the victim irrespective of your motivation. People are entitled to feel safe and secure in their own homes and you should have left Mr Warran's punishment to the police and courts. I note he is to be charged with respect to the earlier incident. Charges have been approved being one unlawful assault charge and one criminal damage charge.", | |
| "In mitigation, there are a combination of factors that I have taken into account on your behalf. Firstly, the early plea of guilty was entered at the earliest opportunity. You spared Mr Warran, the victim, the further trauma of having to come to court and give evidence on your trial and you saved the state the expense and inconvenience of a trial. There is real utility in your plea. I accept that you have facilitated justice and your sentence is to be discounted accordingly.", | |
| "Secondly, I am satisfied that the plea is indicative of genuine remorse. That is reflected in the submissions made by Mr McClure. I am satisfied you now have insight into your offending behaviour. You reacted angrily because of your upset concerning how the victim treated Violetta, but you now acknowledge and accept that you overstepped the mark.", | |
| "I have read all the references that I have received today: the references are from your fiancée, Seb Dibra; your friend Belinda Talevkski; Minna Mattiussi; Sabina Djelosevic; and Emina Ismakic.", | |
| "I take into account that your intention was to steal and not to confront or harm an occupant. It was opportunistic offending which was at a relatively low level for the offence of aggravated burglary, although not so low for theft when it comes to theft of a car from a residence, after stealing its keys." | |
| ) | |
| labels = (1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | |
| vectorizer = TfidfVectorizer() | |
| X = vectorizer.fit_transform(corpus) | |
| classifier = SGDClassifier(loss='hinge', penalty='l2', alpha = 1e-3, max_iter = 5, random_state = 42) | |
| classifier.fit(X, labels) | |
| test = ( | |
| "On Charge 13 of dealing with the proceeds of crime, you are convicted and sentenced to two months' imprisonment.", | |
| "I direct that one month of the sentence on the two summary charges of unlicensed driving be served - it's actually driving whilst disqualified - I have come to realise.", | |
| "The summary charges are not in themselves as serious as the indictable ones, and that, of course, is reflected in the maximum penalties. However, your repeated driving whilst disqualified was flagrant disregard for previously imposed restriction on your driving, and, as I will refer to shortly, you have a long history of unlicensed driving offences." | |
| ) | |
| test = vectorizer.transform(test) | |
| print(classifier.predict(test)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment