Skip to content

Commit

Permalink
Copy files from old Hg repo - no history kept
Browse files Browse the repository at this point in the history
  • Loading branch information
jwickberg committed Jun 3, 2020
1 parent 4420ecc commit 4ac6522
Show file tree
Hide file tree
Showing 66 changed files with 4,781 additions and 2 deletions.
80 changes: 80 additions & 0 deletions ChapterWordle/ChapterWordCloudPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.AddIn;
using System.AddIn.Pipeline;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using AddInSideViews;

namespace ChapterWordCloudPlugin
{
/// <summary>
/// Simple plugin that shows a text box that the user can enter text into. The text is
/// then persisted with the other Paratext project data.
/// </summary>
[AddIn(pluginName, Description = "Shows a \"Word Cloud\" of the current chapter.", Version = "1.0", Publisher = "SIL/UBS")]
[QualificationData(PluginMetaDataKeys.menuText, "&" + pluginName + "...")]
[QualificationData(PluginMetaDataKeys.insertAfterMenuName, "Tools|Advanced")]
[QualificationData(PluginMetaDataKeys.enableWhen, WhenToEnable.nonResourceProjectActive)]
[QualificationData(PluginMetaDataKeys.multipleInstances, CreateInstanceRule.always)]
public class ChapterWordCloudPlugin : IParatextAddIn
{
public const string pluginName = "Chapter Word Cloud";

private WordCloudForm form;

/// <summary>
/// Called by Paratext when the menu item created for this plugin was clicked.
/// </summary>
public void Run(IHost ptHost, string activeProjectName)
{
Form formToShow;
lock (this)
{
IScrExtractor extractor = ptHost.GetScriptureExtractor(activeProjectName, ExtractorType.USFM);
string vrsName = ptHost.GetProjectVersificationName(activeProjectName);
int currRef = ptHost.GetCurrentRef(vrsName);
int book = currRef / 1000000;
int chapter = (currRef / 1000) % 1000;
int bookAndChapter = (currRef / 1000) * 1000;
int startOfChapter = bookAndChapter + 1;
int endOfChapter = bookAndChapter + ptHost.GetLastVerse(book, chapter, vrsName);
string text = extractor.Extract(startOfChapter, endOfChapter);
StringBuilder bldr = new StringBuilder();
bool skipping = false;
for (int i = 0; i < text.Length; i++)
{
char ch = text[i];
if (ch == ' ')
skipping = false;
else
skipping |= (ch == '\\');
if (!skipping)
bldr.Append(ch);
}
formToShow = form = new WordCloudForm(bldr.ToString());
}
Application.Run(formToShow);
Environment.Exit(0);
}

public void RequestShutdown()
{
lock (this)
{
if (form != null)
{
form.Close();
}
}
}

public Dictionary<string, IPluginDataFileMergeInfo> DataFileKeySpecifications
{
get
{
return null;
}
}
}
}
100 changes: 100 additions & 0 deletions ChapterWordle/ChapterWordCloudPlugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6A715F31-42AC-4C17-9A34-E1FD42E49DAB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChapterWordCloudPlugin</RootNamespace>
<AssemblyName>ChapterWordCloudPlugin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AddInViews, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Paratext\Paratext\bin\Debug\Pipeline\AddInViews\AddInViews.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.AddIn">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.AddIn.Contract">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChapterWordCloudPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WordCloudForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="WordCloudForm.Designer.cs">
<DependentUpon>WordCloudForm.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lib\WordCloud\WordCloud.csproj">
<Project>{3C717173-CB43-417E-963A-83C4C4D9AC32}</Project>
<Name>WordCloud</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WordCloudForm.resx">
<DependentUpon>WordCloudForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>xcopy $(TargetDir)*.* "%25ParatextInstallDir%25\plugins\$(ProjectName)" /y /i</PostBuildEvent>
</PropertyGroup>
</Project>
Binary file added ChapterWordle/Gma.CodeCloud.Controls.dll
Binary file not shown.
36 changes: 36 additions & 0 deletions ChapterWordle/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ChapterWordCloud")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("ChapterWordCloud")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f66b61cd-f28d-4fd1-a2e0-5ce363c40b2a")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
90 changes: 90 additions & 0 deletions ChapterWordle/WordCloudForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions ChapterWordle/WordCloudForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Windows.Forms;
using Gma.CodeCloud.Controls.TextAnalyses.Extractors;
using Gma.CodeCloud.Controls.TextAnalyses.Processing;

namespace ChapterWordCloudPlugin
{
public partial class WordCloudForm : Form
{
public WordCloudForm(string text)
{
InitializeComponent();

IProgressIndicator progress = new ProgressBarWrapper(progressBar1);

IEnumerable<string> terms = new StringExtractor(text, progress);

cloudControl.WeightedWords = terms.CountOccurences().SortByOccurences();

progressBar1.Hide();
}

private class ProgressBarWrapper : IProgressIndicator
{
private readonly ProgressBar m_ProgressBar;

public ProgressBarWrapper(ProgressBar toolStripProgressBar)
{
m_ProgressBar = toolStripProgressBar;
}

public int Value
{
get { return m_ProgressBar.Value; }
set { m_ProgressBar.Value = value; }
}

public virtual int Maximum
{
get { return m_ProgressBar.Maximum; }
set { m_ProgressBar.Maximum = value; }
}

public virtual void Increment(int value)
{
m_ProgressBar.Increment(value);
Application.DoEvents();
}
}
}
}
Loading

0 comments on commit 4ac6522

Please sign in to comment.