Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/GlobalConceptStoreSchema.java |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | protected RelationTable mergeTable; |
27 | 27 | protected RelationTable langprepTable; |
28 | 28 | protected RelationTable meaningTable; |
| 29 | + protected RelationTable aboutTable; |
29 | 30 | |
30 | 31 | private ConceptTypeSet conceptTypes; |
31 | 32 | protected TweakSet tweaks; |
— | — | @@ -109,9 +110,18 @@ |
110 | 111 | meaningTable.addKey( new DatabaseKey(this, KeyType.INDEX, "concept_lang", new String[] {"concept", "lang"}) ); |
111 | 112 | addTable(meaningTable); |
112 | 113 | |
| 114 | + aboutTable = new RelationTable(this, "about", getDefaultTableAttributes()); |
| 115 | + //aliasTable.addField( new DatabaseField(this, "id", "INT", "AUTO_INCREMENT", false, KeyType.PRIMARY) ); |
| 116 | + aboutTable.addField( new DatabaseField(this, "lang", getTextType(10), null, true, null ) ); |
| 117 | + aboutTable.addField( new ReferenceField(this, "local_resource", "INT", null, true, null, "resource", "id", null ) ); |
| 118 | + aboutTable.addField( new ReferenceField(this, "local_resource_name", getTextType(255), null, true, null, "resource", "name", null ) ); |
| 119 | + aboutTable.addField( new ReferenceField(this, "type", "INT", null, true, KeyType.INDEX, "concept", "id", null ) ); |
| 120 | + aboutTable.addField( new ReferenceField(this, "concept", "INT", null, true, null, "concept", "id", null ) ); |
| 121 | + aboutTable.addKey( new DatabaseKey(this, KeyType.INDEX, "by_concept", new String[] {"concept", "lang"}) ); |
| 122 | + aboutTable.addKey( new DatabaseKey(this, KeyType.INDEX, "by_resource_name", new String[] {"lang", "local_resource_name"}) ); |
| 123 | + aboutTable.addKey( new DatabaseKey(this, KeyType.INDEX, "by_resource_id", new String[] {"lang", "local_resource"}) ); |
| 124 | + addTable(aboutTable); |
113 | 125 | |
114 | | - //TODO: reference table (aka link) |
115 | | - |
116 | 126 | //getLanguages(); //initialize knownlanguages, corpuses and content types# |
117 | 127 | } |
118 | 128 | |
— | — | @@ -125,7 +135,8 @@ |
126 | 136 | checkIdSanity(originTable, "local_concept"); |
127 | 137 | checkReferentialIntegrity(originTable, "global_concept", false); |
128 | 138 | checkReferentialIntegrity(meaningTable, "concept", false); |
129 | | - |
| 139 | + checkReferentialIntegrity(aboutTable, "about", false); |
| 140 | + |
130 | 141 | checkReferentialIntegrity(relationTable, "concept1", false); |
131 | 142 | checkReferentialIntegrity(relationTable, "concept2", false); |
132 | 143 | |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildThesaurus.java |
— | — | @@ -93,9 +93,9 @@ |
94 | 94 | } |
95 | 95 | |
96 | 96 | section("-- buildMeaningIndex --------------------------------------------------"); |
97 | | - if (agenda.beginTask("BuildThesaurus.run", "buildMeaningIndex")) { |
98 | | - this.conceptStore.buildMeaningIndex(); |
99 | | - agenda.endTask("BuildThesaurus.run", "buildMeaningIndex"); |
| 97 | + if (agenda.beginTask("BuildThesaurus.run", "buildGlobalIndexes")) { |
| 98 | + this.conceptStore.buildGlobalIndexes(); |
| 99 | + agenda.endTask("BuildThesaurus.run", "buildGlobalIndexes"); |
100 | 100 | } |
101 | 101 | |
102 | 102 | /* |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/GlobalConceptStoreBuilder.java |
— | — | @@ -23,6 +23,6 @@ |
24 | 24 | |
25 | 25 | public void setLanguages(String[] languages) throws PersistenceException; |
26 | 26 | |
27 | | - public void buildMeaningIndex() throws PersistenceException; |
| 27 | + public void buildGlobalIndexes() throws PersistenceException; |
28 | 28 | |
29 | 29 | } |
\ No newline at end of file |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseGlobalConceptStoreBuilder.java |
— | — | @@ -54,6 +54,7 @@ |
55 | 55 | |
56 | 56 | protected RelationTable originTable; |
57 | 57 | protected RelationTable meaningTable; |
| 58 | + protected RelationTable aboutTable; |
58 | 59 | |
59 | 60 | protected RelationTable mergeTable; |
60 | 61 | //protected RelationTable langprepTable; |
— | — | @@ -111,6 +112,9 @@ |
112 | 113 | Inserter meaningInserter = configureTable("meaning", 16, 4*1024); |
113 | 114 | meaningTable = (RelationTable)meaningInserter.getTable(); |
114 | 115 | |
| 116 | + Inserter aboutInserter = configureTable("about", 16, 4*1024); |
| 117 | + aboutTable = (RelationTable)aboutInserter.getTable(); |
| 118 | + |
115 | 119 | mergeInserter = configureTable("merge", 16, 4*1024); |
116 | 120 | mergeTable = (RelationTable)mergeInserter.getTable(); |
117 | 121 | |
— | — | @@ -678,7 +682,19 @@ |
679 | 683 | } |
680 | 684 | } |
681 | 685 | |
682 | | - public void buildMeaningIndex() throws PersistenceException { |
| 686 | + public void buildGlobalIndexes() throws PersistenceException { |
| 687 | + if (beginTask("buildGlobalIndexes", "importAbout")) { |
| 688 | + importAbout(); |
| 689 | + endTask("buildGlobalIndexes", "importAbout"); |
| 690 | + } |
| 691 | + |
| 692 | + if (beginTask("buildGlobalIndexes", "buildMeaningIndex")) { |
| 693 | + buildMeaningIndex(); |
| 694 | + endTask("buildGlobalIndexes", "buildMeaningIndex"); |
| 695 | + } |
| 696 | + } |
| 697 | + |
| 698 | + protected void buildMeaningIndex() throws PersistenceException { |
683 | 699 | Corpus[] cc = getLanguages(); |
684 | 700 | |
685 | 701 | for (Corpus c: cc) { |
— | — | @@ -703,7 +719,35 @@ |
704 | 720 | int n = executeChunkedUpdate("importMeanings", "import("+c.getLanguage()+")", sql, null, localMeanings, "M.concept"); |
705 | 721 | return n; |
706 | 722 | } |
| 723 | + |
| 724 | + public void importAbout() throws PersistenceException { |
| 725 | + Corpus[] cc = getLanguages(); |
| 726 | + |
| 727 | + for (Corpus c: cc) { |
| 728 | + if (beginTask("importAbout", "importAbout#"+c.getLanguage())) { |
| 729 | + importAbout(c); |
| 730 | + endTask("importAbout", "importAbout#"+c.getLanguage()); |
| 731 | + } |
| 732 | + } |
| 733 | + } |
707 | 734 | |
| 735 | + private int importAbout(Corpus c) throws PersistenceException { |
| 736 | + LocalConceptStoreSchema localdb = getLocalConceptDatabase(c); |
| 737 | + DatabaseTable localAbout = localdb.getTable("about"); |
| 738 | + DatabaseTable localResource = localdb.getTable("resource"); |
| 739 | + DatabaseTable origin = database.getTable("origin"); |
| 740 | + |
| 741 | + String sql = "INSERT INTO "+aboutTable.getSQLName()+" (concept, lang, local_resource, local_resource_name, type) " |
| 742 | + + " SELECT O.global_concept, "+database.quoteString(c.getLanguage())+", R.id, R.name, R.type " |
| 743 | + + " FROM "+origin.getSQLName()+" as O " |
| 744 | + + " JOIN "+localAbout.getSQLName()+" as A ON A.concept = O.local_concept " |
| 745 | + + " AND O.lang = "+database.quoteString(c.getLanguage()) + " " |
| 746 | + + " JOIN "+localResource.getSQLName()+" as R ON R.id = A.resource "; |
| 747 | + |
| 748 | + int n = executeChunkedUpdate("importAbout", "import("+c.getLanguage()+")", sql, null, localAbout, "A.concept"); |
| 749 | + return n; |
| 750 | + } |
| 751 | + |
708 | 752 | public void clusterGlobalConcepts() throws PersistenceException { |
709 | 753 | int i = 0; |
710 | 754 | while (true) { |