42
PLONE 5 & ML THE MOST POWERFUL PYTHON OPEN SOURCE CMS Created by / Ramon Navarro Bosch @bloodbare

Plone 5 and machine learning

Embed Size (px)

Citation preview

Page 1: Plone 5 and machine learning

PLONE 5 & MLTHE MOST POWERFUL PYTHON OPEN

SOURCE CMSCreated by / Ramon Navarro Bosch @bloodbare

Page 2: Plone 5 and machine learning

RAMON NAVARRO BOSCHPlone Foundation MemberPlone Framework TeamCTO at Iskra.catCatalan

Page 3: Plone 5 and machine learning

THE TALKPLONE 5Machine Learning

Page 4: Plone 5 and machine learning

PLONE 5QualityTestsProtect investment in current sitesUsability for real peopleStabilityScale from S to XL

Page 5: Plone 5 and machine learning

WHO DOES NOT KNOWPLONE?

From the user point of view

Page 6: Plone 5 and machine learning

CONTENTContent is the king (Dexterity)

With full multilingual

Page 7: Plone 5 and machine learning

GRANULAR SECURITY

Zope/ZODBWorkflow

Page 8: Plone 5 and machine learning

THEMING

RequireJS/LESSXSLT/DIAZO

Page 9: Plone 5 and machine learning

INLINE EDITION / TTW

Page 11: Plone 5 and machine learning

WHO DOES NOT KNOWPLONE

From the tech point of view

Page 12: Plone 5 and machine learning

HIERARCHY

Page 13: Plone 5 and machine learning

DEXTERITYfrom plone.app.textfield import RichTextfrom plone.autoform import directivesfrom plone.namedfile import field as namedfilefrom plone.supermodel.directives import fieldsetfrom plone.supermodel import modelfrom z3c.form.browser.radio import RadioFieldWidgetfrom zope import schemafrom zope.schema.vocabulary import SimpleVocabularyfrom zope.schema.vocabulary import SimpleTerm

from ploneconf.site import MessageFactory as _

LevelVocabulary = SimpleVocabulary( [SimpleTerm(value=u'platinum', title=_(u'Platinum Sponsor')), SimpleTerm(value=u'gold', title=_(u'Gold Sponsor')), SimpleTerm(value=u'silver', title=_(u'Silver Sponsor')),

Page 14: Plone 5 and machine learning

TRAVERSALhttp://yoursite.cat/folder-i-created/my-document/my_view

Page 15: Plone 5 and machine learning

VIEWSfrom Products.CMFCore.utils import getToolByNamefrom Products.Five.browser import BrowserViewfrom Products.CMFPlone.resources import add_resource_on_request

class TalkListView(BrowserView): """ A list of talks """

def __call__(self): add_resource_on_request(self.request, 'jquery.datatables') return super(TalkListView, self).__call__()

def talks(self): results = [] portal_catalog = getToolByName(self.context, 'portal_catalog') current_path = "/".join(self.context.getPhysicalPath())

Page 16: Plone 5 and machine learning

VIEWS II <browser:page name="talklistview" for="*" layer="..interfaces.IPloneconfSiteLayer" class=".views.TalkListView" template="templates/talklistview.pt" permission="zope2.View" />

Page 17: Plone 5 and machine learning

VIEWS III<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" metal:use-macro="context/main_template/macros/master" i18n:domain="ploneconf.site"><body>

<metal:head fill-slot="javascript_head_slot"> <script type="text/javascript">

{ var oTable = $('#talks').dataTable({ }

</script></metal:head>

<metal:content-core fill-slot="content-core">

<table class="listing" id="talks">

$(document).ready(function()

); })

Page 18: Plone 5 and machine learning

PYTHONICsite.folder.document.attribute

Page 19: Plone 5 and machine learning

ZOPE COMPONENTARCHITECTURE

Page 20: Plone 5 and machine learning

STORAGE OF COMPONENTSglobal registrylocal registry

Page 21: Plone 5 and machine learning

ADAPTER

class IPerson(Interface):

def whichTShirtIMWearing(self): pass

class CatalanGuy(object): implements(IPerson) def whichTShirtIMWearing(self): return "estelada"

class BaskGuy(object):

implements(IPerson)

Page 22: Plone 5 and machine learning

SUBSCRIBER<subscriber for="object.IKindOfObject zope.lifecycleevent.interfaces.IObjectModifiedEvent" handler="function" />

Page 23: Plone 5 and machine learning

UTILITY<utility for=".interfaces.IGoodAlcohol" handler=".object.GoodAlcohol" />

Page 24: Plone 5 and machine learning

JS/CSSMockup/Patterns

RequireJS/LESS

<input class="pat-pickadate" type="text" name="form.widgets.IDublinCore.effective" value="" data-pat-pickadate="{ 'date': { 'format': 'mmmm d, yyyy', 'max': [2035, 1, 1], 'min': [1915, 1, 1], 'firstDay': 0, 'selectYears': 200, 'placeholder': 'Posa una data', 'today': 'Avui'}, 'time': { 'placeholder': 'Tria l\'hora', 'today': 'Avui', 'format': 'h:i a'}}" >

Page 25: Plone 5 and machine learning

DIAZO<?xml version="1.0" encoding="UTF-8"?><rules xmlns="http://namespaces.plone.org/diazo" xmlns:css="http://namespaces.plone.org/diazo/css" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<theme href="/++theme++abb.basictheme/index.html" css:if-not-content=".userrole-anonymous" <theme href="/++theme++abb.basictheme/index-anon.html" css:if-content= <notheme css:if-not-content="#visual-portal-wrapper" />

<rules if-content="//*[@id='portal-top']"> <!-- Attributes --> <copy attributes="*" theme="/html" content="/html"/> <!-- Base tag --> <before theme="/html/head/title" content="/html/head/base"/> <!-- Title --> <replace theme="/html/head/title" content="/html/head/title" />

Page 26: Plone 5 and machine learning

REST APIplone.rest

<plone:service method="PUT" for="plone.dexterity.interfaces.IDexterityContent" factory=".demo.Put" />

Page 27: Plone 5 and machine learning

class Put(Service):

def render(self): return ISerializeToJSON(self.content)

Page 28: Plone 5 and machine learning

TESTINGJENKINS.PLONE.ORG

Page 29: Plone 5 and machine learning

... and the plone testing team

Page 30: Plone 5 and machine learning

PLONE 5.0 BETA 3!IS HERE!

git clone [email protected]/plone/jump.into.git

python2.7 bootstrap.py

# You need python-dev libpng-dev libjpeg-dev build-essential # libxml2-dev libxslt-dev (gcc)

./bin/buildout -v

# Coffee

./bin/instance fg

Page 31: Plone 5 and machine learning

TRAINING AND DOCStraining.plone.orgdocs.plone.org

Page 32: Plone 5 and machine learning

FUTURE (MY OPINION)?REST APIasyncioPyramid/SustanceDJS frontend

Page 33: Plone 5 and machine learning

MACHINE LEARNING?Content focused with sklearn

Page 34: Plone 5 and machine learning

GOALSRelated contentClassification of current content with existing data setRecommendation of subject tagsSemantic search on the live search

Page 35: Plone 5 and machine learning

CLUSTERINGGITHUB.COM/COLLECTIVE/COLLECTIVE.MACHINELEARNING

Page 36: Plone 5 and machine learning

ADAPTER ILEARNINGSTRINGfrom zope.component import getAdapterfrom collective.machinelearning.interfaces import ILearningString

getAdapter(obj, ILearningString)

Page 37: Plone 5 and machine learning

NORMALIZE AND VECTORIZEnltk.stemFeatureHasher

And we store the corpus as a pickle

Page 38: Plone 5 and machine learning

CLUSTERIZEDefine the number of clusters on FEKMeans!

And we store the model as a pickle

Page 39: Plone 5 and machine learning

We store on the objects to which cluster it belongsWe can predict new objects to which cluster it belongsSecurity is implicit by Plone

Page 40: Plone 5 and machine learning

FUTUREClassification (now trying Naive Bayes) on clusters(collective.gensim)RecommendationSemantic SearchExternal and incremental computation

Page 41: Plone 5 and machine learning

COMMUNITY

Page 42: Plone 5 and machine learning

THE ENDTHANKS@BLOODBARE

[email protected]